Advertisement
Guest User

feedly_utm_Remover.user.js

a guest
May 14th, 2013
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name         feedly - Remove utm from Links
  3. // @description  リンクに追加されているトラッキングコードutm_source=feedlyを削除します
  4. // @version      0.1
  5. // @include      http://www.feedly.com/*
  6. // @include      https://www.feedly.com/*
  7. // ==/UserScript==
  8.  
  9. function removeutm(){
  10.     var as = document.evaluate('descendant-or-self::a', document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  11.     for (var i = 0, l = as.snapshotLength;i < l;++i){
  12.         var a = as.snapshotItem(i);
  13.         if (a.href.indexOf('http') === 0 && a.host !== location.host && /utm_/i.test(a.href)){
  14.             var newhref = a.href.replace(/([\?\&]utm_source=feedly)/ig, '');
  15.             a.setAttribute('href', newhref);
  16.         }
  17.     }
  18. }
  19.  
  20. var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver;
  21. var observer = new MutationObserver(function(mutations) {
  22.     removeutm();
  23. });
  24. observer.observe(document, { childList: true , subtree: true});
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement