幫助,任何人都可以幫助我如何使用greasemonkey更改JavaScript變量?修改JavaScript變量使用Greasemonkey
我已經關注這個問題的答案: How can I change a JavaScript variable using Greasemonkey?
而且此鏈接: http://webdeveloper.com/forum/showthread.php?t=166658
,但我不能與此腳本修改的功能計數器變量值:
// ==UserScript==
// @name My Fancy New Userscript
// @namespace http://use.i.E.your.homepage/
// @version 0.1
// @description enter something useful
// @match https://welcome.telkomhotspot.info/telkomhs/freemax/
// @copyright 2012+, You
// ==/UserScript==
unsafeWindow.counter = 1;
這裏是我想改變功能:
function startTimer(){
var counter = 20;
var wait = 0;
var displayCounter = true;
var startCounting = false;
$("#timerTransition").html(getLoadingCounter())
.everyTime(1000,function(i){
if(wait==0){
if(displayCounter){
$("#loadingCounter").fadeOut(500,function(){
$("#timerTransition").html(getTimerContainer(counter));
$("#timerContainer").fadeIn(500,function(){
startCounting = true;
});
});
}
displayCounter = false;
if(startCounting){
counter = counter - 1;
$("#counter").html(counter);
if(counter == 0) {
if(foundCookies){
$("#timerTransition").stopTime().html(getAuthCookiesLogin());
}
else{
$("#timerTransition").stopTime().html(getAuthButton());
$("#authBtnContainer").fadeIn(0).click(function(){
$(this).fadeOut(0);
closeAds();
openAuthForm();
});
}
}
}
}
else{
wait = wait-1;
}
});
}
感謝您的幫助,我已經在谷歌搜索,但仍然無法修改變量。
如果您定義'unsafeWindow.counter',您還應該閱讀'unsafeWindow.counter',以便在每個地方都用'unsafeWindow.counter'替換'counter'。 – noob 2012-04-16 14:30:03
你是不是要用'unsafeWindow.counter'替換所有'counter'?但是我沒有訪問該文件的權限。我想使用Greasemonkey在'counter = 20;''counter = 1;'在某個網站上修改計數器變量**值**,所以我可以更快地跳過**計時器**。你能告訴我如何? – yudayyy 2012-04-16 15:13:39