SHARE
TWEET

Untitled

a guest Jul 21st, 2019 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. let html = "<div><h1>hey</h1><script>alert(1)<\/script><\/div>";
  2.        
  3.         function scriptify(id, dat){
  4.             let data = new DOMParser().parseFromString(html, 'text/html').body;
  5.             let scripts = data.getElementsByTagName("script");
  6.             let copy = [];
  7.             for(let i = 0; i < scripts.length; i ++){
  8.                 copy.push(scripts[i].innerHTML);
  9.                 scripts[i].remove();
  10.             }
  11.             let doc = document.getElementById(id);
  12.             doc.innerHTML = data.innerHTML;
  13.  
  14.             for(let i = 0; i < copy.length; i ++){             
  15.                 let s = document.createElement('script');
  16.                 s.textContent = copy[i];
  17.                 doc.appendChild(s);
  18.                
  19.             }
  20.         }
  21.        
  22.         scriptify("data", html);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top