Greasy Fork

Greasy Fork is available in English.

loc添加超链接

添加超链接的同时,能够清除斯巴达、搬瓦工、vir、hetzner、dmit、绿云的aff

目前为 2022-04-06 提交的版本。查看 最新版本

// ==UserScript==
// @name         loc添加超链接
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  添加超链接的同时,能够清除斯巴达、搬瓦工、vir、hetzner、dmit、绿云的aff
// @author       Faxlok
// @match        https://hostloc.com/thread-*.html
// @match        https://hostloc.com/forum.php?mod=viewthread&tid=*&highlight=*
// @icon         https://www.google.com/s2/favicons?domain=hostloc.com
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    var t_f_content = document.querySelectorAll(".t_f");
    for (var i = 0; i < t_f_content.length; i++)
    {
        //console.log(t_f_content[i].innerHTML);
        //console.log(/(?<!"|>|quote)(http.*)(?!<\/a>)/g.test(t_f_content[i].innerHTML));

        // 转换为超链接
        /(?<!"|>)(http.*)(?!<\/a>)/g.test(t_f_content[i].innerHTML) ? t_f_content[i].innerHTML = t_f_content[i].innerHTML.replace(/(?<!font size="2"><a href=")(https?:\/\/.*?)</gm,'<a href="$1" target="_blank">$1</a><'):'';
        // 去掉aff
        t_f_content[i].innerHTML = t_f_content[i].innerHTML.replace(/aff\.php/gm,'cart.php').replace(/aff=\d+/gm,'a=add').replace(/ref=\w+/gm,'');
    }
})();