Add links to SGtools

Extend the Sidebar on Steamgifts-Userpages to include links to www.sgtools.tk

目前為 2015-05-29 提交的版本,檢視 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Add links to SGtools
// @namespace    www.twitter.com/silentguy
// @version      0.1
// @author       SilentGuy
// @description  Extend the Sidebar on Steamgifts-Userpages to include links to www.sgtools.tk
// @match        http://www.steamgifts.com/user/*
// @grant        none
// ==/UserScript==

    var elems = document.getElementsByTagName('*'), i;
    var doit=true;
    var steam;
    var steamgift=window.location.href.substring(window.location.href.lastIndexOf("/"));

    for (i in elems) {
        if((' ' + elems[i].className + ' ').indexOf(' ' + "fa-steam" + ' ') > -1) {
            var steamlink=elems[i].parentNode.href;
            steam=steamlink.substring(steamlink.lastIndexOf("/"));
        } else if(doit && (' ' + elems[i].className + ' ').indexOf(' ' + "sidebar__navigation" + ' ') > -1) {
            //elems[i].innerHTML = content;
            //console.log(elems[i].innerHTML);
            var current=elems[i];
            var heading = document.createElement("h3");
            heading.className += " sidebar__heading";
            var t = document.createTextNode("sgtools");
            heading.appendChild(t);
            current.parentElement.appendChild(heading);
            
            var list = document.createElement("ul");
            list.className += " sidebar__navigation";
            
            
            //-----
            
            var item = document.createElement("li");
            item.className += " sidebar__navigation__item";
            list.appendChild(item);
            
            var link = document.createElement("a");
            link.className += " sidebar__navigation__item__link";
            link.href="http://www.sgtools.tk/sent"+steamgift;
            link.target="_blank";
            item.appendChild(link);
            
            
            var div = document.createElement("div");
            div.className += " sidebar__navigation__item__name";
            t = document.createTextNode("Real CV sent");
            div.appendChild(t);
            link.appendChild(div);
            
            div = document.createElement("div");
            div.className += " sidebar__navigation__item__underline";
            link.appendChild(div);

            //-----
            
            item = document.createElement("li");
            item.className += " sidebar__navigation__item";
            list.appendChild(item);
            
            link = document.createElement("a");
            link.className += " sidebar__navigation__item__link";
            link.href="http://www.sgtools.tk/won"+steamgift;
            link.target="_blank";
            item.appendChild(link);
            
            
            div = document.createElement("div");
            div.className += " sidebar__navigation__item__name";
            t = document.createTextNode("Real CV won");
            div.appendChild(t);
            link.appendChild(div);
            
            div = document.createElement("div");
            div.className += " sidebar__navigation__item__underline";
            link.appendChild(div);

            
            //-----

            item = document.createElement("li");
            item.className += " sidebar__navigation__item";
            list.appendChild(item);
            
            link = document.createElement("a");
            link.className += " sidebar__navigation__item__link";
            link.href="http://www.sgtools.tk/nonactivated"+steamgift+steam;
            link.target="_blank";
            item.appendChild(link);
            
            
            div = document.createElement("div");
            div.className += " sidebar__navigation__item__name";
            t = document.createTextNode("Not activated");
            div.appendChild(t);
            link.appendChild(div);
            
            div = document.createElement("div");
            div.className += " sidebar__navigation__item__underline";
            link.appendChild(div);
            
            
            
            
            
            current.parentElement.appendChild(list);


            
            doit=false;
        }
    }