Last active
December 20, 2020 13:50
-
-
Save jethroo/bf97e0dafaeb7377d452c07b235438aa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Bricklink Catalog Page link to MyInventory | |
// @version 3 | |
// @grant none | |
// ==/UserScript== | |
var addToInventory = document.getElementById('_idAddToMyInvLink'); | |
if (addToInventory) { | |
var searchLink = addToInventory.href.replace('inventory_add','inventory_detail').replace('itemId=','q='); | |
var newLink = "<br/><strong><a href='" + searchLink +"&invNew=N' target='_blank'>✨ MyInventory NEW</a></strong>"; | |
var usedLink = "<br/><br/><strong><a href='" + searchLink +"&invNew=U' target='_blank'>⚽ MyInventory USED</a></strong>"; | |
var currentItem = RegExp('[?&]P=([^&]*)').exec(window.location.search); | |
var decoratedSearchUrl = window.location.origin + '/v2/search.page?q=' + currentItem[1] + "*"; | |
var decoratedLink = "<br/><br/><strong><a href='" + decoratedSearchUrl +"' target='_blank'>🖼️ search decorated</a></strong>"; | |
addToInventory.parentNode.innerHTML += newLink + usedLink + decoratedLink; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment