SoftCobra / Nin10News Decoder

Automatically convert all SoftCobra.com link codes into clickable links which automatically redirect to the link code's decoded link.

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         SoftCobra / Nin10News Decoder
// @version      1.0
// @author       Chris Barlow <[email protected]>
// @locale       en_US
// @description  Automatically convert all SoftCobra.com link codes into clickable links which automatically redirect to the link code's decoded link.
// @namespace    softcobra_nin10news
// @license      MIT
// @match        *://softcobra.com/*
// @match        *://www.softcobra.com/*
// @match        *://nin10news.com/decode*
// @match        *://www.nin10news.com/decode*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=softcobra.com
// @require      http://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js
// @run-at       document-start
// ==/UserScript==

(function() {
///////////////////////////////////////////////////////////////////////////////////////////////

const safeInterval = (fn, ms) => {
    return setInterval(()=>{
        if (!document.hasFocus()) return
        fn()
    }, ms)
}

const init = () => {
    // softcobra.com
    if (location.host.endsWith('softcobra.com')) {
        safeInterval(() => {
            $('article > .entry-content-wrapper > .entry-content tr > td:not(.cdb)')
                .filter((i,o) => {
                    let hash = o.innerText.trim()
                    return hash.length > 40 && !hash.includes(' ')
                })
                .each((i,o) => {
                    $(o).replaceWith($(`
                        <td class="cdb">
                            <a href="https://nin10news.com/decode/#hash=${escape(o.innerText)}')">${o.innerText}</a>
                        </td>
                    `))
                })
        }, 1000)
    }

    // nin10news.com
    else if (location.host.endsWith('nin10news.com')) {
        let url = '/wp-content/themes/twentysixteen/inc/decode.php'
        let hash = unescape(location.hash.replace('#hash=', ''))
        $.post(url, {data: hash}, (res) => {
            let url = atob(res)
            if (!url.startsWith('http')) return
            location = url
        })
    }
}
init();

////////////////////////////////////////////////////////////////////////////////////////////////////
})();