AtCoder HashTag Setter

Add Twitter HashTag to share button on AtCoder

目前為 2021-02-26 提交的版本,檢視 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         AtCoder HashTag Setter
// @namespace     https://atcoder.jp/
// @version      1.0
// @description  Add Twitter HashTag to share button on AtCoder
// @author       G4NP0N
// @match        https://atcoder.jp/contests/*
// @grant        none
// ==/UserScript==

window.onload = function() {
    var url = location.href.split("/");
    if(url.length < 5)return;
    var contestId = location.href.split("/")[4];
    var problemId;
    var txt = document.getElementsByClassName("a2a_kit")[0].getAttribute("data-a2a-title");
    txt += " #AtCoder_";
    if(url.length==7){
        if(url[5]=="tasks"){
            txt +=url[6];
        }else if(url[5]=="submissions" && url[6]!="me"){
            txt += document.querySelector("#main-container > div.row > div:nth-child(2) > div:nth-child(9) > table > tbody > tr:nth-child(2) > td > a").getAttribute("href").split("/")[4];
        }else{
            txt+=contestId;
        }
    }else{
        txt += contestId;
    }
    document.getElementsByClassName("a2a_kit")[0].setAttribute("data-a2a-title",txt);
};