Last active
February 13, 2022 02:59
-
-
Save matiaslopezd/74d6c7fb7d42978bdfa77237a68ed24b to your computer and use it in GitHub Desktop.
Get all content of website and put inside to an Iframe. [Not compatible with X-Frame-Options: DENY]
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(elements) { | |
function removeElements(elements){ | |
elements.forEach((type) => { | |
const large = document.querySelectorAll(type).length; | |
for (let i = 0; i < large; i++) { | |
document.querySelector(type).remove(); | |
} | |
}); | |
} | |
function removeChilds(){ | |
const large = document.querySelector('body').childNodes.length | |
for (i = 0; i < large; i++) { | |
document.querySelector('body').childNodes[0].remove(); | |
} | |
} | |
function createIframe(){ | |
const style = 'width: 100%; height: 100%; overflow: hidden; margin: 0;'; | |
document.querySelector('html').setAttribute('style', style); | |
document.querySelector('body').setAttribute('style', style); | |
const iframe = document.createElement('iframe'); | |
iframe.src = window.location.href; | |
iframe.setAttribute('style', 'width: 100%; height: 100%; border: none;'); | |
document.querySelector('body').appendChild(iframe); | |
} | |
removeElements(elements); | |
removeChilds(); | |
createIframe(); | |
})(['script', 'link', 'style']); | |
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(elements){function removeElements(elements){elements.forEach((type)=>{const large=document.querySelectorAll(type).length;for(let i=0;i<large;i++){document.querySelector(type).remove()}})} | |
function removeChilds(){const large=document.querySelector('body').childNodes.length | |
for(i=0;i<large;i++){document.querySelector('body').childNodes[0].remove()}} | |
function createIframe(){const style='width: 100%; height: 100%; overflow: hidden; margin: 0;';document.querySelector('html').setAttribute('style',style);document.querySelector('body').setAttribute('style',style);const iframe=document.createElement('iframe');iframe.src=window.location.href;iframe.setAttribute('style','width: 100%; height: 100%; border: none;');document.querySelector('body').appendChild(iframe)} | |
removeElements(elements);removeChilds();createIframe()})(['script','link','style']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment