Greasy Fork

Greasy Fork is available in English.

巴哈姆特公會、首頁自動簽到

巴哈姆特公會、首頁自動簽到 by.moontai0724

目前为 2018-01-02 提交的版本,查看 最新版本

// ==UserScript==
// @name         巴哈姆特公會、首頁自動簽到
// @version      1.0
// @description  巴哈姆特公會、首頁自動簽到 by.moontai0724
// @author       moontai0724
// @match        https://www.gamer.com.tw
// @match        https://guild.gamer.com.tw/guild.php?sn=*
// @grant        none
// @namespace http://greasyfork.icu/users/165315
// ==/UserScript==

(function()
 {
    'use strict';

    /* (Chrome)
    如果要開啟自動簽到,請在「設定 -> 起始畫面」中新增 https://www.gamer.com.tw/#check
    如果要開啟自動簽到,請在「設定 -> 起始畫面」中新增 https://www.gamer.com.tw/#check
    如果要開啟自動簽到,請在「設定 -> 起始畫面」中新增 https://www.gamer.com.tw/#check

    網址錯誤將無法正常運行。

    意思為在開啟瀏覽器時,都會打開 https://www.gamer.com.tw/#check
    當打開 https://www.gamer.com.tw/#check 的時候,自動簽到就會開始。
    請靜待程式結束,速度依照公會數量而定。
    何謂程式結束?它會自動開啟又關閉分頁,當公會分頁皆消失時,即為結束。

    ----------------------------------------------------------------------------------------------------

    公會自動簽到列表
      請在這一個列表中寫入您要簽到的公會ID,ID可於網址找到
      如果有一個公會網址為 https://guild.gamer.com.tw/guild.php?sn=9999 則 ID 即為 sn 後方的 9999
      請依照下方格式加入列表中。

    */

    var gulidnumbers = ["1234", "5678", "12345", "45678"];

/*
    作者的話:本人僅於 Chrome 上測試,照理說應能通用,但如有錯誤,將不提供其他瀏覽器的完全支援與改動。
             (如果有錯誤還是可以回報,也許某天會改動。)
    ----------------------------------------------------------------------------------------------------*/



    // 下方為程式內容,請勿更動。下方為程式內容,請勿更動。下方為程式內容,請勿更動。下方為程式內容,請勿更動。
    // 下方為程式內容,請勿更動。下方為程式內容,請勿更動。下方為程式內容,請勿更動。下方為程式內容,請勿更動。
    // 下方為程式內容,請勿更動。下方為程式內容,請勿更動。下方為程式內容,請勿更動。下方為程式內容,請勿更動。
    // 下方為程式內容,請勿更動。下方為程式內容,請勿更動。下方為程式內容,請勿更動。下方為程式內容,請勿更動。
    // 下方為程式內容,請勿更動。下方為程式內容,請勿更動。下方為程式內容,請勿更動。下方為程式內容,請勿更動。
    // 下方為程式內容,請勿更動。下方為程式內容,請勿更動。下方為程式內容,請勿更動。下方為程式內容,請勿更動。
    // 下方為程式內容,請勿更動。下方為程式內容,請勿更動。下方為程式內容,請勿更動。下方為程式內容,請勿更動。
    // 下方為程式內容,請勿更動。下方為程式內容,請勿更動。下方為程式內容,請勿更動。下方為程式內容,請勿更動。
    // 下方為程式內容,請勿更動。下方為程式內容,請勿更動。下方為程式內容,請勿更動。下方為程式內容,請勿更動。
    // 下方為程式內容,請勿更動。下方為程式內容,請勿更動。下方為程式內容,請勿更動。下方為程式內容,請勿更動。


    var url = location.href;
    var testresult = test(url);
    var id = "temp";
    var final = "temp";

    // 如果是公會就解析網址 ok
    if(testresult == 1)
    {
        var ary1 = url.split('?');
        var ary2 = ary1[1].split('=');
        var ary3 = ary2[1].split('#');
        id = ary3[0];
        final = bind(id);
    }

    // 禁止 alert ok
    if(url == "https://www.gamer.com.tw/#check" || url == final)
    {
        window.alert = function(str)
        {
            return ;
        };
    }

    // 如果是首頁,且位址為 https://www.gamer.com.tw/#check 就簽到 ok
    if(url == "https://www.gamer.com.tw/#check")
    {
        Signin.start(this);
        window.setTimeout(function(){windows.close();},3000);
    }

    // 如果是公會,且位址後方有 #check 就簽到 ok
    if(url == final)
    {
        guild_sign(id);
        window.setTimeout(function(){this.close();},3000);
        window.setTimeout(function(){windows.close();},3000);
    }

    // 開分頁
    if(url == "https://www.gamer.com.tw/#check" || bind(id))
    {
        if(url == "https://www.gamer.com.tw/#check")
        {
            var awindow = window.open(bind(gulidnumbers[0]));
            window.setTimeout(function(){awindow.close();},1000*(gulidnumbers.length+1));
        }
        for(var i=0;i<gulidnumbers.length-1;i++)
        {
            if(url==bind(gulidnumbers[i]))
            {
                var mywindow = window.open(bind(gulidnumbers[i+1]));
                window.setTimeout(function(){mywindow.close();},1000*(gulidnumbers.length-i));
            }
        }
    }
 }
)();

function bind(id) {
    return "https://guild.gamer.com.tw/guild.php?sn=" + id + "#check";
}

function test(url) {
    var ary1 = url.split('?');
    if(ary1[0] == "https://guild.gamer.com.tw/guild.php") {
       return 1;
    } else {
        return 0;
    }
}