3
2

More than 5 years have passed since last update.

自動リロードするGreasemonkey

Posted at

自動でリロードしてほしいページがあったため、Greasemonkeyで対応した際のメモです。

// ==UserScript==
// @name        autoreload
// @namespace   haruyosh.name.space
// @include     http://example.com/static.html
// @version     1
// @grant       none
// ==/UserScript==

(function myloop(i) {
  setTimeout(function() {
    myfunc();
    if (--i) myloop(i);
  },180000)
})(1);

function myfunc() {
  window.location.reload(true);
}

var myp = document.createElement("p");
myp.textContent = "Last update: " + (new Date()).toString();
$("#top").append(myp);

参考文献

How to reload a page using Javascript?
How do I add a delay in a JavaScript loop?

3
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2