Quick link

deadfrontier-This is a convenience button script

当前为 2024-11-08 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Quick link
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.2
  5. // @description deadfrontier-This is a convenience button script
  6. // @author SHUNHK
  7. // @icon https://i.imgur.com/WKv8txW.jpeg
  8. // @match *fairview.deadfrontier.com/onlinezombiemmo/index.php*
  9. // @match *fairview.deadfrontier.com/onlinezombiemmo/
  10. // @license LGPL License
  11. // @downloadURL
  12. // @updateURL
  13. // ==/UserScript==
  14.  
  15. (function() {
  16. 'use strict';
  17.  
  18. console.log('Script started');
  19.  
  20. //
  21. var container = createButtonContainer();
  22. document.body.appendChild(container);
  23.  
  24. //
  25. function setCustomPosition(container) {
  26. if (window.innerWidth <= 960) { //
  27. container.style.top = '600px';
  28. container.style.right = '715px';
  29. } else { //
  30. container.style.top = '230px';
  31. container.style.right = '380px';
  32. }
  33. }
  34.  
  35. //
  36. setCustomPosition(container);
  37.  
  38. //
  39. window.addEventListener('resize', function() {
  40. setCustomPosition(container);
  41. });
  42.  
  43. //
  44. addRainbowAnimation();
  45.  
  46. function createButtonContainer() {
  47. var container = document.createElement('div');
  48. container.style.position = 'fixed';
  49. container.style.top = '200px'; //
  50. container.style.right = '380px'; //
  51. container.style.zIndex = '1000';
  52. container.style.backgroundImage = 'url("https://i.imgur.com/HW8B3sf.jpeg")';
  53. container.style.backgroundSize = 'cover';
  54. container.style.padding = '8px';
  55. container.style.borderRadius = '50px';
  56. container.style.display = 'flex';
  57. container.style.flexDirection = 'column';
  58. container.style.gap = '5px';
  59. container.style.width = '60px'; //
  60. container.style.height = 'auto'; //
  61.  
  62. console.log('Container created');
  63.  
  64. var buttons = [
  65. { name: 'Travel', link: 'https://fairview.deadfrontier.com/onlinezombiemmo/index.php?page=61' },
  66. { name: 'Craft', link: 'https://fairview.deadfrontier.com/onlinezombiemmo/index.php?page=59' },
  67. { name: 'Game', link: 'https://fairview.deadfrontier.com/onlinezombiemmo/index.php?page=49' },
  68. { name: 'Venditron', link: 'https://fairview.deadfrontier.com/onlinezombiemmo/index.php?page=84' },
  69. { name: 'Profile', link: 'https://fairview.deadfrontier.com/onlinezombiemmo/index.php?action=profile' },
  70. { name: 'Marke', link: 'https://fairview.deadfrontier.com/onlinezombiemmo/index.php?page=35' },
  71. { name: 'Bank', link: 'https://fairview.deadfrontier.com/onlinezombiemmo/index.php?page=15' },
  72. { name: 'Storage', link: 'https://fairview.deadfrontier.com/onlinezombiemmo/index.php?page=50' },
  73. { name: 'Yard', link: 'https://fairview.deadfrontier.com/onlinezombiemmo/index.php?page=24' },
  74. { name: 'OP', link: 'https://fairview.deadfrontier.com/onlinezombiemmo/index.php?page=0' },
  75. ];
  76.  
  77. buttons.forEach(function(buttonInfo) {
  78. createQuickNavigationButton(container, buttonInfo.name, buttonInfo.link);
  79. });
  80.  
  81. //
  82. createMoveButton(container);
  83.  
  84. return container;
  85. }
  86.  
  87. function createQuickNavigationButton(container, buttonTitle, url) {
  88. let button = document.createElement("button");
  89. button.textContent = buttonTitle;
  90. button.id = buttonTitle;
  91. button.style.height = "max-content";
  92. button.classList.add("nav-button");
  93. button.addEventListener("click", function() {
  94. window.location.href = url;
  95. });
  96. button.addEventListener('mouseover', function() {
  97. button.style.animation = 'rainbow 3s infinite';
  98. });
  99. button.addEventListener('mouseout', function() {
  100. button.style.animation = '';
  101. });
  102. container.appendChild(button);
  103. }
  104.  
  105. function createMoveButton(container) {
  106. let moveButton = document.createElement("button");
  107. moveButton.textContent = "move";
  108. moveButton.style.padding = '10px';
  109. moveButton.style.border = 'none';
  110. moveButton.style.borderRadius = '5px';
  111. moveButton.style.backgroundColor = '#28a745';
  112. moveButton.style.color = 'white';
  113. moveButton.style.cursor = 'pointer';
  114. moveButton.addEventListener('mousedown', function(e) {
  115. var offsetX = e.clientX - container.getBoundingClientRect().left;
  116. var offsetY = e.clientY - container.getBoundingClientRect().top;
  117.  
  118. function mouseMoveHandler(e) {
  119. container.style.left = `${e.clientX - offsetX}px`;
  120. container.style.top = `${e.clientY - offsetY}px`;
  121. }
  122.  
  123. function mouseUpHandler() {
  124. document.removeEventListener('mousemove', mouseMoveHandler);
  125. document.removeEventListener('mouseup', mouseUpHandler);
  126. }
  127.  
  128. document.addEventListener('mousemove', mouseMoveHandler);
  129. document.addEventListener('mouseup', mouseUpHandler);
  130. });
  131. container.appendChild(moveButton);
  132. }
  133.  
  134. function addRainbowAnimation() {
  135. var style = document.createElement('style');
  136. style.innerHTML = `
  137. @keyframes rainbow {
  138. 0% { background-color: red; }
  139. 14% { background-color: orange; }
  140. 28% { background-color: yellow; }
  141. 42% { background-color: green; }
  142. 57% { background-color: blue; }
  143. 71% { background-color: indigo; }
  144. 85% { background-color: violet; }
  145. 100% { background-color: red; }
  146. }
  147. .rainbow-animation {
  148. animation: rainbow 3s infinite;
  149. }
  150. .move-button {
  151. padding: 10px;
  152. border: none;
  153. border-radius: 5px;
  154. background-color: #28a745;
  155. color: white;
  156. cursor: pointer;
  157. }
  158. `;
  159. document.head.appendChild(style);
  160. }
  161.  
  162.  
  163.  
  164. })();