Remove viglink & outbound tracking redirects from reddit
当前为
// ==UserScript==
// @name Reddit Link Hijack Remover
// @author jmesmon
// @description Remove viglink & outbound tracking redirects from reddit
// @include *://reddit.com/*
// @include *://*.reddit.com/*
// @grant none
// @version 0.0.1.20160709181519
// @namespace https://greasyfork.org/users/49902
// ==/UserScript==
(function () {
'use strict';
function cl(ac) {
var a = ac.querySelectorAll('a[data-href-url]');
var ct_out = 0,
ct_aff = 0,
ct = 0;
for (var i = 0; i < a.length; i++) {
var url = a[i].getAttribute('data-href-url');
if (url) {
if (a[i].getAttribute('data-affiliate-url')) {
a[i].setAttribute('data-affiliate-url', url);
ct_aff++;
}
if (a[i].getAttribute('data-outbound-url')) {
a[i].setAttribute('data-outbound-url', url);
ct_out++;
}
ct++;
}
}
console.log('>>>');
console.log('Outbound redirects removed: ' + ct_out);
console.log('Affiliate redirects removed: ' + ct_aff);
console.log('Total redirects removed: ' + ct);
console.log('<<<');
}
var tbls = document.querySelector('#siteTable');
var obs = new MutationObserver(function (r, self) {
for (var i = 0; i < r.length; i++) {
var ad = r[i].addedNodes;
for (var j = 0; j < ad.length; j++) {
var n = ad[j];
cl(n);
}
}
});
obs.observe(tbls, {
childList: true
});
cl(document);
}) ();