Add marketplace button

Replaces inventory button with yard button

当前为 2025-05-08 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Add marketplace button
  3. // @namespace http://tampermonkey.net/
  4. // @version 2025-05-08
  5. // @description Replaces inventory button with yard button
  6. // @author Disk217
  7. // @match *://fairview.deadfrontier.com/onlinezombiemmo/index.php*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=deadfrontier.com
  9. // @license MIT
  10. // @grant none
  11. // @noframes
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. 'use strict';
  16.  
  17. function waitForElement(id, callback) {
  18. const interval = setInterval(function() {
  19. const element = document.getElementById(id);
  20. if (element && callback(element)) {
  21. clearInterval(interval);
  22.  
  23. }
  24. }, 100); // Check every 100ms
  25. }
  26.  
  27. waitForElement("sidebar", function(elem) {
  28. try {
  29. const bar = elem.childNodes[1]
  30. const marketplace = document.createElement("a")
  31. marketplace.textContent = "Marketplace"
  32. marketplace.href = "index.php?page=35"
  33. const br = document.createElement("br")
  34. bar.appendChild(br)
  35. bar.appendChild(marketplace)
  36. } catch(e) {
  37. return false
  38. }
  39. return true
  40. })
  41.  
  42.  
  43.  
  44.  
  45. })();