Created
August 25, 2020 14:54
-
-
Save nessthehero/df0d5a62a6016ac82c53daa73ca8e145 to your computer and use it in GitHub Desktop.
Devtools Snippets
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
// jquerify.js | |
// https://github.com/bgrins/devtools-snippets | |
// Add jQuery to any page that does not have it already. | |
(function () { | |
if ( !window.jQuery ) { | |
var s = document.createElement('script'); | |
s.setAttribute('src', '//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js'); | |
document.body.appendChild(s); | |
console.log('jquery loaded!'); | |
} | |
})(); |
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
/* | |
log-globals | |
by Sindre Sorhus | |
https://github.com/sindresorhus/log-globals | |
MIT License | |
*/ | |
(function () { | |
'use strict'; | |
function getIframe() { | |
var el = document.createElement('iframe'); | |
el.style.display = 'none'; | |
document.body.appendChild(el); | |
var win = el.contentWindow; | |
document.body.removeChild(el); | |
return win; | |
} | |
function detectGlobals() { | |
var iframe = getIframe(); | |
var ret = Object.create(null); | |
for (var prop in window) { | |
if (!(prop in iframe)) { | |
ret[prop] = window[prop]; | |
} | |
} | |
return ret; | |
} | |
console.log(detectGlobals()); | |
})(); |
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
pathname = window.location.pathname; | |
section = pathname.split('/')[1]; | |
numSlashes = pathname.split('/').length - 1; | |
console.log(numSlashes); |
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
function q () { | |
var vars = [], | |
grabUrl = window.location.search, | |
parts, | |
pieces, | |
qs = '', | |
qsVals = []; | |
if (typeof arguments[0] == 'string') { | |
qs = arguments[0]; | |
} | |
if (typeof arguments[0] == 'string') { | |
qs = arguments[0]; | |
} | |
if (typeof grabUrl != 'undefined' && grabUrl != '') { | |
grabUrl = grabUrl.replace("?", ''); | |
parts = grabUrl.split("&"); | |
for (var j in parts) { | |
pieces = parts[j].split('='); | |
if (vars.length != 0) { | |
for (var i in vars) { | |
if (vars[i].name == pieces[0].toString()) { | |
vars[i].values.push(pieces[1]); | |
} else { | |
vars.push({ "name" : pieces[0].toString(), "values" : [pieces[1]] }); | |
} | |
} | |
} else { | |
vars.push({ "name" : pieces[0].toString(), "values" : [pieces[1]] }); | |
} | |
} | |
if (qs != '') { | |
for (var i in vars) { | |
if (vars[i].name == qs) { | |
return vars[i].values; | |
} | |
} | |
return ['-1']; | |
} | |
return vars; | |
} else { | |
return []; | |
} | |
} | |
q(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment