Created
June 7, 2017 07:06
-
-
Save lgh06/c2ec281be66b74ba2247d4921a2befc9 to your computer and use it in GitHub Desktop.
auto refresh with Tampermonkey
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name css-refresh | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description try to take over the world! | |
// @author You | |
// @require http://cdn.bootcss.com/crypto-js/3.1.2/rollups/sha1.js | |
// @match http://m.kankan.com/v/* | |
// @match http://127.0.0.1:8083/* | |
// @match http://192.168.28.52:8083/* | |
// @run-at document-idle | |
// @grant GM_xmlhttpRequest | |
// ==/UserScript== | |
/* eslint-disable */ | |
(function (){ | |
'use strict'; | |
setInterval(()=>{ | |
GM_xmlhttpRequest({ | |
method: "GET", | |
url: 'http://192.168.28.52:8083/css/index.css' + "?" + Math.random(), | |
onload: function (response){ | |
var last = localStorage.getItem('lastscript'); | |
var str = response.responseText; | |
var sha = CryptoJS.SHA1(str).toString(); | |
//console.log(sha); | |
localStorage.setItem('lastscript', sha + ''); | |
if( last != sha ) | |
window.location.reload(); | |
} | |
}); | |
}, 500); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment