Я пытаюсь выполнить скрипт с тамперной обезьяной, которая добавляет значок и выполняет задачу открытия всех ссылок на веб-странице по щелчку, и вот источник скрипта https://gist.github.com/jameshibbard/3831983#file-gistfile1-js .
Значок добавляется на страницу при включении скрипта, но переход по ссылке не работает.
Я понял, что это может быть связано с проблемами совместимости jquery, и попробовал ниже изменения в загрузке jquery
// ==UserScript==
// @name Open CodeProject Links
// @namespace http://hibbard.eu/
// @version 0.1
// @description Opens all of the links from the CodeProject newsletter in one go
// @match *://www.codeproject.com/script/Mailouts/*
// @copyright 2012+, hibbard.eu
// @require https://code.jquery.com/jquery-latest.js
// @grant GM_log
// ==/UserScript==
//- The @grant directive is needed to restore the proper sandbox.
// a function that loads jQuery and calls a callback function when jQuery has finished loading
function addJQuery(callback) {
var script = document.createElement("script");
script.setAttribute("src", "//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js");
script.addEventListener('load', function() {
var script = document.createElement("script");
script.textContent = "window.jQ=jQuery.noConflict(true);(" + callback.toString() + ")();";
document.body.appendChild(script);
}, false);
document.body.appendChild(script);
}
function main(){
$(document).ready(function() {
//var my_jquery = jQuery;
//jQuery.noConflict(true);
//var $ = my_jquery, jQuery = my_jquery;
var hrefs = new Array();
var elements = $('.headline > a');
elements.each(function() {
hrefs.push($(this).attr('href'));
});
$('body').append('<input type="button" value="Open Links" id="CP">');
$("#CP").css("position", "fixed").css("top", 0).css("left", 0);
$('#CP').click(function(){
$.each(hrefs, function(index, value) {
setTimeout(function(){
window.open(value, '_blank');
},1000);
});
});
});
}
// load jQuery and execute the main function
addJQuery(main);
Но это тоже не работает. Может ли кто-нибудь помочь мне решить проблему с выполнением нажатия кнопки с тамперной обезьяной?