Created
August 10, 2014 07:57
-
-
Save F1LT3R/f3f8154090b6d3035d4a to your computer and use it in GitHub Desktop.
Using Charles Proxy to load scripts into other webpages
This file contains 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
<?xml version='1.0' encoding='UTF-8' ?> | |
<?charles serialisation-version='2.0' ?> | |
<rewriteSet-array> | |
<rewriteSet> | |
<active>true</active> | |
<name>Script Loader</name> | |
<hosts> | |
<locationPatterns> | |
<locationMatch> | |
<location> | |
<host>*.*</host> | |
</location> | |
<enabled>true</enabled> | |
</locationMatch> | |
<locationMatch> | |
<location> | |
<protocol>.*</protocol> | |
</location> | |
<enabled>true</enabled> | |
</locationMatch> | |
</locationPatterns> | |
</hosts> | |
<rules> | |
<rewriteRule> | |
<active>true</active> | |
<ruleType>7</ruleType> | |
<matchValue>(</[Hh][Ee][Aa][Dd](>|\s))</matchValue> | |
<matchHeaderRegex>false</matchHeaderRegex> | |
<matchValueRegex>true</matchValueRegex> | |
<matchRequest>false</matchRequest> | |
<matchResponse>true</matchResponse> | |
<newValue><script data-provider="script-loader-proxy" type="text/javascript" src="//localhost/charles-script-load/loader-script.js"></script></newValue> | |
<newHeaderRegex>false</newHeaderRegex> | |
<newValueRegex>false</newValueRegex> | |
<matchWholeValue>false</matchWholeValue> | |
<caseSensitive>true</caseSensitive> | |
<replaceType>1</replaceType> | |
</rewriteRule> | |
</rules> | |
</rewriteSet> | |
</rewriteSet-array> |
This file contains 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
// Served from localhost with Charles | |
(function () { | |
var scripts = [ | |
'localhost/repos/repo1/src/repo1.js', | |
'localhost/repos/repo2/src/repo2.js' | |
]; | |
scripts.forEach(function (url) { | |
var script = document.createElement('script'), | |
first = document.getElementsByTagName('script')[0]; | |
script.src = document.location.protocol + '//'+ url; | |
script.type = 'text/javascript'; | |
script.async = true; | |
first.parentNode.insertBefore(script, first); | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment