Because we despise scammers
当前为
// ==UserScript==
// @name Steam Archive Menu
// @description Because we despise scammers
// @version 1.4.1
// @author SkauOfArcadia
// @homepage https://skau.neocities.org/
// @contactURL https://t.me/SkauOfArcadia
// @match *://steamcommunity.com/*
// @match *://store.steampowered.com/*
// @run-at document-idle
// @grant none
// @namespace https://greasyfork.org/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
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 = window.location.protocol + "//" + window.location.hostname
if (window.location.pathname.indexOf('/id/') === 0 && (window.location.pathname.lastIndexOf('/') === 3 || window.location.pathname.split('/')[3].length === 0))
{
var y = document.body.innerHTML;
y = y.split('","steamid":"').pop().split('","personaname"')[0];
if(isNumeric(y)){
console.log('Obtained SteamID:' + y);
archUrl += '/profiles/' + y;
}
} else if (window.location.pathname.indexOf('/app/') === 0 || window.location.pathname.indexOf('/bundle/') === 0){
var y = window.location.pathname;
let path = '/' + y.split('/')[1].split('/')[0] + '/';
y = y.split(path).pop().split('/')[0];
if(isNumeric(y)){
archUrl += path + y;
}
} else {
archUrl += window.location.pathname
}
if (window.location.search.indexOf('?l=') !== -1 || window.location.search.indexOf('&l=') !== -1
|| window.location.search.indexOf('?searchtext=') !== -1 || window.location.search.indexOf('&searchtext=') !== -1) {
let params = new URLSearchParams(window.location.search)
params.delete('l');
params.delete('searchtext');
if (String(params).length > 0){
archUrl += '?' + params;
}
} else {
archUrl += window.location.search
}
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);