Прямые ссылки на сайтах с движком DataLife Engine (DLE)
当前为
// ==UserScript==
// @name DLE links decoder
// @namespace lainscripts_dle_links_decoder
// @version 0.8
// @description Прямые ссылки на сайтах с движком DataLife Engine (DLE)
// @author lainverse
// @match *://*/*
// @grant none
// ==/UserScript==
// Script based on a similar script by raletag:
// https://greasyfork.org/en/scripts/22290-Прямые-ссылки-в-dle
(function() {
'use strict';
var impCodes = '%3B%2C%2F%3F%3A%40%26%3D%2B%24%23',
impRegex = new RegExp((impCodes.replace(/%/g,'|%').replace('|','')), 'gi'),
impDecoded = decodeURIComponent(impCodes),
impReplacer = function(ch) {
return impDecoded[impCodes.indexOf(ch.toUpperCase())/3];
};
function decodeImportant(text) {
return text.replace(impRegex, impReplacer);
}
function clickHandler(e){
var link = e.target, url = link.href, url64;
if (!url) {
while (!url && link !== this) {
link = link.parentNode;
url = link.href;
}
if (!url) {
return true;
}
}
url64 = (url.match(/([?&]url=|\/leech_out\.php\?.:)([^&]+)(&|$)/i)||[])[2];
if (!url64) {
return true;
}
try {
url64 = decodeURIComponent(url64);
url = window.atob(url64);
} catch(ignore) {
url = url64;
}
url = decodeImportant(url);
console.log('Replaced ' + link.href + ' with ' + url);
link.href = url;
link.target = '_blank';
return true;
}
document.addEventListener('click', clickHandler, false);
document.addEventListener('contextmenu', clickHandler, false);
})();