🎉 欢迎访问GreasyFork.Org 镜像站!本镜像站由公众号【爱吃馍】搭建,用于分享脚本。联系邮箱📮

Greasy fork 爱吃馍镜像

Greasy Fork is available in English.

4chan/f helper

4chan/f helper script

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

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

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

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

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

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

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

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

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

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

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

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

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

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

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

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

// ==UserScript==
// @name         4chan/f helper
// @namespace    https://greasyfork.org/zh-CN/scripts/412639-4chan-f-fitler
// @version      0.3
// @description  4chan/f helper script
// @description  ctrl+<- prev swf
// @description  ctrl+-> next swf
// @author       Neysummer2000
// @match        https://boards.4chan.org/f/
// @grant GM_setValue
// @grant GM_getValue
// @grant GM_openInTab
// @grant GM_addStyle
// ==/UserScript==

(function() {
    'use strict';
    // GM_addStyle(".viewing{background-color: blue !important;}");

    var g_viewing; // dom
    var g_viewed = GM_getValue("4chan_viewed", "[]");
    g_viewed = JSON.parse(g_viewed);

    window.addEventListener("keydown", function(ev){
        if(g_viewing === undefined) return;
        if(ev.ctrlKey){
            switch(ev.key){
                case "ArrowRight":
                    var prev = g_viewing.nextElementSibling;
                    if(prev !== null){
                        document.getElementById('swf-embed').remove()
                        prev.children[3].children[0].click();
                    }
                    break;

                case "ArrowLeft":
                    var next = g_viewing.previousElementSibling;
                    if(next !== null){
                        document.getElementById('swf-embed').remove()
                        next.children[3].children[0].click();
                    }
                    break;

            }
        }
    });

    var g_doms = [];
    document.querySelectorAll('.flashListing td:nth-child(4) a').forEach(function(d) {
        var parent =  d.parentElement.parentElement;
        if (g_viewed.indexOf(d.href) != -1){
            parent.remove();
        }else{
            g_doms.push(d);
        }
    });

   g_doms.forEach(function(d, i){
       var parent =  d.parentElement.parentElement;
        d.addEventListener("click", function(ev) {
//             for(let dom of document.querySelectorAll(".viewing")){
//                 dom.classList.remove("viewing");
//             }
//             parent.classList.add("viewing");

            g_viewed.push(d.href);
            g_viewing = parent;
            // console.log(g_viewing);
            GM_setValue("4chan_viewed", JSON.stringify(g_viewed));

            var iframe = document.getElementById('swf-embed-header');
            var span = document.createElement("span");
            span.innerText = "  --  " + parent.children[6].innerText;
            iframe.appendChild(span);

            var span_1 = document.createElement("span");
            span_1.innerText = "[ " + (i + 1) + "/" + g_doms.length+ "] ";
            iframe.prepend(span_1);

            var a = document.createElement("a");
            //a.target = "_blank";
            //a.href = d.href;
            a.href = "javascript: void(0)";
            a.addEventListener("click", function(){GM_openInTab(d.href, true)});
            a.innerText = "download";
            a.style.cssText = "float: right; margin-right: 10px;";
            iframe.appendChild(a);
            //console.log(d.href);

        });
    });

})();