Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. // ==UserScript==
  2. // @name Badge List Links to Inventory
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description try to take over the world!
  6. // @author You
  7. // @match https://www.steamcardexchange.net/index.php?badgeprices
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. const COMMUNITY_LINK = /^https?:\/\/www\.steamcardexchange\.net\/index\.php\?gamepage-appid-(\d+)$/i;
  15. function replaceLink(a) {
  16. const matches = a.href.match(COMMUNITY_LINK);
  17. if(!matches)
  18. return;
  19. a.href = `https://www.steamcardexchange.net/index.php?inventorygame-appid-${matches[1]}`;
  20. }
  21. function replaceAllLinks() {
  22. for(const a of container.querySelectorAll(`
  23. a[href^="https://www.steamcardexchange.net/index.php?gamepage-appid-"],
  24. a[href^="http://www.steamcardexchange.net/index.php?gamepage-appid-"]
  25. `)) {
  26. replaceLink(a);
  27. }
  28. }
  29. const container = document.querySelector('#blotter_content');
  30.  
  31.  
  32. const observer = new MutationObserver(replaceAllLinks);
  33. observer.observe(container, {
  34. childList: true
  35. });
  36.  
  37. replaceAllLinks();
  38. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement