Greasy Fork

Greasy Fork is available in English.

SteamCN 链接互点

Bilibili 20180621助力活动

当前为 2018-09-30 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         SteamCN 链接互点
// @namespace    http://greasyfork.icu/users/34380
// @version      20180930
// @description  Bilibili 20180621助力活动
// @match        https://steamcn.com/t427838-*-1
// @match        https://steamcn.com/forum.php*tid=427838*
// @grant        GM_setValue
// @grant        GM_getValue
// @grant        GM_listValues
// @grant        GM_deleteValue
// @run-at       document-idle
// ==/UserScript==

(function () {
    'use strict';

    // Your code here...
    const loc_hostname = window.location.hostname;
    const loc_href = window.location.href;
    if (loc_hostname === "steamcn.com") {
        const scr_run = document.createElement("a");
        const clear_all = document.createElement("a");
        scr_run.id = "open-links";
        scr_run.innerText = "打开本页链接";
        scr_run.setAttribute('style', 'margin: 6px;font-size: 18px;background-color: #b7dff1;');
        scr_run.onclick = function () { openBiliLinks() };
        clear_all.id = "clear-links";
        clear_all.innerText = "每日清除链接记录";
        clear_all.setAttribute('style', 'margin: 6px;font-size: 18px;background-color: #b7dff1;');
        clear_all.onclick = function () { clearOpenedLinks() };
        document.querySelector("#pgt").appendChild(scr_run);
        document.querySelector("#pgt").appendChild(clear_all);

        function openBiliLinks() {
            let floors = document.querySelectorAll(".t_f");
            let opened_links = GM_getValue("opened_links", "");
            if (opened_links !== "") {
                opened_links = opened_links.split(",");
            } else {
                opened_links = [];
            }

            for (let link of floors) {
                const uid = link.innerHTML.match(/activity\/lucky_draw\/share\?share_id=(\d+)/);
                // const tcn = link.innerHTML.match(/http:\/\/t\.cn\/\w{7}/);
                if (uid && !opened_links.includes(uid[1])) {
                    window.open("https://www.igxe.cn/activity/lucky_draw/share?share_id=" + uid[1]);
                    opened_links.push(uid[1]);
                    GM_setValue("opened_links", opened_links.join(","));
                // } else if (tcn) {
                //     window.open(tcn[0]);
                }
            }
        }
        function clearOpenedLinks() {
            GM_listValues().map(GM_deleteValue);
        }
    }
})();