Created
August 20, 2012 09:20
-
-
Save arkadius/3402602 to your computer and use it in GitHub Desktop.
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 Dev_Mode | |
// @namespace http://ingensol.pl/ | |
// @version 0.1 | |
// @description enter something useful | |
// @match http://localhost:8080/* | |
// @copyright 2012+, ark_adius | |
// @require http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js | |
// ==/UserScript== | |
(function() { | |
var $ = jQuery; | |
var from = ':8080'; | |
var to = ''; | |
var blacklist = [ | |
/.*\/resources\/.*/ | |
]; | |
function isBlacklisted(src) { | |
for (var i=0; i<blacklist.length; i++) { | |
var el = blacklist[i]; | |
if (src.match(el)) { | |
return true; | |
} | |
} | |
return false; | |
}; | |
$('script').each(function() { | |
if (this.src == '' || isBlacklisted(this.src)) | |
return; | |
var src = this.src.replace(from, to); | |
var script = document.createElement("script"); | |
script.type = "text/javascript"; | |
script.src = src; | |
document.head.appendChild(script); | |
console.log('inject js: ' + this.src); | |
}); | |
$('link').each(function() { | |
if (isBlacklisted(this.href)) | |
return; | |
var src = this.href.replace(from, to); | |
this.href = src; | |
console.log('inject css: ' + this.href); | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment