Tiny Customize

针对一些常用网站的反反广告、自动化等。

Per 01-06-2016. Zie de nieuwste versie.

Voor het installeren van scripts heb je een extensie nodig, zoals Tampermonkey, Greasemonkey of Violentmonkey.

Voor het installeren van scripts heb je een extensie nodig, zoals Tampermonkey of Violentmonkey.

Voor het installeren van scripts heb je een extensie nodig, zoals Tampermonkey of Violentmonkey.

Voor het installeren van scripts heb je een extensie nodig, zoals Tampermonkey of Userscripts.

Voor het installeren van scripts heb je een extensie nodig, zoals {tampermonkey_link:Tampermonkey}.

Voor het installeren van scripts heb je een gebruikersscriptbeheerder nodig.

(Ik heb al een user script manager, laat me het downloaden!)

Voor het installeren van gebruikersstijlen heb je een extensie nodig, zoals {stylus_link:Stylus}.

Voor het installeren van gebruikersstijlen heb je een extensie nodig, zoals {stylus_link:Stylus}.

Voor het installeren van gebruikersstijlen heb je een extensie nodig, zoals {stylus_link:Stylus}.

Voor het installeren van gebruikersstijlen heb je een gebruikersstijlbeheerder nodig.

Voor het installeren van gebruikersstijlen heb je een gebruikersstijlbeheerder nodig.

Voor het installeren van gebruikersstijlen heb je een gebruikersstijlbeheerder nodig.

(Ik heb al een beheerder - laat me doorgaan met de installatie!)

// ==UserScript==
// @name        Tiny Customize
// @description 针对一些常用网站的反反广告、自动化等。
// @namespace   [email protected]
// @author      [email protected]
// @include     http://forum.gamer.com.tw/*
// @include     http://bbs.kafan.cn/*
// @version     1.0.2
// @grant       none
// ==/UserScript==

if (typeof unsafeWindow == "undefined")
{
    unsafeWindow = window;
}

/**
 * 获取立即执行的操作。
 */
const getInstantActions = function()
{
    const host = unsafeWindow.location.host;
    const actions = [];

    if (host === "forum.gamer.com.tw")
    {
        // 巴哈姆特。
        // 反反广告检测。
        const action = function()
        {
            if (unsafeWindow.AntiAd)
            {
                unsafeWindow.AntiAd.check = function() {};
            }
        };
        actions.push(action);
    }
    else if (host === "bbs.kafan.cn")
    {
        // 卡饭论坛。
        // 屏蔽方向键翻页。
        const action = function()
        {
            if (unsafeWindow.keyPageScroll)
            {
                unsafeWindow.keyPageScroll = function() {};
            }
        };
        actions.push(action);
    }

    return actions;
};

/**
 * 获取延迟执行的操作。
 */
const getLazyActions = function()
{
    const host = unsafeWindow.location.host;
    const actions = [];

    // 巴哈姆特。
    if (host === "forum.gamer.com.tw")
    {
        // 自动开启图片。
        let action = function()
        {
            if (unsafeWindow.forumShowAllMedia)
            {
                unsafeWindow.forumShowAllMedia();
            }
        };
        actions.push(action);
    }

    return actions;
};

/**
 * 执行指定的操作。
 */
const exec = function(p_actions)
{
    if (p_actions)
    {
        p_actions.forEach(function(p_action)
        {
            p_action();
        });
    }
};

// 1. 立即执行。
exec(getInstantActions());


// 2. 延迟执行。
unsafeWindow.addEventListener("load", function()
{
    exec(getLazyActions());
}, true);