您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
移除跳转外链提示
当前为
- // ==UserScript==
- // @name Wanta
- // @namespace http://tampermonkey.net/
- // @version 0.1.1
- // @description 移除跳转外链提示
- // @author PRO
- // @match *://www.jianshu.com/p/*
- // @match *://juejin.cn/post/*
- // @match *://gitee.com/*
- // @icon https://greasyfork.org/rails/active_storage/blobs/redirect/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBMWhLQVE9PSIsImV4cCI6bnVsbCwicHVyIjoiYmxvYl9pZCJ9fQ==--2831c7f8ea43fc8b8e3eed3818b98e88bb689285/%E5%B1%8F%E5%B9%95%E6%88%AA%E5%9B%BE%202022-07-16%20105357.png?locale=zh-CN
- // @grant none
- // @license unlicense
- // ==/UserScript==
- (function() {
- 'use strict';
- let debug = false;
- // domain: [link_prefix query_parameter main_article_path dynamic_query urldecode]
- let fuck = {
- 'www.jianshu.com': ['https://links.jianshu.com/go', 'to', 'article', '', true],
- 'juejin.cn': ['https://link.juejin.cn', 'target', '#juejin > div.view-container > main > div > div.main-area.article-area > article', ' > .article-content', true],
- 'gitee.com': ['https://gitee.com/link', 'target', '#git-readme > div > div.file_content.markdown-body', '', true]
- };
- let domain = document.domain;
- let suffix = fuck[domain][0];
- let query_name = fuck[domain][1];
- let main_path = fuck[domain][2];
- let dynamic = fuck[domain][3];
- let urldecode = fuck[domain][4];
- let name = 'Wanta';
- function getQueryValue(url, query_string) {
- let index = url.indexOf('?');
- if (index == -1) return null;
- let search = url.slice(index + 1);
- let queries = search.split('&');
- for (let i = 0; i < queries.length; i++) {
- let query = queries[i].split('=');
- if (query[0] === query_string) return query[1];
- }
- return null;
- }
- // function removeSuffix(string, suffix) {
- // if (string.startsWith(suffix)) return string.slice(suffix.length);
- // else return string;
- // }
- function purify(link) {
- let new_href = getQueryValue(link.href, query_name);
- if (urldecode) new_href = decodeURIComponent(new_href);
- if (new_href) {
- link.href = new_href;
- if (debug) console.log(`[${name} DEBUG] ${link.href} -> ${new_href}`);
- return true;
- }
- else {
- console.log(`[${name}] Failed to purify below link element:`);
- console.log(link);
- return false;
- }
- }
- function main() {
- let links = document.querySelector(main_path + dynamic).getElementsByTagName('a');
- if (debug) console.log(links);
- let purified = 0;
- for (let i = 0;i < links.length; i++) {
- if (links[i].href.startsWith(suffix)) {
- if (purify(links[i])) purified++;
- } else if (debug) console.log(`[${name} DEBUG] Skipped "${links[i].href}".`);
- }
- console.log(`[${name}] Purified ${purified} links out of ${links.length} links.`);
- }
- if (dynamic) {
- const node = document.querySelector(main_path);
- const config = { attributes: false, childList: true, subtree: true };
- const callback = function(mutations, observer) {
- let article = node.querySelector(dynamic.slice(3));
- if (article) {
- main();
- observer.disconnect();
- }
- }
- const observer = new MutationObserver(callback);
- observer.observe(node, config);
- }
- else main();
- })();