您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Switches all imgur links to 0imgur
当前为
// ==UserScript== // @name Imgur Mirror (Modified) // @version 2.2.2 // @description Switches all imgur links to 0imgur // @author Ad3m // @include *://*/* // @exclude *://imgur.com/* // @exclude *://*.imgur.com/* // @grant GM_Config // @grant GM_getValue // @grant GM_setValue // @grant GM_addStyle // @grant GM_registerMenuCommand // @namespace https://gf.qytechs.cn/users/159159 // @require http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js // @require https://gf.qytechs.cn/scripts/37236-monkeyconfig/code/MonkeyConfig.js // ==/UserScript== var cfg = new MonkeyConfig({ title: 'Imgur Mirror Configuration', menuCommand: true, params: { reddit_redirect: { type: 'checkbox', default: false }, imgur_redirect: { type: 'checkbox', default: true }, reddit_link_hijack_remover: { type: 'checkbox', default: true }, open_links_in_new_tab: { type: 'checkbox', default: true } } }); var red_cfg = cfg.get('reddit_redirect'); var img_cfg = cfg.get('imgur_redirect'); var red_link_cfg = cfg.get('reddit_link_hijack_remover'); var new_tab_cfg = cfg.get('open_links_in_new_tab'); changeLinks(); document.addEventListener('scroll', changeLinks); document.addEventListener('click', changeLinks); function changeLinks() { if (img_cfg != false) { if (window.location.hostname == "i.0imgur.com") { $('style').remove(); $('.icerik').remove(); $('.yatay').remove(); $('.dikey').remove(); jQuery('body') .prepend("<style> .img { cursor:zoom-in; position: fixed; top: 0; bottom: 0; left: 0; right: 0; max-width: 100%; max-height: 100%; margin: auto; overflow: auto; } .img-exp { cursor:zoom-out; max-width: none; }</style>"); $(".img").click(function () { $(this).removeClass("img"); $(this).addClass("img-exp"); }); $(".img-exp").click(function () { $(this).removeClass("img-exp"); $(this).addClass("img"); }); } var imgur_old_href = "imgur.com"; var imgur_new_href = "0imgur.com"; var nodeList = document.querySelectorAll('[href*="imgur.com"]'); for (var i = 0; i < nodeList.length; i++) { if (nodeList[i].href.indexOf(imgur_new_href)==-1) { nodeList[i].href = nodeList[i].href.replace(imgur_old_href,imgur_new_href); if (new_tab_cfg != false) { nodeList[i].setAttribute('target', '_blank'); } } } var imgur_old_src = "imgur.com"; var imgur_new_src = "0imgur.com"; var nodeList_src = document.querySelectorAll('[src*="imgur.com"]'); for (var i = 0; i < nodeList_src.length; i++) { if (nodeList_src[i].src.indexOf(imgur_new_src)==-1) nodeList_src[i].src = nodeList_src[i].src.replace(imgur_old_src,imgur_new_src); } } if (red_cfg != false) { var list = document.querySelectorAll('[href*="redd.it"]'); for (var i = 0; i < list.length; i++) { var node = list.item(i); var proxy_node = "https://proxy.duckduckgo.com/iu/?u=" if (node.href.indexOf(proxy_node)==-1) { node.setAttribute('href', node.getAttribute('href') .replace(node.getAttribute('href'), proxy_node + node.getAttribute('href') + '&f=1')); if (new_tab_cfg != false) { node.setAttribute('target', '_blank'); } } } list = document.querySelectorAll('[src*="redd.it"]'); for (i = 0; i < list.length; i++) { var node = list.item(i); var proxy_node = "https://proxy.duckduckgo.com/iu/?u=" if (node.src.indexOf(proxy_node)==-1) { node.setAttribute('src', node.getAttribute('src') .replace(node.getAttribute('src'), proxy_node + node.getAttribute('src'))); } } } } if (red_link_cfg != false) { // Reddit Link Hijack Remover by jmesmon https://gf.qytechs.cn/tr/scripts/20752-reddit-link-hijack-remover (function () { 'use strict'; if (window.location.host == "www.reddit.com") { function cl(ac) { var a = ac.querySelectorAll('a[data-href-url]'); var ct_out = 0, ct_aff = 0, ct = 0, ct_in; for (var i = 0; i < a.length; i++) { /* // This is reddit's function to determine the url, which is stored in `o`. // It then hooks window unload to call sendBeacon with the url in `o` or // modifies the href attribute (if sendBeacon is disabled in config or unsupported by the browser). function o(e) { var t = $(e), r = Date.now(), o; return t.attr('data-inbound-url') ? o = t.attr('data-inbound-url') : !n && t.attr('data-outbound-expiration') > r && (o = t.attr('data-outbound-url')), o && (i ? s = o : e.href = o), !0 } */ // Some minimal counting so we can tell things are working if (a[i].getAttribute('data-inbound-url')) { ct_in++; } if (a[i].getAttribute('data-affiliate-url')) { ct_aff++; } if (a[i].getAttribute('data-outbound-url') || a[i].getAttribute('data-outbound-expiration')) { ct_out++; } // Goals: // - make sure `o` stays undefined. // - avoid ever getting this function called // Removing all the relevent attributes gets us both of those // Unclear what the purpose of these is, but they are being used to // re-write urls (and trigger entry to the fn above), so remove. a[i].removeAttribute('data-inbound-url'); // Doesn't appear that reddit is injecting these affiliate links // anymore, but no reason to remove this a[i].removeAttribute('data-affiliate-url'); // We don't actually need to remove this, but it does short circuit // the condition quicker & cleans up the html, so do it. a[i].removeAttribute('data-outbound-expiration'); a[i].removeAttribute('data-outbound-url'); ct++; } console.log('>>>'); console.log('Outbound redirects removed: ' + ct_out); console.log('Inbound 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 }); // TODO: consider patching out window.navigator.sendBeacon (which reddit only uses for this link tracking) // TODO: consider blocking the recent_srs cookie used for tracking cl(document); } }) (); } // Reddit Link Hijack Remover by jmesmon https://gf.qytechs.cn/tr/scripts/20752-reddit-link-hijack-remover
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址