Skip to content

Instantly share code, notes, and snippets.

@lgh06
Created June 7, 2017 07:06
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save lgh06/c2ec281be66b74ba2247d4921a2befc9 to your computer and use it in GitHub Desktop.
Save lgh06/c2ec281be66b74ba2247d4921a2befc9 to your computer and use it in GitHub Desktop.
auto refresh with Tampermonkey
// ==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