14

【代码】稀土掘金去除外链跳转提示

 1 year ago
source link: https://loli.fj.cn/2023/08/21/%E7%A8%80%E5%9C%9F%E6%8E%98%E9%87%91%E5%8E%BB%E9%99%A4%E5%A4%96%E9%93%BE%E8%B7%B3%E8%BD%AC%E6%8F%90%E7%A4%BA/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

【代码】稀土掘金去除外链跳转提示

2023-08-21 2023-08-22

稀土掘金去除外链跳转提示

// ==UserScript==
// @name 稀土掘金去除外链跳转提示
// @namespace http://tampermonkey.net/
// @version 1.0
// @description 稀土掘金去除外链跳转提示
// @author FeiJu
// @match *://*juejin.cn/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=tampermonkey.net
// @grant none
// ==/UserScript==

(function() {
'use strict';
let count = 0;
// 修改这里的阈值指定最大的扫描次数
let max_count = 100;
while (true) {
const content = document.body.innerHTML;
const index = content.indexOf("https:\/\/link.juejin.cn\?target=");
if (index === -1) {
console.log(`${count}. 没找见外链`);
break;
} else {
console.log(`${count}. 找见外链了`);
const front = content.substr(0, index);
const middle_and_behind = content.substr(index+30);
const index_end = middle_and_behind.indexOf("\"");
let middle = middle_and_behind.substr(0, index_end);
const behind = middle_and_behind.substr(index_end);
console.log("获取链接完成");
console.log(middle);
middle = unescape(middle);
console.log("URL解码完成");
console.log(middle);
document.body.innerHTML = front + middle + behind;
console.log("重新组合body完成");
count += 1;
if (count > max_count) {
console.log(`执行了 ${count} 脚本,达到阈值,已停止脚本防止死循环`);
break;
}
}
}
})();

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK