Last active
April 4, 2019 08:25
-
-
Save mgng/5410160 to your computer and use it in GitHub Desktop.
meta refresh blocker クローム用拡張
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
{ | |
"manifest_version": 2, | |
"name" : "meta refresh blocker", | |
"version" : "0.1", | |
"description" : "meta refresh タグを無効にする拡張です。", | |
"content_scripts" : [{ | |
"matches" : ["*://*/*"], | |
"run_at" : "document_idle", | |
"all_frames" : true, | |
"js" : [ "metarefreshblocker.js" ] | |
}] | |
} |
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
/** metarefreshblocker.js */ | |
(function(){ | |
var nodes = document.querySelectorAll( 'meta[HTTP-EQUIV="refresh"]' ); | |
if ( nodes.length > 0 ) { | |
var blocked = document.createElement('div'); | |
blocked.setAttribute('style', 'display:block;background-color:#FDA;color:#000;border:1px solid #333;padding:.5em;'); | |
for( var i=0,l=nodes.length; i<l; i++ ) { | |
var a = document.createElement('a'); | |
var elm = document.createElement('div'); | |
var url = nodes[i]['content'].replace(/.*url=/i, ''); | |
a.setAttribute( 'href', url ); | |
//a.setAttribute( 'target', 'blank' ); | |
a.appendChild( document.createTextNode( 'jump to ' + url ) ) | |
elm.appendChild( a ); | |
blocked.appendChild( elm ); | |
} | |
document.documentElement.insertBefore( blocked, document.documentElement.firstChild ); | |
document.write( document.documentElement.outerHTML ); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment