// ==UserScript==
// @name Peter Burke - Duplicate Article Detection
// @namespace https://www.mturkcrowd.com/members/aveline.7/
// @version 1.0
// @description Probably does nothing.
// @author aveline
// @icon https://i.imgur.com/jsju8Wy.png
// @include *
// @require http://code.jquery.com/jquery-3.2.1.min.js
// @grant none
// ==/UserScript==
let popup;
// Submit button
function submit() {
if (popup) popup.close();
document.querySelector(`[type="submit"]`).click();
}
function windowIsOnEndor() {
return window.location.href.includes('endor');
}
if (windowIsOnEndor()) {
var yes = document.getElementsByTagName('input')[1];
var no = document.getElementsByTagName('input')[2];
var na = document.getElementsByTagName('input')[3];
let linko1 = window.open(document.getElementsByTagName("a")[0].href,"linko1","width=" + screen.availWidth/2 + ",height=" + (screen.availHeight/2 - 30) + ",left=" + screen.availWidth/2);
let linko2 = window.open(document.getElementsByTagName("a")[1].href,"linko2","width=" + screen.availWidth/2 + ",height=" + (screen.availHeight/2 - 30) + ",left=" + screen.availWidth/2 + ",top=" + screen.availHeight/2);
window.addEventListener("beforeunload", function() {
linko1.close();
linko2.close();
});
window.addEventListener("message", listener, false);
}
function listener(l){
var info = l.data;
if (l.data == 'yes') {
yes.click();
} else if (l.data == 'no') {
no.click();
} else if (l.data == 'na') {
na.click();
} else if (l.data == 'submit') {
submit();
} else {
console.log(info);
}
}
function kas(i) {
// Yes
if (i.keyCode == 49){// 1
i.preventDefault();
window.opener.postMessage('yes', '*');
}
// No
if (i.keyCode == 50){// 2
i.preventDefault();
window.opener.postMessage('no', '*');
}
// N/A
if (i.keyCode == 51) {//3
i.preventDefault();
window.opener.postMessage('na', '*');
}
// Submit
if (i.keyCode == 192) {//`
i.preventDefault();
window.opener.postMessage('submit', '*');
}
}
if (!windowIsOnEndor()) {
console.log('errrr');
document.addEventListener('keydown', kas, true);
}