Calm Code 2.0

Calm Code Helper

  1. // ==UserScript==
  2. // @name Calm Code 2.0
  3. // @namespace http://tampermonkey.net/
  4. // @version 2024-04-02.3.2
  5. // @description Calm Code Helper
  6. // @author xabdaziz
  7. // @match https://fcmenu-dub-regionalized.corp.amazon.com/CDG7/laborTrackingKiosk
  8. // @match https://fcmenu-dub-regionalized.corp.amazon.com/CDG7/calmCode
  9. // @icon https://www.google.com/s2/favicons?sz=64&domain=amazon.com
  10. // @grant none
  11. // @license AzAbd
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. 'use strict';
  16.  
  17. const style = document.createElement('style');
  18. style.textContent = `
  19. .button-container {
  20. position: relative;
  21. display: flex;
  22. align-items: center;
  23. margin: 2px;
  24. }
  25. .code-button {
  26. display: flex;
  27. justify-content: space-between;
  28. align-items: center;
  29. width: 100%;
  30. padding: 6px 10px;
  31. margin: 0;
  32. }
  33. .code-text {
  34. color: #FFD700;
  35. font-weight: bold;
  36. }
  37. .code-label {
  38. margin-left: 10px;
  39. color: #98FB98;
  40. font-size: 11px;
  41. }
  42.  
  43. .category-inbound .code-text,
  44. .category-training .code-text {
  45. color: #000000;
  46. }
  47. .category-inbound .code-label,
  48. .category-training .code-label {
  49. color: #FFFFFF;
  50. }
  51. `;
  52. document.head.appendChild(style);
  53.  
  54. const categories = [
  55. {
  56. name: "Inbound",
  57. color: "#FF9900",
  58. codes: [
  59. { code: "ICQAPS", label: "Dock/JPE/Corral/Bras-KO" },
  60. { code: "ICQAPSR", label: "NPC/RCV/DCT/PREP" },
  61. { code: "ICQAPST", label: "MFI/TTO/TTF/TTH" },
  62. { code: "QARSH", label: "IOL/Authors" }
  63. ]
  64. },
  65. {
  66. name: "Outbound",
  67. color: "#01B0F1",
  68. codes: [
  69. { code: "ICQAPSO", label: "SORT" },
  70. { code: "PSRSPS", label: "UIS" },
  71. { code: "PSTOPS", label: "MP/RP" },
  72. { code: "PSRPPS", label: "JPW/ATAC" }
  73. ]
  74. },
  75. {
  76. name: "ICQA",
  77. color: "#146EB4",
  78. codes: [
  79. { code: "ICQDMP", label: "DMG Processing" },
  80. { code: "ICQADMP", label: "Recolte DMG" },
  81. { code: "ICQAQA", label: "AUDIT" },
  82. { code: "AUDITPC", label: "Pallet Defect Capture" }
  83. ]
  84. },
  85. {
  86. name: "Training",
  87. color: "#FF9900",
  88. codes: [
  89. { code: "ICQATR", label: "ICQA Peer Trainer" },
  90. { code: "ICQAIC", label: "ICQA Trainee" }
  91. ]
  92. },
  93. {
  94. name: "Other",
  95. color: "#37475A",
  96. codes: [
  97. { code: "FACJAN", label: "Facility Janitorial" },
  98. { code: "ICQA5S", label: "5S" },
  99. { code: "OPSEMPENG", label: "Engagement" },
  100. { code: "ICQALQA", label: "LEAD" }
  101. ]
  102. }
  103. ];
  104.  
  105. function createButton(codeObj, color, categoryName) {
  106. const buttonContainer = document.createElement('div');
  107. buttonContainer.className = `button-container category-${categoryName.toLowerCase()}`;
  108.  
  109. const button = document.createElement('button');
  110. button.className = 'code-button';
  111. button.style.cssText = `
  112. border: none;
  113. border-radius: 4px;
  114. background-color: ${color};
  115. cursor: pointer;
  116. font-size: 11px;
  117. transition: all 0.3s;
  118. width: 100%;
  119. text-align: left;
  120. `;
  121.  
  122. const codeSpan = document.createElement('span');
  123. codeSpan.className = 'code-text';
  124. codeSpan.textContent = codeObj.code;
  125. const labelSpan = document.createElement('span');
  126. labelSpan.className = 'code-label';
  127. labelSpan.textContent = codeObj.label;
  128.  
  129. button.appendChild(codeSpan);
  130. button.appendChild(labelSpan);
  131.  
  132. button.addEventListener('mouseover', () => button.style.transform = 'scale(1.05)');
  133. button.addEventListener('mouseout', () => button.style.transform = 'scale(1)');
  134. button.addEventListener('click', () => {
  135. const input = document.querySelector('#calmCode');
  136. if (input) {
  137. input.value = codeObj.code;
  138. const form = input.closest('form');
  139. if (form) form.submit();
  140. }
  141. });
  142.  
  143. buttonContainer.appendChild(button);
  144. return buttonContainer;
  145. }
  146.  
  147. function toggleCategory(categoryDiv, buttonsDiv) {
  148. const isExpanded = buttonsDiv.style.display !== 'none';
  149. buttonsDiv.style.display = isExpanded ? 'none' : 'flex';
  150. categoryDiv.querySelector('.toggle-icon').textContent = isExpanded ? '+' : '-';
  151. }
  152.  
  153. const container = document.createElement('div');
  154. container.style.cssText = `
  155. position: absolute;
  156. top: 50%;
  157. left: 20px;
  158. transform: translateY(-50%);
  159. background: #232F3E;
  160. padding: 12px;
  161. border-radius: 8px;
  162. box-shadow: 0 0 15px rgba(0,0,0,0.3);
  163. display: flex;
  164. flex-direction: column;
  165. gap: 10px;
  166. z-index: 9999;
  167. font-family: Amazon Ember, Arial, sans-serif;
  168. font-size: 12px;
  169. min-width: 300px;
  170. `;
  171.  
  172. categories.forEach(category => {
  173. const categoryDiv = document.createElement('div');
  174. categoryDiv.style.cssText = `
  175. display: flex;
  176. flex-direction: column;
  177. gap: 6px;
  178. `;
  179.  
  180. const categoryHeader = document.createElement('div');
  181. categoryHeader.style.cssText = `
  182. display: flex;
  183. align-items: center;
  184. cursor: pointer;
  185. user-select: none;
  186. padding: 4px 0;
  187. border-bottom: 2px solid #FF9900;
  188. `;
  189.  
  190. const toggleIcon = document.createElement('span');
  191. toggleIcon.textContent = '+';
  192. toggleIcon.className = 'toggle-icon';
  193. toggleIcon.style.cssText = `
  194. color: #FFFFFF;
  195. margin-right: 8px;
  196. font-weight: bold;
  197. font-size: 16px;
  198. width: 15px;
  199. `;
  200.  
  201. const categoryTitle = document.createElement('span');
  202. categoryTitle.textContent = category.name;
  203. categoryTitle.style.cssText = `
  204. font-weight: bold;
  205. color: #FFFFFF;
  206. font-size: 13px;
  207. `;
  208.  
  209. const buttonsDiv = document.createElement('div');
  210. buttonsDiv.style.cssText = `
  211. display: none;
  212. flex-direction: column;
  213. gap: 6px;
  214. margin-top: 6px;
  215. `;
  216.  
  217. categoryHeader.appendChild(toggleIcon);
  218. categoryHeader.appendChild(categoryTitle);
  219. categoryDiv.appendChild(categoryHeader);
  220.  
  221. category.codes.forEach(codeObj => {
  222. buttonsDiv.appendChild(createButton(codeObj, category.color, category.name));
  223. });
  224.  
  225. categoryDiv.appendChild(buttonsDiv);
  226.  
  227. categoryHeader.addEventListener('click', () => toggleCategory(categoryDiv, buttonsDiv));
  228.  
  229. container.appendChild(categoryDiv);
  230. });
  231.  
  232. document.body.appendChild(container);
  233. })();