[英]Modify Javascript Variable Using Greasemonkey
Help, can anyone help me how to change javascript variable using greasemonkey? 帮助,任何人都可以帮助我如何使用滑脂糖改变javascript变量吗?
I already following the answers on this question: How can I change a JavaScript variable using Greasemonkey? 我已经在回答以下问题: 如何使用Greasemonkey更改JavaScript变量?
and also this link: http://webdeveloper.com/forum/showthread.php?t=166658 以及此链接: http : //webdeveloper.com/forum/showthread.php?t=166658
but I unable to modify the counter variable value on the function with this script: 但是我无法使用此脚本修改函数上的计数器变量值 :
// ==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;
Here are the function that I want to change: 这是我要更改的功能:
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;
}
});
}
Thanks for helping, I already searching on google but still I can't modify the variable. 感谢您的帮助,我已经在Google上进行搜索,但仍然无法修改变量。
counter
is a local variable within a function. counter
是函数中的局部变量。 You will not be able to change its value unless you can modify the function to use a global variable. 除非您可以修改函数以使用全局变量,否则将无法更改其值。 If you do not have access to the code, you could try replacing the entire startTimer
function with your own implementation. 如果您无权访问该代码,则可以尝试使用自己的实现替换整个startTimer
函数。 I can not tell from your example, but you can only replace startTimer if it is a global. 我无法从您的示例中看出来,但是如果它是全局的,则只能替换startTimer。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.