Last active
September 11, 2018 19:35
-
-
Save N0taN3rd/16d0e6050f60256517db942d1fe29703 to your computer and use it in GitHub Desktop.
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
var url = `${location.protocol}/${wbinfo.proxy_magic}/proxy-fetch/https://www.google.com` | |
var res = await fetch(url) | |
console.log(await res.text()) |
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
var srcsetSplit = /\s*(\S*\s+[\d.]+[wx]),|(?:\s*,(?:\s+|(?=https?:)))/; | |
elemCache = window.elemCache || new WeakSet(); | |
function getSrcsets() { | |
var ssElems = document.querySelectorAll('*[srcset]'); | |
var ssElem; | |
var i = 0; | |
var j, length2; | |
var length = ssElems.length; | |
var values = []; | |
var ssValues; | |
for (; i < length; ++i) { | |
ssElem = ssElems[i]; | |
if (elemCache.has(ssElem)) { | |
continue; | |
} | |
elemCache.add(ssElem); | |
ssValues = ssElem.srcset.split(srcsetSplit); | |
j = 0; | |
length2 = ssValues.length; | |
while (j < length2) { | |
if (Boolean(ssValues[j])) { | |
values.push(ssValues[j].split(' ')[0]); | |
} | |
j += 1; | |
} | |
} | |
return values; | |
} | |
// getSrcsets() | |
function corsFetch (it) { | |
return fetch(`https://cors-anywhere.herokuapp.com/${it}`, { | |
method: 'GET', | |
headers: new Headers({'Origin': location.origin}) | |
}).then(res => res.text()) | |
} | |
function getStyleSheets () { | |
var styleSheets = document.styleSheets; | |
var i = 0; | |
var styleTag = document.createElement('style'); | |
document.body.append(styleTag); | |
var length = styleSheets.length; | |
var ruleValues = []; | |
for(; i < length; ++i) { | |
try { | |
ruleValues.push(Promise.resolve(styleSheets[i].cssRules)) | |
} catch(error) { | |
ruleValues.push(corsFetch(styleSheets[i].href).then(text => { | |
styleTag.innerText = text; | |
return styleTag.sheet.cssRules; | |
}).catch(error => null)); | |
} | |
} | |
return Promise.all(ruleValues); | |
} | |
getStyleSheets().then(vals => console.log(vals)).catch(error => console.error(error)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment