ATP TestScriptFunction

Test skriptu

此腳本不應該直接安裝,它是一個供其他腳本使用的函式庫。欲使用本函式庫,請在腳本 metadata 寫上: // @require https://update.greasyfork.org/scripts/483757/1305569/ATP%20TestScriptFunction.js

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

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

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

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

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

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

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

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

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

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

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

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

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

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

function atpTourChecker() {
'use strict';
var a = document.querySelectorAll('.stats-cta > a:nth-child(1)');
var year = document.querySelector('.date-location > span:last-child').textContent.trim().match(/[0-9]{4}$/);
var tourID = window.location.href.match(/\/([0-9]+)\//)[1];
var tourTypeMatch = document.querySelector('.atp_draw > div > ul > li.active > a').textContent.trim();
var tourType;
if (tourTypeMatch == "Singles") {
tourType = "ms";}
if (tourTypeMatch == "Doubles") {
tourType = "md";}
if (tourTypeMatch == "Qual Singles") {
tourType = "qs";}
if (tourTypeMatch == "Qual Doubles") {
tourType = "qd";}

var matchCount = a.length;
var there_are_12 = ["008", "009", "010", "011", "012", "013", "014", "015", "004", "005", "006", "007"];
var there_are_31 = ["016", "017", "018", "019", "020", "021", "022", "023", "024", "025", "026", "027", "028", "029", "030", "031", "008", "009", "010", "011", "012", "013", "014", "015", "004", "005", "006", "007", "002", "003", "001"];
var there_are_63 = ["032", "033", "034", "035", "036", "037", "038", "039", "040", "041", "042", "043", "044", "045", "046", "047", "048", "049", "050", "051", "052", "053", "054", "055", "056", "057", "058", "059", "060", "061", "062", "063", "016", "017", "018", "019", "020", "021", "022", "023", "024", "025", "026", "027", "028", "029", "030", "031", "008", "009", "010", "011", "012", "013", "014", "015", "004", "005", "006", "007", "002", "003", "001"];
var there_are_15 = ["008", "009", "010", "011", "012", "013", "014", "015", "004", "005", "006", "007", "002", "003", "001"];
var there_are_3 = ["002", "003", "001"];
var there_are_18 = ["016", "017", "018", "019", "020", "021", "022", "023", "024", "025", "026", "027", "008", "009", "010", "011", "012", "013"];
var there_are_21 = ["016", "017", "018", "019", "020", "021", "022", "023", "024", "025", "026", "027", "028", "029", "009", "010", "011", "012", "013", "014", "015"];
var there_are_36 = ["032", "033", "034", "035", "036", "037", "038", "039", "040", "041", "042", "043", "044", "045", "046", "047", "048", "049", "050", "051", "052", "053", "054", "055", "016", "017", "018", "019", "020", "021", "022", "023", "024", "025", "026", "027"];
var there_are_127 = ["064", "065", "066", "067", "068", "069", "070", "071", "072", "073", "074", "075", "076", "077", "078", "079", "080", "081", "082", "083", "084", "085", "086", "087", "088", "089", "090", "091", "092", "093", "094", "095", "096", "097", "098", "099", "100", "101", "102", "103", "104", "105", "106", "107", "108", "109", "110", "111", "112", "113", "114", "115", "116", "117", "118", "119", "120", "121", "122", "123", "124", "125", "126", "127", "032", "033", "034", "035", "036", "037", "038", "039", "040", "041", "042", "043", "044", "045", "046", "047", "048", "049", "050", "051", "052", "053", "054", "055", "056", "057", "058", "059", "060", "061", "062", "063", "016", "017", "018", "019", "020", "021", "022", "023", "024", "025", "026", "027", "028", "029", "030", "031", "008", "009", "010", "011", "012", "013", "014", "015", "004", "005", "006", "007", "002", "003", "001"];

var m12 = there_are_12.length
var m31 = there_are_31.length
var m63 = there_are_63.length
var m15 = there_are_15.length
var m3 = there_are_3.length
var m18 = there_are_18.length
var m21 = there_are_21.length
var m36 = there_are_36.length
var m127 = there_are_127.length
var list;
if (matchCount == m12) {
list = there_are_12;}
if (matchCount == m31) {
list = there_are_31;}
if (matchCount == m63) {
list = there_are_63;}
if (matchCount == m15) {
list = there_are_15;}
if (matchCount == m3) {
list = there_are_3;}
if (matchCount == m18) {
list = there_are_18;}
if (matchCount == m21) {
list = there_are_21;}
if (matchCount == m36) {
list = there_are_36;}
if (matchCount == m127) {
list = there_are_127;}

for (var i = 0; i < matchCount; i++) {
        var value = "/en/scores/stats-centre/live/" + year + "/" + tourID + "/" + tourType + list[i];
        a[i].setAttribute("href", value);
    }
}