Bricklink - Add Brickset instructions link

7/12/2023, 11:51:54 AM

// ==UserScript==
// @name        Bricklink - Add Brickset instructions link
// @namespace   Violentmonkey Scripts
// @match       https://www.bricklink.com/v2/catalog/catalogitem.page
// @grant       none
// @version     1.0
// @author      legendeveryone
// @description 7/12/2023, 11:51:54 AM
// @run-at      document-end
// @license     MIT
// ==/UserScript==

(function () {

  let urlElement = document.querySelector("div.innercontent table tbody tr td").lastChild.textContent.replace(": ","");
  let link = "https://brickset.com/sets/" + urlElement;
  var node = document.getElementById("_idPriceGuideLink");
  let copy = node.cloneNode(true);

  copy.firstChild.setAttribute("id", "bricksetLink");
  copy.firstChild.setAttribute("href", link);
  copy.firstChild.setAttribute("rel", "noopener noreferrer");
  copy.firstChild.setAttribute("target", "_blank");
  copy.firstChild.innerText = "Instructions on BrickSet";

  node.parentElement.appendChild(copy);

})();