CSGO Links Helper

Add links on steam and faceit

当前为 2019-05-29 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         CSGO Links Helper
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Add links on steam and faceit
// @require      https://cdn.bootcss.com/bignumber.js/8.1.1/bignumber.min.js
// @author       maxinimize
// @match        https://www.faceit.com/*/players/*
// @match        https://steamcommunity.com/id/*
// @match        https://steamcommunity.com/profiles/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    const SteamToESEA = (steamID) => {
        const steamID3 = BigNumber(steamID).minus('76561197960265728');
        const z = steamID3.dividedToIntegerBy(2);
        const y = BigNumber(steamID).modulo(2);
        const eseaResult = "https://play.esea.net/index.php?s=search&query=1%3A" + y.toString() + "%3A" + z.toString();
        return eseaResult;
    }

    const currentUrl = window.location.href;
    if (currentUrl.includes("faceit")) {
        window.setTimeout(function() {
            const faceitlogin = $('#main-container-height-wrapper > div > div > section.page-title.page-title--with-bg.page-title--with-inset > div.page-title__content > div.page-title__content__title.page-title__content--flexible.page-title__content--dark-bg > h1').text();
            const [url1, url2, url3] = [
                "https://faceitstats.com/player,"+faceitlogin,
                "https://www.faceit-stats.me/?user="+faceitlogin,
                "https://faceitelo.net/player/"+faceitlogin
            ];
            const [faceit1, faceit2, faceit3] = [
                $(`<li class="subpage-nav__list__item"> <a class="subpage-nav__list__link" href="${url1}" target="_blank">facitstats</a></li>`),
                $(`<li class="subpage-nav__list__item"> <a class="subpage-nav__list__link" href="${url2}" target="_blank">facit-stats</a></li>`),
                $(`<li class="subpage-nav__list__item"> <a class="subpage-nav__list__link" href="${url3}" target="_blank">facitelo</a></li>`)
            ]
            for (let faceit of [faceit1, faceit2, faceit3]) {
                $('#main-container-height-wrapper > div > div > nav > ul').append(faceit);
            }
        }, 2000);
    }

    if(currentUrl.includes("steam")) {
        const urlFaceit = "https://faceitstats.com/steam,"+window.g_rgProfileData.steamid;
        const urlESEA = SteamToESEA(window.g_rgProfileData.steamid);
        const faceit = $J(`<div class="profile_count_link"><a id="faceit" href="${urlFaceit}" target="_blank"><span class="count_link_label">faceitstats</span></a></div>`);
        const esea = $J(`<div class="profile_count_link"><a id="esea" href="${urlESEA}" target="_blank"><span class="count_link_label">ESEA</span></a></div>`);
        // es_profile_link css
        faceit.css({
           	'display': 'inline-block',
            'margin-top': '10px'
        })
        // add missing div for private profile
        const privateBan = $J('body > div.responsive_page_frame.with_header > div.responsive_page_content > div.responsive_page_template_content > div.no_header.profile_page.private_profile > div.profile_content > div > div.profile_rightcol');
        const privateNoBan = $J('body > div.responsive_page_frame.with_header > div.responsive_page_content > div.responsive_page_template_content > div.no_header.profile_page.private_profile > div.profile_content');
        if(privateBan) {
            privateBan.append($J(`<div class="profile_item_links"></div>`));
        }
        if(!privateBan && privateNoBan) {
            privateNoBan.append($J(`<div><div class="profile_rightcol"><div class="profile_item_links"></div></div></div`))
        }
        $J('div.profile_item_links').append(faceit);
        $J('div.profile_item_links').append(esea);
    }
})();