Greasy Fork is available in English.
Bilibili 20180621助力活动
当前为
// ==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);
}
}
})();