所以,我有这个脚本,它将从这个页面上的表格中获取链接(“x”是登录用户页面上的链接)......
所以我正在尝试使用 Brock 帮助我处理另一个脚本的弹出循环内容......链接被正确添加到“linksToOpen”数组中(或者在我添加按钮、侦听器和“openLinksInSequence”函数之前)。 ..一切似乎都很好,我没有收到任何错误消息......但我的按钮不起作用!
// ==UserScript==
// @name Unicreatures Accoplishment Checker
// @namespace http://trueidiocy.us
// @description Marks off completed accomplishments
// @include http://unicreatures.com/accomplishments.php
// @include http://www.unicreatures.com/accomplishments.php
// @include http://unicreatures.com/accomplishments.php?
// @include http://www.unicreatures.com/accomplishments.php?
// @version 1
// @grant GM_addStyle
// ==/UserScript==
var mytable = document.getElementById('right').getElementsByTagName('table')[4];
var links=mytable.getElementsByTagName('a');
var i;
var linksToOpen = [];
var mywin2 = null;
var zNode = document.createElement ('div');
zNode.innerHTML = '<button id="checkButton" type="button">'
+ 'Check Accomplishments</button>'
;
zNode.setAttribute ('id', 'checkButton');
mytable.parentNode.insertBefore(zNode, mytable);
function checkAccomplishments (zEvent) {
for(i=0;i < links.length;i++) {
if (links[i].href.indexOf('family') > -1) {
linksToOpen.push (links[i].href);
links[i].innerHTML="*";
}
}
alert(linksToOpen)
openLinksInSequence ();
};
function openLinksInSequence () {
if (mywin2) {
mywin2.close ();
mywin2 = null;
}
if (linksToOpen.length) {
var link = linksToOpen.shift ();
mywin2 = window.open (link, "my_win2");
mywin2.addEventListener ('load', openLinksInSequence, false);
}
}
checkButton.addEventListener ("click", checkAccomplishments, true);
那么,为什么我的按钮不起作用?