Steam Archive Menu

Because we despise scammers

当前为 2021-07-02 提交的版本,查看 最新版本

// ==UserScript==
// @name     Steam Archive Menu
// @description	Because we despise scammers
// @version		1.3
// @author       SkauOfArcadia
// @homepage https://skau.neocities.org/
// @contactURL https://t.me/SkauOfArcadia
// @match  *://steamcommunity.com/*
// @run-at      document-idle
// @grant none
// @namespace https://gf.qytechs.cn/users/751327
// ==/UserScript==
/**
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */
 var isHover = false
 var archUrl
 var x = String(window.location.pathname)
 
 if (x.substr(-'/'.length) === '/') {
     x = String(window.location.pathname).slice(0, -1)
 }
 
 function isNumeric(str) {
   if (typeof str != "string") return false
   return !isNaN(str) &&
          !isNaN(parseFloat(str))
 }
 
 function insertAfter(newNode, referenceNode) {
     referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling);
 }
 
 function getOffset( el ) {
     var _x = 0;
     var _y = 0;
     while( el && !isNaN( el.offsetLeft ) && !isNaN( el.offsetTop ) ) {
         _x += el.offsetLeft - el.scrollLeft;
         _y += el.offsetTop - el.scrollTop;
         el = el.offsetParent;
     }
     return { top: _y, left: _x };
 }
 
 function mouseOver() {
     var parentPos = getOffset(parentClass).left - getOffset(parentClass.parentNode).left
     console.log(parentPos)
     childClass.style.left = Math.round(parentPos) + "px";
     childClass.style.opacity = "1";
     childClass.style.pointerEvents = "auto";
     isHover = true
 }
 
 function mouseOut() {
     isHover=false
     setTimeout(() => { if(!isHover){childClass.style.opacity = "0"; childClass.style.pointerEvents = "none";} }, 100);
 }
 
 archUrl = String(window.location)
 if (/\/id\//i.test (x))
 {
     var y = document.body.innerHTML;
     y = y.split('","steamid":"').pop().split('","personaname"')[0];
     if(isNumeric(y)){
           console.log('Obtained SteamID:' + y);
           archUrl = 'https://steamcommunity.com/profiles/' + y
         }
 }
 
 if (/l=/i.test (archUrl) && /id=/i.test (archUrl))
 {
     archUrl = archUrl.split('l=')[0] + 'id=' + archUrl.split('id=').pop()
 } else if (/l=/i.test (archUrl)) {
     archUrl = archUrl.split('?')[0]
 }
 
 var menuitem=document.getElementsByClassName("menuitem");
 var archmenu = document.createElement("a");
 var archtxt = document.createTextNode("ARCHIVE...");
 archmenu.setAttribute("class","menuitem archive");
 archmenu.setAttribute("data-tooltip-type","selector");
 archmenu.setAttribute("data-tooltip-content",".submenu_archive");
 archmenu.appendChild(archtxt);
 var archnav = document.createElement("div")
 archnav.setAttribute("style","position: absolute; z-index: 1500; opacity: 0; left: 300px; top: 64px; pointer-events: none;");
 archnav.setAttribute("class","supernav_content archive");
 var archsub  = document.createElement("div")
 archsub.setAttribute("class","submenu_archive");
 archsub.setAttribute("style","");
 archsub.setAttribute("data-submenuid","archive");
 var archit1 = document.createElement("a");
 archit1.setAttribute("class","submenuitem");
 archit1.setAttribute("href","https://web.archive.org/save/" + archUrl);
 archit1.setAttribute("target","_blank");
 archit1.setAttribute("rel","noopener noreferrer");
 var archit1txt = document.createTextNode("Archive this page");
 archit1.appendChild(archit1txt);
 var archit2 = document.createElement("a");
 archit2.setAttribute("class","submenuitem");
 archit2.setAttribute("href","https://web.archive.org/web/*/" + archUrl);
 archit2.setAttribute("target","_blank");
 archit2.setAttribute("rel","noopener noreferrer");
 var archit2txt = document.createTextNode("View History");
 archit2.appendChild(archit2txt);
 archsub.appendChild(archit1);
 archsub.appendChild(archit2);
 archnav.appendChild(archsub);
 
 insertAfter(archnav, menuitem[menuitem.length - 1]);
 
 insertAfter(archmenu, menuitem[menuitem.length - 1]);
 
 var parentClass = document.getElementsByClassName("menuitem archive")[0];
 var childClass = document.getElementsByClassName("supernav_content archive")[0];
 
 parentClass.addEventListener("mouseover", mouseOver);
 parentClass.addEventListener("mouseout", mouseOut);
 childClass.addEventListener("mouseover", mouseOver);
 childClass.addEventListener("mouseout", mouseOut);

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址