去你大爷的闲鱼口令

它将 V2EX 帖子中的闲鱼口令/淘口令转换为可直接访问的链接,使您可一键直达闲鱼/淘宝。

当前为 2020-07-01 提交的版本,查看 最新版本

// ==UserScript==
// @name         去你大爷的闲鱼口令
// @namespace    http://tampermonkey.net/
// @version      0.2.0
// @description  它将 V2EX 帖子中的闲鱼口令/淘口令转换为可直接访问的链接,使您可一键直达闲鱼/淘宝。
// @author       Wood
// @match        https://*.v2ex.com/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    const text = document.body.innerText;
    const tkl = text.match(/[€|¥][A-Za-z0-9]+[€|¥]/g);

    window.addIframe = (url) => {
        const viewDom = document.getElementById("viewGoods");
        viewDom && viewDom.remove();
        let div = document.createElement("div");
        div.setAttribute("id", "viewGoods");
        div.innerHTML = `
<div><span onclick="document.getElementById('viewGoods').remove()" style="width: 60px;height: 30px;color: white;background: red;display: inline-block;text-align: center;line-height: 30px;float: right;cursor: pointer;">关闭</span></div>
<iframe src=${url}" style="width: 300px;height: 540px;">`;
        div.style.position = "fixed";
        div.style.bottom = "3em";
        div.style.right = "4em";
        document.body.appendChild(div);
    }

    tkl && tkl.length > 0 && tkl.forEach(x=>{
        if(fetch){
            fetch(`https://jckhj8su.demo.wood-is.top/tkl/tkljm?apikey=ZwuJXDIBef&tkl=${x}`).then(res => {res.json().then(data => {
                const {content, url} = data;
                document.body.innerHTML = document.body.innerHTML.replace(x, `<span title="${content}" onclick="addIframe('${url}')" style="color: red; padding: 0 .5em; font-weight: 500; cursor: pointer;">${x}</span>`)
            })})
        }
    });
})();