Yahoo direct non-tracking search

Strips tracking and redirection from Yahoo search urls

当前为 2017-02-14 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Yahoo direct non-tracking search
  3. // @description Strips tracking and redirection from Yahoo search urls
  4. // @include http://*yahoo.tld/*
  5. // @include https://*yahoo.tld/*
  6. // @version 1.1.2
  7. // @author wOxxOm
  8. // @namespace wOxxOm.scripts
  9. // @license MIT License
  10. // @run-at document-start
  11. // @require https://greasyfork.org/scripts/12228/code/setMutationHandler.js?version=175122
  12. // ==/UserScript==
  13.  
  14. /* jshint lastsemic:true, multistr:true, laxbreak:true, -W030, -W041, -W084 */
  15.  
  16. setMutationHandler(document, 'form, a', function(nodes) {
  17. nodes.forEach(function(node) {
  18. switch (node.localName) {
  19. case 'form':
  20. if (node.action.indexOf('/search') > 0) {
  21. node.addEventListener('submit', function(e){
  22. e.preventDefault();
  23. stopPropagation(e);
  24. e.target.action = e.target.action.replace(/_yl[tu]=[\w;_=.-]+/, '');
  25. e.target.submit();
  26. });
  27. }
  28. break;
  29. case 'a':
  30. node.href = node.href.replace(/;?_yl[tu]=[\w;_=.-]+\/?/, '')
  31. .replace(/^.+?\/RU=(http[^\/]+)\/?.*$/, function(s, url) { return decodeURIComponent(url) });
  32. node.removeAttribute('onmousedown');
  33. node.removeAttribute('data-sb');
  34. break;
  35. }
  36. });
  37. return true;
  38. });
  39.  
  40. document.addEventListener('click', stopPropagation, true);
  41. document.addEventListener('mousedown', stopPropagation, true);
  42. window.addEventListener('click', stopPropagation, true);
  43. window.addEventListener('mousedown', stopPropagation, true);
  44.  
  45. function stopPropagation(e) {
  46. if (e.target.href) {
  47. e.stopPropagation();
  48. e.stopImmediatePropagation();
  49. }
  50. }