Bookmarklet: Elegant CSS Force Reload

Bookmarklet: Elegant CSS Force Reload

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
javascript:void(function(){

var i, a, s;
a = document.getElementsByTagName('link');

for (i = 0; i < a.length; i++) {
    s = a[i];
    if (s.rel.toLowerCase().indexOf('stylesheet') >= 0 && s.href) {
        var h = s.href.replace(/(&|%5C?)forceReload=\d+/, '');
        s.href = h + (h.indexOf('?') >= 0 ? '&' : '?') + 'forceReload=' + (new Date().valueOf())
    }
}

})();

The above works perfectly, but I created Tampermonkey script that doesn’t have a “flash” when changing CSS and has a shortcut of Ctrl-E.

date 01. Jan 0001 | modified 13. May 2024
filename: Tip » Bookmarklet » Reload CSS