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';