Created
January 13, 2017 16:28
-
-
Save daniellizik-sc/b8555683fd87eaee70da8e07ef0c9f42 to your computer and use it in GitHub Desktop.
find script tag sources
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
((name) => { | |
const scripts = [...document.querySelectorAll('script')]; | |
const matches = scripts.filter(s => s.src.indexOf(name) > -1); | |
const sources = matches.map(s => s.src); | |
if (matches.length < 1) | |
return alert(`no scripts found with name "${name}"`); | |
else if (matches.length > 1) | |
return alert(`multiple scripts found including this name ${JSON.stringify(sources, null, 2)}`); | |
else if (matches.length === 1) | |
return alert(`script is deployed as ${sources[0]}`); | |
})(prompt('search script name')); |
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
!function(a){function b(a){if(Array.isArray(a)){for(var b=0,c=Array(a.length);b<a.length;b++)c[b]=a[b];return c}return Array.from(a)}var c=[].concat(b(document.querySelectorAll("script"))),d=c.filter(function(b){return b.src.indexOf(a)>-1}),e=d.map(function(a){return a.src});return d.length<1?alert('no scripts found with name "'+a+'"'):d.length>1?alert("multiple scripts found including this name "+JSON.stringify(e,null,2)):1===d.length?alert("script is deployed as "+e[0]):void 0}(prompt("search script name")); |
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
javascript:!function(a){function b(a){if(Array.isArray(a)){for(var b=0,c=Array(a.length);b<a.length;b++)c[b]=a[b];return c}return Array.from(a)}var c=[].concat(b(document.querySelectorAll("script"))),d=c.filter(function(b){return b.src.indexOf(a)>-1}),e=d.map(function(a){return a.src});return d.length<1?alert('no scripts found with name "'+a+'"'):d.length>1?alert("multiple scripts found including this name "+JSON.stringify(e,null,2)):1===d.length?alert("script is deployed as "+e[0]):void 0}(prompt("search script name")); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment