09/09 - Fresh Friday!

Status
Not open for further replies.

Kerek

Red Cat-Bear
Contributor
Crowd Pleaser
Joined
Jan 12, 2016
Messages
65,210
Reaction score
145,751
Points
2,088
Gender
Male
Code:
// ==UserScript==
// @name         Aristo MTurk - Rank science information
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       turker
// @grant        none
// @include      https://www.mturkcontent.com/*
// @require      http://code.jquery.com/jquery-latest.min.js
// ==/UserScript==
var counter = 0;
var evenNum = [];
evenNum[0] = 0;
evenNum[1] = 2;
evenNum[2] = 4;
evenNum[3] = 6;
evenNum[4] = 8;
evenNum[5] = 10;
var oddNum = [];
oddNum[0] = 1;
oddNum[1] = 3;
oddNum[2] = 5;
oddNum[3] = 7;
oddNum[4] = 9;
oddNum[5] = 11;
var mostOrLeast = 0;
document.getElementsByTagName("body")[0].onkeydown = function(event) {
for (a=0;a<4;a++) {
if (event.keyCode == a+49) {
for (i=0;i<evenNum.length;i++) {
if (counter == evenNum[i]) {
mostOrLeast = a;
}
else if (counter == oddNum[i]) {
mostOrLeast = a+4;
}
}
document.getElementsByClassName("diff-pair-table")[0].getElementsByTagName("input")[mostOrLeast].checked = true;
//document.getElementsByClassName("diff-pair-table")[0].getElementsByTagName("input")[mostOrLeast].checked = true;
counter = counter + 1;
}
}
};
I rewrote my script from scratch. does anyone know why this doesn't work? it should answer the first part of question 1 on pressing key 1,2,3, or 4. it works other than it doesn't click the bubble. clicking the bubble does work if I do that outside of the onkeydown part. like this -
Code:
// ==UserScript==
// @name         Aristo MTurk - Rank science information
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       turker
// @grant        none
// @include      https://www.mturkcontent.com/*
// @require      http://code.jquery.com/jquery-latest.min.js
// ==/UserScript==
var counter = 0;
var evenNum = [];
evenNum[0] = 0;
evenNum[1] = 2;
evenNum[2] = 4;
evenNum[3] = 6;
evenNum[4] = 8;
evenNum[5] = 10;
var oddNum = [];
oddNum[0] = 1;
oddNum[1] = 3;
oddNum[2] = 5;
oddNum[3] = 7;
oddNum[4] = 9;
oddNum[5] = 11;
var mostOrLeast = 0;


document.getElementsByClassName("diff-pair-table")[0].getElementsByTagName("input")[0].checked = true;



document.getElementsByTagName("body")[0].onkeydown = function(event) {
for (a=0;a<4;a++) {
if (event.keyCode == a+49) {
for (i=0;i<evenNum.length;i++) {
if (counter == evenNum[i]) {
mostOrLeast = a;
}
else if (counter == oddNum[i]) {
mostOrLeast = a+4;
}
}
//document.getElementsByClassName("diff-pair-table")[0].getElementsByTagName("input")[mostOrLeast].checked = true;
//document.getElementsByClassName("diff-pair-table")[0].getElementsByTagName("input")[mostOrLeast].checked = true;
counter = counter + 1;
}
}
};
Seems to work fine for me, you just need to change the 0 to something that changes with the counter, e.g.,

document.getElementsByClassName("diff-pair-table")[0].getElementsByTagName("input")[mostOrLeast].checked = true;

should be

document.getElementsByClassName("diff-pair-table")[Math.floor(counter/2)].getElementsByTagName("input")[mostOrLeast].checked = true;

so that it actually moves to the next table

Code:
// ==UserScript==
// @name         Aristo MTurk - Rank science information
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       turker
// @grant        none
// @include      https://www.mturkcontent.com/*
// @require      http://code.jquery.com/jquery-latest.min.js
// ==/UserScript==
var counter = 0;
var evenNum = [];
evenNum[0] = 0;
evenNum[1] = 2;
evenNum[2] = 4;
evenNum[3] = 6;
evenNum[4] = 8;
evenNum[5] = 10;
var oddNum = [];
oddNum[0] = 1;
oddNum[1] = 3;
oddNum[2] = 5;
oddNum[3] = 7;
oddNum[4] = 9;
oddNum[5] = 11;
var mostOrLeast = 0;
document.getElementsByTagName("body")[0].onkeydown = function(event) {
for (a=0;a<4;a++) {
if (event.keyCode == a+49) {
for (i=0;i<evenNum.length;i++) {
if (counter == evenNum[i]) {
mostOrLeast = a;
}
else if (counter == oddNum[i]) {
mostOrLeast = a+4;
}
}
document.getElementsByClassName("diff-pair-table")[Math.floor(counter/2)].getElementsByTagName("input")[mostOrLeast].checked = true;
//document.getElementsByClassName("diff-pair-table")[0].getElementsByTagName("input")[mostOrLeast].checked = true;
counter = counter + 1;
}
}
};
(Although I'd just use AHK for this probably)
 
Last edited:
  • Like
Reactions: Pleco

Concise

Buddhist Bacchante
Joined
Apr 28, 2016
Messages
4,103
Reaction score
6,421
Points
813
You've received a bonus from Pamela R Murphy for work related to &^&*(()CJ8JLZ63.
The value of your bonus is: $5.00 USD

The Requester included this note:
Payment for reported performance on trivia quiz.

Thanks for being a Worker on Mechanical Turk!
 
  • Like
Reactions: Itsmee
D

Deleted member 526

Guest
Seems to work fine for me, you just need to change the 0 to something that changes with the counter, e.g.,

document.getElementsByClassName("diff-pair-table")[0].getElementsByTagName("input")[mostOrLeast].checked = true;

should be

document.getElementsByClassName("diff-pair-table")[Math.floor(counter/2)].getElementsByTagName("input")[mostOrLeast].checked = true;

so that it actually moves to the next table
TY I was going to figure that out next. you saved me some time! but even this doesn't work. nothing at all works on keydown.

Code:
// ==UserScript==
// @name         Aristo MTurk - Rank science information
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       turker
// @grant        none
// @include      https://www.mturkcontent.com/*
// @require      http://code.jquery.com/jquery-latest.min.js
// ==/UserScript==
if ( $("body:contains('Sentence pattern')").length ) {
var counter = 0;
var evenNum = [];
evenNum[0] = 0;
evenNum[1] = 2;
evenNum[2] = 4;
evenNum[3] = 6;
evenNum[4] = 8;
evenNum[5] = 10;
var oddNum = [];
oddNum[0] = 1;
oddNum[1] = 3;
oddNum[2] = 5;
oddNum[3] = 7;
oddNum[4] = 9;
oddNum[5] = 11;
var mostOrLeast = 0;
   
   
   
document.getElementsByTagName("body")[0].onkeydown = function(event) {
   
   
     alert("y");
   
};
}
 

Kerek

Red Cat-Bear
Contributor
Crowd Pleaser
Joined
Jan 12, 2016
Messages
65,210
Reaction score
145,751
Points
2,088
Gender
Male
TY I was going to figure that out next. you saved me some time! but even this doesn't work. nothing at all works on keydown.

Code:
// ==UserScript==
// @name         Aristo MTurk - Rank science information
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       turker
// @grant        none
// @include      https://www.mturkcontent.com/*
// @require      http://code.jquery.com/jquery-latest.min.js
// ==/UserScript==
if ( $("body:contains('Sentence pattern')").length ) {
var counter = 0;
var evenNum = [];
evenNum[0] = 0;
evenNum[1] = 2;
evenNum[2] = 4;
evenNum[3] = 6;
evenNum[4] = 8;
evenNum[5] = 10;
var oddNum = [];
oddNum[0] = 1;
oddNum[1] = 3;
oddNum[2] = 5;
oddNum[3] = 7;
oddNum[4] = 9;
oddNum[5] = 11;
var mostOrLeast = 0;
 
 
 
document.getElementsByTagName("body")[0].onkeydown = function(event) {
 
 
     alert("y");
 
};
}
Works fine for me. You have to focus the frame (by clicking in it, or using Scroll to Workspace, or something)
 
  • Like
Reactions: Deleted member 526
D

Deleted member 526

Guest
Works fine for me. You have to focus the frame (by clicking in it, or using Scroll to Workspace, or something)
oh it was the focus!! Thanks! now it works! :D
 
Last edited by a moderator:
  • Like
Reactions: Kerek

Pleco

Friendly Neighborhood Rat
Contributor
Crowd Pleaser
Joined
Jan 23, 2016
Messages
19,190
Reaction score
76,218
Points
1,588
Age
38
Gender
Male
Seems to work fine for me, you just need to change the 0 to something that changes with the counter, e.g.,

document.getElementsByClassName("diff-pair-table")[0].getElementsByTagName("input")[mostOrLeast].checked = true;

should be

document.getElementsByClassName("diff-pair-table")[Math.floor(counter/2)].getElementsByTagName("input")[mostOrLeast].checked = true;

so that it actually moves to the next table

Code:
// ==UserScript==
// @name         Aristo MTurk - Rank science information
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       turker
// @grant        none
// @include      https://www.mturkcontent.com/*
// @require      http://code.jquery.com/jquery-latest.min.js
// ==/UserScript==
var counter = 0;
var evenNum = [];
evenNum[0] = 0;
evenNum[1] = 2;
evenNum[2] = 4;
evenNum[3] = 6;
evenNum[4] = 8;
evenNum[5] = 10;
var oddNum = [];
oddNum[0] = 1;
oddNum[1] = 3;
oddNum[2] = 5;
oddNum[3] = 7;
oddNum[4] = 9;
oddNum[5] = 11;
var mostOrLeast = 0;
document.getElementsByTagName("body")[0].onkeydown = function(event) {
for (a=0;a<4;a++) {
if (event.keyCode == a+49) {
for (i=0;i<evenNum.length;i++) {
if (counter == evenNum[i]) {
mostOrLeast = a;
}
else if (counter == oddNum[i]) {
mostOrLeast = a+4;
}
}
document.getElementsByClassName("diff-pair-table")[Math.floor(counter/2)].getElementsByTagName("input")[mostOrLeast].checked = true;
//document.getElementsByClassName("diff-pair-table")[0].getElementsByTagName("input")[mostOrLeast].checked = true;
counter = counter + 1;
}
}
};
(Although I'd just use AHK for this probably)
Where's the red panda? I Liked it anyway.
 
  • Like
Reactions: YAHU and Kerek

SleepComa

Drifting through the stars...
Joined
Sep 7, 2016
Messages
3,817
Reaction score
8,152
Points
763
Location
So-Cal
Gender
Male
Other than the server crashing, that $!0 hit was ez pz.
 
  • Like
Reactions: kryss

Kerek

Red Cat-Bear
Contributor
Crowd Pleaser
Joined
Jan 12, 2016
Messages
65,210
Reaction score
145,751
Points
2,088
Gender
Male
YAHU @YAHU [that thread] is a mess. Good job.
 
  • Like
Reactions: YAHU

SleepComa

Drifting through the stars...
Joined
Sep 7, 2016
Messages
3,817
Reaction score
8,152
Points
763
Location
So-Cal
Gender
Male
TessBrooks why won't you Qualify me?
 
Status
Not open for further replies.