0
所以我有这样的脚本:脚本在Firefox暂存器而不是在Greasemonkey的
links = document.getElementsByClassName('thumb');
for (var i=links.length-1; i>=0; i--)
{
links[i].href=links[i].href+'/popout';
}
该页面后暂存器的作品,我想修改,被加载。
但是,当我把它放在greasemonkey中,它在页面完全加载之前运行,并且我需要mod的元素不存在,它不起作用。
这里是GS脚本:
// ==UserScript==
// @name popout
// @namespace PylonPants
// @include http://*.twitch.tv/directory/*
// @version 1
// ==/UserScript==
//if ('loading' == document.readyState) {
// alert("This script is running at document-start time.");
//} else {
// alert("This script is running with document.readyState: " + document.readyState);
//}
// script runs at readyState = interactive and that brakes it
// do not know how to make it wait till complete
links = document.getElementsByClassName('thumb');
alert(links[0]); // i get "undefined"
for (var i=links.length-1; i>=0; i--)
{
alert('the script works'); //i never reach here
alert(links[i].href); // nor here
links[i].href=links[i].href+'/popout';
}
alert('crazy'); // i get this then the page loads fully.
谢谢回答 – user2209850 2013-03-26 07:33:04