Advertisement
teknoraver

keepurl

Mar 8th, 2021
829
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. function sanitizeNode(node) {
  3.     if (node.tagName != 'A')
  4.         return;
  5.  
  6.     node.removeAttribute('onmousedown');
  7. }
  8.  
  9. function walk(node) {
  10.     // thanks to: http://is.gd/mwZp7E
  11.     switch (node.nodeType) {
  12.         case  1: // Node.ELEMENT_NODE
  13.             sanitizeNode(node);
  14.         case  9: // Node.DOCUMENT_NODE
  15.         case 11: // Node.DOCUMENT_FRAGMENT_NODE
  16.             var child = node.firstChild;
  17.             while (child) {
  18.                 var next = child.nextSibling;
  19.                 walk(child);
  20.                 child = next;
  21.             }
  22.             break;
  23.     }
  24. }
  25.  
  26. walk(document.body);
  27.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement