admin管理员组文章数量:1026192
I'm trying to make a Tampermonkey script to unhide one DIV defined like that
<div id="div2" style="display: none;">
My script doesn't work and I don't know why...
// ==UserScript==
// @name Actualisation Vérification Infra
// @namespace /
// @version 0.1
// @description Permet de recharger la page toutes les x millisecondes afin de garder la session active
// @match .do*
// @copyright 2013+, The PCU Team
// ==/UserScript==
var extern = document.getElementById('div2').style.display;
alert('extern');
// Refresh toutes les xx minutes
var delay = "30m"; // Remplacer par le temps souhaité, 1s, 10s, 60s, 1m, 15m, 30m, 1h, 3h, ...
var t = parseInt(delay.match(/\d+/)[0], 10),
unit = "",
d = 0;
switch(delay.match(/[ms]/i)[0]) {
case "s":
unit = "secondes";
d = t * 1000;
break;
case "m":
unit = "minutes";
d = t * 60000;
break;
case "h":
unit = "heures";
d = t * 3600000;
break;
}
setInterval("window.location.reload()", d);
alert("Vous n'aviez pas activé la page depuis " + t + " " + unit);
when i want show the var "extern", the pop-up give my "extern" and not the value of the DIV...
Please could you help me ?
Ps : The second part of my code work properly, it's a refresh of the web page
I'm trying to make a Tampermonkey script to unhide one DIV defined like that
<div id="div2" style="display: none;">
My script doesn't work and I don't know why...
// ==UserScript==
// @name Actualisation Vérification Infra
// @namespace http://use.i.E.your.homepage/
// @version 0.1
// @description Permet de recharger la page toutes les x millisecondes afin de garder la session active
// @match https://reportingogd.truc.fr/reporting/afficherSynthese.do*
// @copyright 2013+, The PCU Team
// ==/UserScript==
var extern = document.getElementById('div2').style.display;
alert('extern');
// Refresh toutes les xx minutes
var delay = "30m"; // Remplacer par le temps souhaité, 1s, 10s, 60s, 1m, 15m, 30m, 1h, 3h, ...
var t = parseInt(delay.match(/\d+/)[0], 10),
unit = "",
d = 0;
switch(delay.match(/[ms]/i)[0]) {
case "s":
unit = "secondes";
d = t * 1000;
break;
case "m":
unit = "minutes";
d = t * 60000;
break;
case "h":
unit = "heures";
d = t * 3600000;
break;
}
setInterval("window.location.reload()", d);
alert("Vous n'aviez pas activé la page depuis " + t + " " + unit);
when i want show the var "extern", the pop-up give my "extern" and not the value of the DIV...
Please could you help me ?
Ps : The second part of my code work properly, it's a refresh of the web page
Share Improve this question edited Jul 19, 2013 at 11:30 Brock Adams 93.7k23 gold badges241 silver badges305 bronze badges asked Jul 19, 2013 at 11:09 user2599181user2599181 91 silver badge2 bronze badges 1-
1
Take out the quotes around
extern
in the alert.alert(extern)
else it alerts a string – dievardump Commented Jul 19, 2013 at 11:19
1 Answer
Reset to default 4Your alert alerts 'extern' because you alert it as a string.
alert(extern)
will alert the good value.
And to make the div visible, just:
document.getElementById('div2').style.display = 'block';
I'm trying to make a Tampermonkey script to unhide one DIV defined like that
<div id="div2" style="display: none;">
My script doesn't work and I don't know why...
// ==UserScript==
// @name Actualisation Vérification Infra
// @namespace /
// @version 0.1
// @description Permet de recharger la page toutes les x millisecondes afin de garder la session active
// @match .do*
// @copyright 2013+, The PCU Team
// ==/UserScript==
var extern = document.getElementById('div2').style.display;
alert('extern');
// Refresh toutes les xx minutes
var delay = "30m"; // Remplacer par le temps souhaité, 1s, 10s, 60s, 1m, 15m, 30m, 1h, 3h, ...
var t = parseInt(delay.match(/\d+/)[0], 10),
unit = "",
d = 0;
switch(delay.match(/[ms]/i)[0]) {
case "s":
unit = "secondes";
d = t * 1000;
break;
case "m":
unit = "minutes";
d = t * 60000;
break;
case "h":
unit = "heures";
d = t * 3600000;
break;
}
setInterval("window.location.reload()", d);
alert("Vous n'aviez pas activé la page depuis " + t + " " + unit);
when i want show the var "extern", the pop-up give my "extern" and not the value of the DIV...
Please could you help me ?
Ps : The second part of my code work properly, it's a refresh of the web page
I'm trying to make a Tampermonkey script to unhide one DIV defined like that
<div id="div2" style="display: none;">
My script doesn't work and I don't know why...
// ==UserScript==
// @name Actualisation Vérification Infra
// @namespace http://use.i.E.your.homepage/
// @version 0.1
// @description Permet de recharger la page toutes les x millisecondes afin de garder la session active
// @match https://reportingogd.truc.fr/reporting/afficherSynthese.do*
// @copyright 2013+, The PCU Team
// ==/UserScript==
var extern = document.getElementById('div2').style.display;
alert('extern');
// Refresh toutes les xx minutes
var delay = "30m"; // Remplacer par le temps souhaité, 1s, 10s, 60s, 1m, 15m, 30m, 1h, 3h, ...
var t = parseInt(delay.match(/\d+/)[0], 10),
unit = "",
d = 0;
switch(delay.match(/[ms]/i)[0]) {
case "s":
unit = "secondes";
d = t * 1000;
break;
case "m":
unit = "minutes";
d = t * 60000;
break;
case "h":
unit = "heures";
d = t * 3600000;
break;
}
setInterval("window.location.reload()", d);
alert("Vous n'aviez pas activé la page depuis " + t + " " + unit);
when i want show the var "extern", the pop-up give my "extern" and not the value of the DIV...
Please could you help me ?
Ps : The second part of my code work properly, it's a refresh of the web page
Share Improve this question edited Jul 19, 2013 at 11:30 Brock Adams 93.7k23 gold badges241 silver badges305 bronze badges asked Jul 19, 2013 at 11:09 user2599181user2599181 91 silver badge2 bronze badges 1-
1
Take out the quotes around
extern
in the alert.alert(extern)
else it alerts a string – dievardump Commented Jul 19, 2013 at 11:19
1 Answer
Reset to default 4Your alert alerts 'extern' because you alert it as a string.
alert(extern)
will alert the good value.
And to make the div visible, just:
document.getElementById('div2').style.display = 'block';
本文标签: javascriptalert() doesn39t show the value in a Tampermonkey scriptStack Overflow
版权声明:本文标题:javascript - alert() doesn't show the value in a Tampermonkey script - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745635279a2160409.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论