Skip to content

Instantly share code, notes, and snippets.

@Idered
Last active December 14, 2015 14:49
Show Gist options
  • Save Idered/5103603 to your computer and use it in GitHub Desktop.
Save Idered/5103603 to your computer and use it in GitHub Desktop.
Debug bookmarklets
javascript:
var CSSRefresh = {
styleSheets: [],
init: function() {
var links = document.getElementsByTagName("link"),
lastModified;
for(var i = 0; i < links.length; i++) {
if(links[i].rel === "stylesheet" && links[i].href.indexOf(window.location.host) !== -1) {
lastModified = CSSRefresh.getFiletime(links[i].href) || 0;
links[i].lastModified = lastModified;
CSSRefresh.styleSheets.push(links[i]);
}
}
var timer = setInterval(CSSRefresh.refresh, 150);
},
getFiletime: function(file) {
var req = new XMLHttpRequest();
req.open('GET', file, false);
req.send(null);
return req.getResponseHeader('Last-Modified');
},
refresh: function() {
var lastModified,
ss;
for (var i = CSSRefresh.styleSheets.length - 1; i >= 0; i--) {
ss = CSSRefresh.styleSheets[i];
lastModified = CSSRefresh.getFiletime(ss.href);
if (lastModified != ss.lastModified) {
ss.lastModified = lastModified;
ss.href = ss.href.replace(/\.css.*/, '.css?reload=' + new Date().getTime());
}
};
}
};
CSSRefresh.init();
javascript:var CSSRefresh={styleSheets:[],init:function(){var links=document.getElementsByTagName("link"),lastModified;for(var i=0;i<links.length;i++){if(links[i].rel==="stylesheet"&&links[i].href.indexOf(window.location.host)!==-1){lastModified=CSSRefresh.getFiletime(links[i].href)||0;links[i].lastModified=lastModified;CSSRefresh.styleSheets.push(links[i]);}}var timer=setInterval(CSSRefresh.refresh,150);},getFiletime:function(file){var req=new XMLHttpRequest();req.open('GET',file,false);req.send(null);return req.getResponseHeader('Last-Modified');},refresh:function(){var lastModified,ss;for(var i=CSSRefresh.styleSheets.length-1;i>=0;i--){ss=CSSRefresh.styleSheets[i];lastModified=CSSRefresh.getFiletime(ss.href);if(lastModified!=ss.lastModified){ss.lastModified=lastModified;ss.href=ss.href.replace(/\.css.*/,'.css?reload='+new Date().getTime());}};}};CSSRefresh.init();
javascript:
var debug = document.createElement('div');
debug.id = '#debug-window';
debug.style.font = '16px/1.5 Arial';
debug.style.color = '#fff';
debug.style.textAlign = 'right';
debug.style.background = '#333';
debug.style.padding = '.5em 1em';
debug.style.position = 'fixed';
debug.style.bottom = 0;
debug.style.right = 0;
debug.style.borderRadius = '3px 0 0 0';
document.getElementsByTagName('body')[0].appendChild(debug);
window.onresize = function()
{
debug.innerHTML = window.innerWidth + 'x' + window.innerHeight + 'px';
};
window.onresize();
javascript:var debug=document.createElement('div');debug.id='#debug-window';debug.style.font='16px/1.5 Arial';debug.style.color='#fff';debug.style.textAlign='right';debug.style.background='#333';debug.style.padding='.5em 1em';debug.style.position='fixed';debug.style.bottom=0;debug.style.right=0;debug.style.borderRadius='3px 0 0 0';document.getElementsByTagName('body')[0].appendChild(debug);window.onresize=function(){debug.innerHTML=window.innerWidth+'x'+window.innerHeight+'px';};window.onresize();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment