Steam Archive Menu

Because we despise scammers

As of 2021-03-25. See the latest version.

// ==UserScript==
// @name     Steam Archive Menu
// @description	Because we despise scammers
// @version		1.1
// @author       SkauOfArcadia
// @homepage https://skau.neocities.org/
// @contactURL https://t.me/SkauOfArcadia
// @match  *://steamcommunity.com/*
// @run-at      document-idle
// @require      http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js
// @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 mouseOver() {
  	var parentPos = $(parentClass).position()
  	childClass.style.left = Math.round(parentPos.left) + "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);
}

if (/\/id\//i.test (window.location.pathname)
   && !/\/inventory/i.test (window.location.pathname)
   && !/\/wishlist/i.test (window.location.pathname)
   && !/\/screenshots/i.test (window.location.pathname)
   && !/\/videos/i.test (window.location.pathname)
   && !/\/myworkshopfiles/i.test (window.location.pathname)
   && !/\/recommended/i.test (window.location.pathname))
{
    var y = document.body.innerHTML;
    y = y.split('","steamid":"').pop().split('","personaname"')[0];
    archUrl = 'https://steamcommunity.com/profiles/' + y
} else {
    var x = String(window.location)
    archUrl = x;
}

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]
}

$('<div style="position: absolute; z-index: 1500; opacity: 0; left: 300px; top: 64px; pointer-events: none;" class="supernav_content archive"><div class="submenu_archive" style="" data-submenuid="archive">' +
			'<a class="submenuitem" href="https://web.archive.org/save/' + archUrl + '" target="_blank" rel="noopener noreferrer">Archive this page</a>' +
			'<a class="submenuitem" href="https://web.archive.org/web/*/' + archUrl + '" target="_blank" rel="noopener noreferrer">View History</a></div></div>').insertAfter( $(".menuitem").last() );

$('<a class="menuitem archive" data-tooltip-type="selector" data-tooltip-content=".submenu_archive">ARCHIVE...</a>').insertAfter( $(".menuitem").last() );

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);