Greasy Fork

Greasy Fork is available in English.

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

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

当前为 2018-01-03 提交的版本,查看 最新版本

// ==UserScript==
// @name         巴哈姆特公會、首頁自動簽到
// @version      1.1
// @description  巴哈姆特公會、首頁自動簽到 by.moontai0724
// @author       moontai0724
// @match        https://www.gamer.com.tw
// @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/index2.php#check
    如果要開啟自動簽到,請在「設定 -> 起始畫面」中新增 https://www.gamer.com.tw/index2.php#check
    如果要開啟自動簽到,請在「設定 -> 起始畫面」中新增 https://www.gamer.com.tw/index2.php#check

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

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

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

    公會自動簽到列表
      請在這一個列表中寫入您要簽到的公會ID,ID可於網址找到
      如果有一個公會網址為 https://guild.gamer.com.tw/guild.php?sn=9999 則 ID 即為 sn 後方的 9999
      此功能將消耗不少 CPU,請衡量電腦效能後再使用。
      請記得備份此陣列(guildnumbers)內容,以免更新後消失。
      請依照下方格式加入列表中。
    */

//  var gulidnumbers = ["1234", "5678", "12345", "45678"]; ----> 此行為範例

    var gulidnumbers = [];

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



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


    var id = "temp";

    // 如果是公會就解析網址 ok
    if(location.hostname == "guild.gamer.com.tw" && location.pathname == "/guild.php")
    {
        var sn = location.search.split('=');
        id = sn[1];
    }

    // 禁止 alert ok
    if(location.hash == "#check")
    {
        window.alert = function(str)
        {
            return ;
        };
    }

    // 如果是首頁,且有 #check 就簽到 ok
    if(location.hostname == "www.gamer.com.tw" && location.hash == "#check")
    {
        Signin.start(this);
    }

    // 如果是公會,且位址後方有 #check 就簽到 ok
    if(location.hostname == "guild.gamer.com.tw" && location.pathname == "/guild.php" && location.hash == "#check")
    {
        guild_sign(id);
    }

    // 開分頁
    if(location.hostname == "www.gamer.com.tw" && location.hash == "#check" || location.hostname == "guild.gamer.com.tw" && location.pathname == "/guild.php" && location.hash == "#check")
    {
        if(location.hostname == "www.gamer.com.tw" && location.hash == "#check" && gulidnumbers.length !== 0)
        {
            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(location.href==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";
}