Undirect

Removes this tracking and redirection from google search results

  1. // ==UserScript==
  2. // @name Undirect
  3. // @namespace http://stevesspace.com/
  4. // @version 1.1.3
  5. // @description Removes this tracking and redirection from google search results
  6. // @include /^https?.\/\/.+google[^\/]*/
  7. // @copyright 2014+, Steve Leigh
  8. // ==/UserScript==
  9.  
  10. (function() {
  11. var googlePagesPattern = /https?.\/\/.+google[^\/]*/gi;
  12. if (!document.location.href.match(googlePagesPattern))
  13. return;
  14.  
  15. var scriptToExecute = (function() {
  16. var expectedRwt = function() { return true; };
  17.  
  18. var replaceRwtFunction = function() {
  19. if (window.rwt && window.rwt != expectedRwt) {
  20. delete window.rwt;
  21. Object.defineProperty(window, 'rwt', {
  22. value: expectedRwt,
  23. writable: false
  24. });
  25. }
  26. };
  27.  
  28. replaceRwtFunction();
  29.  
  30. var timeoutId = 0;
  31. document.body.addEventListener("DOMNodeInserted", function() {
  32. if (timeoutId) clearTimeout(timeoutId)
  33. timeoutId = setTimeout(replaceRwtFunction, 1000);
  34. }, false);
  35. });
  36.  
  37. // Write script to page - since plugins often work in an isolated world, this gives us the
  38. // ability to replace javascript added by the page
  39. var fnContents = scriptToExecute.toString();
  40. var executeFnScript = '(' + fnContents + ')();';
  41.  
  42. var script = document.createElement('script');
  43. script.textContent = executeFnScript;
  44. (document.head || document.documentElement).appendChild(script);
  45. script.parentNode.removeChild(script);
  46. })();