DHM Desktop Notifications

Desktop Notifications for DHM

目前為 2023-10-25 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name DHM Desktop Notifications
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.0
  5. // @description Desktop Notifications for DHM
  6. // @author level
  7. // @match https://dhm.idle-pixel.com/
  8. // @run-at document-idle
  9. // @grant none
  10. // @license MIT
  11. // ==/UserScript==
  12. var VERSION_NUMBER = "1.0";
  13.  
  14. window.addEventListener("load", function() {
  15. console.log('Loading DHM Helper...');
  16. var loaded = false;
  17. loading();
  18. var Hinterval = setInterval(loading, 100);
  19.  
  20. function loading() {
  21. if (loaded === false) {
  22. console.log("Loaded DHM Helper");
  23. loaded = true;
  24. addStyles();
  25. createNav();
  26. createMenu();
  27. init();
  28. }
  29. }
  30. function addStyles() {
  31. let style = document.createElement('style');
  32. style.innerHTML = `
  33. #dhm-helper-menu {
  34. position: absolute;
  35. background: white;
  36. width: 700px;
  37. height: 777px;
  38. max-width: 100%;
  39. max-height: 100%;
  40. z-index: 10000;
  41. top: 50%;
  42. left: 50%;
  43. transform: translate(-50%, -50%);
  44. box-shadow: black 0 0 15px 1px;
  45. overflow-y: auto;
  46. }
  47. #dhm-helper-menu h1, #dhm-helper-menu span, #dhm-helper-menu p {
  48. color: black;
  49. text-align: center;
  50. }
  51. #dhm-helper-menu h1 img {
  52. margin: 0 10px 0 10px;
  53. }
  54. #dhm-helper-menu h1 img:nth-child(1) {
  55. transform: scaleX(-1);
  56. }
  57. .dhm-helper-headerContainer {
  58. text-align: center;
  59. }
  60. #dhm-helper-menu hr {
  61. background-color: #e0e0e0;
  62. width: 100%;
  63. }
  64. .dhm-helper-inputContainer {
  65. max-width: 400px;
  66. margin: 0 auto;
  67. height: 40px;
  68. display: flex;
  69. justify-content: space-between;
  70. align-items: center;
  71. }
  72. .dhm-helper-inputContainer input[type="checkbox"] {
  73. width: 20px;
  74. height: 20px;
  75. }
  76. .dhm-helper-inputContainer-sub input[type="checkbox"] {
  77. margin-left: 25px;
  78. }
  79. .dhm-helper-inputContainer-sub-sub input[type="checkbox"] {
  80. margin-left: 50px;
  81. }
  82. .dhm-helper-inputContainer label {
  83. color: black;
  84. font-size: 20px;
  85. }
  86. #dhm-helper-menu span {
  87. color: #5a5a5a;
  88. padding: 5px;
  89. }
  90. .dialogue-button {
  91. border:1px solid silver;
  92. background-color:#e6e6e6;
  93. border-radius:3pt;
  94. color:black;
  95. font-size:14pt;
  96. text-align:center;
  97. cursor:pointer;
  98. padding:10px;
  99. }`;
  100. document.head.appendChild(style);
  101. }
  102.  
  103. function createNav() {
  104. let navItem = document.createElement('div');
  105. let miscTab = document.querySelectorAll("#tab-misc > .main-button");
  106. navItem.innerHTML = `<div onclick="window.toggleMenu2()" class="main-button" style="cursor: pointer;">
  107. <table>
  108. <tbody><tr>
  109. <td><img src="images/bronzeStarLamp.png" class="img-small"></td>
  110. <td style="text-align:right;padding-right:20px;font-size:12pt;">DESKTOP NOTFICATIONS</td>
  111. </tr>
  112. </tbody></table>
  113. </div>`;
  114. miscTab[2].parentNode.insertBefore(navItem,miscTab[3]);
  115. }
  116.  
  117. function createMenu() {
  118. let menu = document.createElement('div');
  119. menu.setAttribute('id', 'dhm-helper-menu');
  120. menu.style.display = 'none';
  121. let closeButton = document.createElement('div');
  122. closeButton.setAttribute('class', 'dialogue-button');
  123. closeButton.innerText = "Close";
  124. closeButton.addEventListener('click', toggleMenu)
  125. menu.appendChild(closeButton);
  126.  
  127. let headerContainer = document.createElement('div');
  128. headerContainer.setAttribute('class', 'dhm-helper-headerContainer');
  129.  
  130. let header = document.createElement('h1');
  131. let headerImage = document.createElement('img');
  132. headerImage.setAttribute('src', 'images/bronzeStarLamp.png');
  133. headerImage.setAttribute('class', 'img-medium');
  134. let headerImage2 = headerImage.cloneNode(true);
  135. header.innerText = "DHM Helper";
  136. header.insertBefore(headerImage, header.firstChild);
  137. header.appendChild(headerImage2);
  138. headerContainer.appendChild(header);
  139.  
  140. let version = document.createElement('span');
  141. version.innerText = "Version: " + VERSION_NUMBER;
  142. headerContainer.appendChild(version);
  143. menu.appendChild(headerContainer);
  144. let hr = document.createElement('hr');
  145. menu.appendChild(hr);
  146. // Global Notifications Checkbox
  147. let notificationsInputContainer = document.createElement('div');
  148. notificationsInputContainer.setAttribute('class', 'dhm-helper-inputContainer');
  149. let notificationsInput = document.createElement('input');
  150. notificationsInput.setAttribute('type', 'checkbox');
  151. notificationsInput.setAttribute('name', 'dhm-notificationsInput');
  152. notificationsInput.setAttribute('data-storage', 'hNotifications');
  153. if (localStorage.hNotifications === "true") {
  154. notificationsInput.setAttribute('checked', 'checked');
  155. }
  156. notificationsInput.addEventListener("change", grantNotifications);
  157. let notificationsLabel = document.createElement('label');
  158. notificationsLabel.setAttribute('for', 'checkbox');
  159. notificationsLabel.innerText = "Desktop Notifications";
  160.  
  161. notificationsInputContainer.append(notificationsInput);
  162. notificationsInputContainer.append(notificationsLabel);
  163.  
  164. menu.appendChild(notificationsInputContainer);
  165.  
  166. // Daily Mission Notifications Checkbox
  167. let dailyInputContainer = document.createElement('div');
  168. dailyInputContainer.setAttribute('class', 'dhm-helper-inputContainer dhm-helper-inputContainer-sub');
  169. let dailyInput = document.createElement('input');
  170. dailyInput.setAttribute('type', 'checkbox');
  171. dailyInput.setAttribute('name', 'dhm-notificationsInput');
  172. dailyInput.setAttribute('data-storage', 'hDaily');
  173. if (localStorage.hDaily === "true") {
  174. dailyInput.setAttribute('checked', 'checked');
  175. }
  176. dailyInput.addEventListener("change", toggleStorage);
  177. let dailyLabel = document.createElement('label');
  178. dailyLabel.setAttribute('for', 'checkbox');
  179. dailyLabel.innerText = "Daily Mission Notifications";
  180.  
  181. dailyInputContainer.append(dailyInput);
  182. dailyInputContainer.append(dailyLabel);
  183.  
  184. menu.appendChild(dailyInputContainer);
  185.  
  186. // Treasure Map Notifications Checkbox
  187. let mapInputContainer = document.createElement('div');
  188. mapInputContainer.setAttribute('class', 'dhm-helper-inputContainer dhm-helper-inputContainer-sub');
  189. let mapInput = document.createElement('input');
  190. mapInput.setAttribute('type', 'checkbox');
  191. mapInput.setAttribute('name', 'dhm-notificationsInput');
  192. mapInput.setAttribute('data-storage', 'hMap');
  193. if (localStorage.hMap === "true") {
  194. mapInput.setAttribute('checked', 'checked');
  195. }
  196. mapInput.addEventListener("change", toggleStorage);
  197. let mapLabel = document.createElement('label');
  198. mapLabel.setAttribute('for', 'checkbox');
  199. mapLabel.innerText = "Treasure Map Notifications";
  200.  
  201. mapInputContainer.append(mapInput);
  202. mapInputContainer.append(mapLabel);
  203.  
  204. menu.appendChild(mapInputContainer);
  205.  
  206. // Event Notifications Checkbox
  207. let eventInputContainer = document.createElement('div');
  208. eventInputContainer.setAttribute('class', 'dhm-helper-inputContainer dhm-helper-inputContainer-sub');
  209. let eventInput = document.createElement('input');
  210. eventInput.setAttribute('type', 'checkbox');
  211. eventInput.setAttribute('name', 'dhm-notificationsInput');
  212. eventInput.setAttribute('data-storage', 'hEvent');
  213. if (localStorage.hEvent === "true") {
  214. eventInput.setAttribute('checked', 'checked');
  215. }
  216. eventInput.addEventListener("change", toggleStorage);
  217. let eventLabel = document.createElement('label');
  218. eventLabel.setAttribute('for', 'checkbox');
  219. eventLabel.innerText = "Event Notifications";
  220.  
  221. eventInputContainer.append(eventInput);
  222. eventInputContainer.append(eventLabel);
  223.  
  224. menu.appendChild(eventInputContainer);
  225.  
  226. // Research Notifications Checkbox
  227. let researchInputContainer = document.createElement('div');
  228. researchInputContainer.setAttribute('class', 'dhm-helper-inputContainer dhm-helper-inputContainer-sub');
  229. let researchInput = document.createElement('input');
  230. researchInput.setAttribute('type', 'checkbox');
  231. researchInput.setAttribute('name', 'dhm-notificationsInput');
  232. researchInput.setAttribute('data-storage', 'hResearch');
  233. if (localStorage.hResearch === "true") {
  234. researchInput.setAttribute('checked', 'checked');
  235. }
  236. researchInput.addEventListener("change", toggleStorage);
  237. let researchLabel = document.createElement('label');
  238. researchLabel.setAttribute('for', 'checkbox');
  239. researchLabel.innerText = "Research Notifications";
  240.  
  241. researchInputContainer.append(researchInput);
  242. researchInputContainer.append(researchLabel);
  243.  
  244. menu.appendChild(researchInputContainer);
  245.  
  246. // Train Notifications Checkbox
  247. let trainInputContainer = document.createElement('div');
  248. trainInputContainer.setAttribute('class', 'dhm-helper-inputContainer dhm-helper-inputContainer-sub');
  249. let trainInput = document.createElement('input');
  250. trainInput.setAttribute('type', 'checkbox');
  251. trainInput.setAttribute('name', 'dhm-notificationsInput');
  252. trainInput.setAttribute('data-storage', 'hTrain');
  253. if (localStorage.hTrain === "true") {
  254. trainInput.setAttribute('checked', 'checked');
  255. }
  256. trainInput.addEventListener("change", toggleStorage);
  257. let trainLabel = document.createElement('label');
  258. trainLabel.setAttribute('for', 'checkbox');
  259. trainLabel.innerText = "Train Notifications";
  260.  
  261. trainInputContainer.append(trainInput);
  262. trainInputContainer.append(trainLabel);
  263.  
  264. menu.appendChild(trainInputContainer);
  265.  
  266. // Rocket Notifications Checkbox
  267. let rocketInputContainer = document.createElement('div');
  268. rocketInputContainer.setAttribute('class', 'dhm-helper-inputContainer dhm-helper-inputContainer-sub');
  269. let rocketInput = document.createElement('input');
  270. rocketInput.setAttribute('type', 'checkbox');
  271. rocketInput.setAttribute('name', 'dhm-notificationsInput');
  272. rocketInput.setAttribute('data-storage', 'hRocket');
  273. if (localStorage.hRocket === "true") {
  274. rocketInput.setAttribute('checked', 'checked');
  275. }
  276. rocketInput.addEventListener("change", toggleStorage);
  277. let rocketLabel = document.createElement('label');
  278. rocketLabel.setAttribute('for', 'checkbox');
  279. rocketLabel.innerText = "Rocket Notifications";
  280.  
  281. rocketInputContainer.append(rocketInput);
  282. rocketInputContainer.append(rocketLabel);
  283.  
  284. menu.appendChild(rocketInputContainer);
  285.  
  286. // Furnace Notifications Checkbox
  287. let furnaceInputContainer = document.createElement('div');
  288. furnaceInputContainer.setAttribute('class', 'dhm-helper-inputContainer dhm-helper-inputContainer-sub');
  289. let furnaceInput = document.createElement('input');
  290. furnaceInput.setAttribute('type', 'checkbox');
  291. furnaceInput.setAttribute('name', 'dhm-notificationsInput');
  292. furnaceInput.setAttribute('data-storage', 'hFurnace');
  293. if (localStorage.hFurnace === "true") {
  294. furnaceInput.setAttribute('checked', 'checked');
  295. }
  296. furnaceInput.addEventListener("change", toggleStorage);
  297. let furnaceLabel = document.createElement('label');
  298. furnaceLabel.setAttribute('for', 'checkbox');
  299. furnaceLabel.innerText = "Furnace Notifications";
  300.  
  301. furnaceInputContainer.append(furnaceInput);
  302. furnaceInputContainer.append(furnaceLabel);
  303.  
  304. menu.appendChild(furnaceInputContainer);
  305.  
  306. // Foundry Notifications Checkbox
  307. let foundryInputContainer = document.createElement('div');
  308. foundryInputContainer.setAttribute('class', 'dhm-helper-inputContainer dhm-helper-inputContainer-sub');
  309. let foundryInput = document.createElement('input');
  310. foundryInput.setAttribute('type', 'checkbox');
  311. foundryInput.setAttribute('name', 'dhm-notificationsInput');
  312. foundryInput.setAttribute('data-storage', 'hFoundry');
  313. if (localStorage.hFoundry === "true") {
  314. foundryInput.setAttribute('checked', 'checked');
  315. }
  316. foundryInput.addEventListener("change", toggleStorage);
  317. let foundryLabel = document.createElement('label');
  318. foundryLabel.setAttribute('for', 'checkbox');
  319. foundryLabel.innerText = "Foundry Notifications";
  320.  
  321. foundryInputContainer.append(foundryInput);
  322. foundryInputContainer.append(foundryLabel);
  323.  
  324. menu.appendChild(foundryInputContainer);
  325.  
  326. // Refinary Notifications Checkbox
  327. let refinaryInputContainer = document.createElement('div');
  328. refinaryInputContainer.setAttribute('class', 'dhm-helper-inputContainer dhm-helper-inputContainer-sub');
  329. let refinaryInput = document.createElement('input');
  330. refinaryInput.setAttribute('type', 'checkbox');
  331. refinaryInput.setAttribute('name', 'dhm-notificationsInput');
  332. refinaryInput.setAttribute('data-storage', 'hRefinary');
  333. if (localStorage.hRefinary === "true") {
  334. refinaryInput.setAttribute('checked', 'checked');
  335. }
  336. refinaryInput.addEventListener("change", toggleStorage);
  337. let refinaryLabel = document.createElement('label');
  338. refinaryLabel.setAttribute('for', 'checkbox');
  339. refinaryLabel.innerText = "Refinary Notifications";
  340.  
  341. refinaryInputContainer.append(refinaryInput);
  342. refinaryInputContainer.append(refinaryLabel);
  343.  
  344. menu.appendChild(refinaryInputContainer);
  345.  
  346. // Tree Notifications Checkbox
  347. let treeInputContainer = document.createElement('div');
  348. treeInputContainer.setAttribute('class', 'dhm-helper-inputContainer dhm-helper-inputContainer-sub');
  349. let treeInput = document.createElement('input');
  350. treeInput.setAttribute('type', 'checkbox');
  351. treeInput.setAttribute('name', 'dhm-notificationsInput');
  352. treeInput.setAttribute('data-storage', 'hTree');
  353. if (localStorage.hTree === "true") {
  354. treeInput.setAttribute('checked', 'checked');
  355. }
  356. treeInput.addEventListener("change", toggleStorage);
  357. let treeLabel = document.createElement('label');
  358. treeLabel.setAttribute('for', 'checkbox');
  359. treeLabel.innerText = "Tree Notifications";
  360.  
  361. treeInputContainer.append(treeInput);
  362. treeInputContainer.append(treeLabel);
  363.  
  364. menu.appendChild(treeInputContainer);
  365.  
  366. // Planter Notifications Checkbox
  367. let planterInputContainer = document.createElement('div');
  368. planterInputContainer.setAttribute('class', 'dhm-helper-inputContainer dhm-helper-inputContainer-sub');
  369. let planterInput = document.createElement('input');
  370. planterInput.setAttribute('type', 'checkbox');
  371. planterInput.setAttribute('name', 'dhm-notificationsInput');
  372. planterInput.setAttribute('data-storage', 'hPlanter');
  373. if (localStorage.hPlanter === "true") {
  374. planterInput.setAttribute('checked', 'checked');
  375. }
  376. planterInput.addEventListener("change", toggleStorage);
  377. let planterLabel = document.createElement('label');
  378. planterLabel.setAttribute('for', 'checkbox');
  379. planterLabel.innerText = "Planter Notifications";
  380.  
  381. planterInputContainer.append(planterInput);
  382. planterInputContainer.append(planterLabel);
  383.  
  384. menu.appendChild(planterInputContainer);
  385.  
  386. // Explorer Notifications Checkbox
  387. let explorerInputContainer = document.createElement('div');
  388. explorerInputContainer.setAttribute('class', 'dhm-helper-inputContainer dhm-helper-inputContainer-sub');
  389. let explorerInput = document.createElement('input');
  390. explorerInput.setAttribute('type', 'checkbox');
  391. explorerInput.setAttribute('name', 'dhm-notificationsInput');
  392. explorerInput.setAttribute('data-storage', 'hExplorer');
  393. if (localStorage.hExplorer === "true") {
  394. explorerInput.setAttribute('checked', 'checked');
  395. }
  396. explorerInput.addEventListener("change", toggleStorage);
  397. let explorerLabel = document.createElement('label');
  398. explorerLabel.setAttribute('for', 'checkbox');
  399. explorerLabel.innerText = "Explorer Notifications";
  400.  
  401. explorerInputContainer.append(explorerInput);
  402. explorerInputContainer.append(explorerLabel);
  403.  
  404. menu.appendChild(explorerInputContainer);
  405.  
  406. // Cousin Notifications Checkbox
  407. let cousinInputContainer = document.createElement('div');
  408. cousinInputContainer.setAttribute('class', 'dhm-helper-inputContainer dhm-helper-inputContainer-sub');
  409. let cousinInput = document.createElement('input');
  410. cousinInput.setAttribute('type', 'checkbox');
  411. cousinInput.setAttribute('name', 'dhm-notificationsInput');
  412. cousinInput.setAttribute('data-storage', 'hCousin');
  413. if (localStorage.hCousin === "true") {
  414. cousinInput.setAttribute('checked', 'checked');
  415. }
  416. cousinInput.addEventListener("change", toggleStorage);
  417. let cousinLabel = document.createElement('label');
  418. cousinLabel.setAttribute('for', 'checkbox');
  419. cousinLabel.innerText = "Cousin Notifications";
  420.  
  421. cousinInputContainer.append(cousinInput);
  422. cousinInputContainer.append(cousinLabel);
  423.  
  424. menu.appendChild(cousinInputContainer);
  425.  
  426. // Boat Notifications Checkbox
  427. let boatInputContainer = document.createElement('div');
  428. boatInputContainer.setAttribute('class', 'dhm-helper-inputContainer dhm-helper-inputContainer-sub');
  429. let boatInput = document.createElement('input');
  430. boatInput.setAttribute('type', 'checkbox');
  431. boatInput.setAttribute('name', 'dhm-notificationsInput');
  432. boatInput.setAttribute('data-storage', 'hBoat');
  433. if (localStorage.hBoat === "true") {
  434. boatInput.setAttribute('checked', 'checked');
  435. }
  436. boatInput.addEventListener("change", toggleStorage);
  437. let boatLabel = document.createElement('label');
  438. boatLabel.setAttribute('for', 'checkbox');
  439. boatLabel.innerText = "Boat Notifications";
  440.  
  441. boatInputContainer.append(boatInput);
  442. boatInputContainer.append(boatLabel);
  443.  
  444. menu.appendChild(boatInputContainer);
  445.  
  446. // Chef Notifications Checkbox
  447. let chefInputContainer = document.createElement('div');
  448. chefInputContainer.setAttribute('class', 'dhm-helper-inputContainer dhm-helper-inputContainer-sub');
  449. let chefInput = document.createElement('input');
  450. chefInput.setAttribute('type', 'checkbox');
  451. chefInput.setAttribute('name', 'dhm-notificationsInput');
  452. chefInput.setAttribute('data-storage', 'hChef');
  453. if (localStorage.hChef === "true") {
  454. chefInput.setAttribute('checked', 'checked');
  455. }
  456. chefInput.addEventListener("change", toggleStorage);
  457. let chefLabel = document.createElement('label');
  458. chefLabel.setAttribute('for', 'checkbox');
  459. chefLabel.innerText = "Chef Notifications";
  460.  
  461. chefInputContainer.append(chefInput);
  462. chefInputContainer.append(chefLabel);
  463.  
  464. menu.appendChild(chefInputContainer);
  465.  
  466. // Goblin Shop Notifications Checkbox
  467. let goblinShopInputContainer = document.createElement('div');
  468. goblinShopInputContainer.setAttribute('class', 'dhm-helper-inputContainer dhm-helper-inputContainer-sub');
  469. let goblinShopInput = document.createElement('input');
  470. goblinShopInput.setAttribute('type', 'checkbox');
  471. goblinShopInput.setAttribute('name', 'dhm-notificationsInput');
  472. goblinShopInput.setAttribute('data-storage', 'hGoblinShop');
  473. if (localStorage.hGoblinShop === "true") {
  474. goblinShopInput.setAttribute('checked', 'checked');
  475. }
  476. goblinShopInput.addEventListener("change", toggleStorage);
  477. let goblinShopLabel = document.createElement('label');
  478. goblinShopLabel.setAttribute('for', 'checkbox');
  479. goblinShopLabel.innerText = "Goblin Shop Notifications";
  480.  
  481. goblinShopInputContainer.append(goblinShopInput);
  482. goblinShopInputContainer.append(goblinShopLabel);
  483.  
  484. menu.appendChild(goblinShopInputContainer);
  485.  
  486. document.body.appendChild(menu);
  487. }
  488.  
  489. function grantNotifications() {
  490. if (localStorage["hNotifications"] && localStorage["hNotifications"] == "true") {
  491. localStorage["hNotifications"] = "false";
  492. } else {
  493. if (Notification.permission !== "granted") {
  494. Notification.requestPermission(function(permission) {
  495. if (permission === "granted") {
  496. localStorage["hNotifications"] = "true";
  497. } else {
  498. alert("You will need to need desktop notifcations for DHM alerts to work.")
  499. }
  500. });
  501. } else {
  502. localStorage["hNotifications"] = "true";
  503. }
  504. }
  505. }
  506.  
  507. function toggleStorage() {
  508. let name = this.getAttribute('data-storage');
  509. if (localStorage[name] && localStorage[name] == "true") {
  510. localStorage[name] = "false";
  511. } else {
  512. localStorage[name] = "true";
  513. }
  514. }
  515.  
  516. function toggleMenu() {
  517. let menu = document.getElementById('dhm-helper-menu');
  518. menu.style.display = menu.style.display === 'none' ? '' : 'none';
  519. }
  520.  
  521. window.toggleMenu2 = toggleMenu
  522.  
  523. function init() {
  524. // Daily Mission
  525. var dailyObserver = new MutationObserver(function(mutations) {
  526. mutations.forEach(function(mutationRecord) {
  527. if (document.getElementById("notification-dailyMissionNotification").style.display !== "none") {
  528. if ((localStorage.hNotifications === "true") && (localStorage.hDaily === "true")) {
  529. var notification = new Notification("Daily Mission Available",{ icon: 'images/dailyMissions.png' });
  530. }
  531. }
  532. });
  533. });
  534. var dailyTarget = document.getElementById('notification-dailyMissionNotification');
  535. dailyObserver.observe(dailyTarget, { attributes : true, attributeFilter : ['style'] });
  536. // Treasure Map
  537. var mapObserver = new MutationObserver(function(mutations) {
  538. mutations.forEach(function(mutationRecord) {
  539. if (document.getElementById("notification-treasureMapNotification").style.display !== "none") {
  540. if ((localStorage.hNotifications === "true") && (localStorage.hMap === "true")) {
  541. var notification = new Notification("Treasure Map Found",{ icon: 'images/treasureMap.png' });
  542. }
  543. }
  544. });
  545. });
  546. var mapTarget = document.getElementById('notification-treasureMapNotification');
  547. mapObserver.observe(mapTarget, { attributes : true, attributeFilter : ['style'] });
  548. // Green Treasure Map
  549. var greenMapObserver = new MutationObserver(function(mutations) {
  550. mutations.forEach(function(mutationRecord) {
  551. if (document.getElementById("notification-greenTreasureMapNotification").style.display !== "none") {
  552. if ((localStorage.hNotifications === "true") && (localStorage.hMap === "true")) {
  553. var notification = new Notification("Green Treasure Map Found",{ icon: 'images/greenTreasureMap.png' });
  554. }
  555. }
  556. });
  557. });
  558. var greenMapTarget = document.getElementById('notification-greenTreasureMapNotification');
  559. greenMapObserver.observe(greenMapTarget, { attributes : true, attributeFilter : ['style'] });
  560. // Event
  561. var eventObserver = new MutationObserver(function(mutations) {
  562. mutations.forEach(function(mutationRecord) {
  563. if (document.getElementById("main-button-event").style.display !== "none") {
  564. if ((localStorage.hNotifications === "true") && (localStorage.hEvent === "true")) {
  565. var notification = new Notification("Event Coming",{ icon: 'images/meteorEvent.png' });
  566. }
  567. }
  568. });
  569. });
  570. var eventTarget = document.getElementById('main-button-event');
  571. eventObserver.observe(eventTarget, { attributes : true, attributeFilter : ['style'] });
  572. // Event Glowing
  573. var glowingObserver = new MutationObserver(function(mutations) {
  574. mutations.forEach(function(mutationRecord) {
  575. if (document.getElementById("notification-eventFullyActiveNotification").style.display !== "none") {
  576. if ((localStorage.hNotifications === "true") && (localStorage.hEvent === "true")) {
  577. var notification = new Notification("Event Glowing",{ icon: 'images/meteorActionEvent.png' });
  578. }
  579. }
  580. });
  581. });
  582. var glowingTarget = document.getElementById('notification-eventFullyActiveNotification');
  583. glowingObserver.observe(glowingTarget, { attributes : true, attributeFilter : ['style'] });
  584. // Researcher
  585. var researchObserver = new MutationObserver(function(mutations) {
  586. mutations.forEach(function(mutationRecord) {
  587. if (document.getElementById("notification-researcherNotification").style.display !== "none") {
  588. if ((localStorage.hNotifications === "true") && (localStorage.hResearch === "true")) {
  589. var notification = new Notification("Research Ready",{ icon: 'images/researcher.png' });
  590. }
  591. }
  592. });
  593. });
  594. var researchTarget = document.getElementById('notification-researcherNotification');
  595. researchObserver.observe(researchTarget, { attributes : true, attributeFilter : ['style'] });
  596. // Train Ready
  597. var trainObserver = new MutationObserver(function(mutations) {
  598. mutations.forEach(function(mutationRecord) {
  599. if (document.getElementById("notification-profileNotificationsOffTrain").style.display !== "none") {
  600. if ((localStorage.hNotifications === "true") && (localStorage.hTrain === "true")) {
  601. var notification = new Notification("Train Ready",{ icon: 'images/train.png' });
  602. }
  603. }
  604. });
  605. });
  606. var trainTarget = document.getElementById('notification-profileNotificationsOffTrain');
  607. trainObserver.observe(trainTarget, { attributes : true, attributeFilter : ['style'] });
  608. // Train at Destination
  609. var trainDestinationObserver = new MutationObserver(function(mutations) {
  610. mutations.forEach(function(mutationRecord) {
  611. if (document.getElementById("notification-trainNotification").style.display !== "none") {
  612. if ((localStorage.hNotifications === "true") && (localStorage.hTrain === "true")) {
  613. var notification = new Notification("Train Ready To Collect",{ icon: 'images/train.png' });
  614. }
  615. }
  616. });
  617. });
  618. var trainDestinationTarget = document.getElementById('notification-trainNotification');
  619. trainDestinationObserver.observe(trainDestinationTarget, { attributes : true, attributeFilter : ['style'] });
  620. // Rocket Ready
  621. var rocketObserver = new MutationObserver(function(mutations) {
  622. mutations.forEach(function(mutationRecord) {
  623. if (document.getElementById("notification-profileNotificationsOffRocket").style.display !== "none") {
  624. if ((localStorage.hNotifications === "true") && (localStorage.hRocket === "true")) {
  625. var notification = new Notification("Rocket Ready",{ icon: 'images/rocket.png' });
  626. }
  627. }
  628. });
  629. });
  630. var rocketTarget = document.getElementById('notification-profileNotificationsOffRocket');
  631. rocketObserver.observe(rocketTarget, { attributes : true, attributeFilter : ['style'] });
  632. // Rocket at Destination
  633. var rocketDestinationObserver = new MutationObserver(function(mutations) {
  634. mutations.forEach(function(mutationRecord) {
  635. if (document.getElementById("notification-rocketNotification").style.display !== "none") {
  636. if ((localStorage.hNotifications === "true") && (localStorage.hRocket === "true")) {
  637. var notification = new Notification("Rocket Ready To Collect",{ icon: 'images/rocket.png' });
  638. }
  639. }
  640. });
  641. });
  642. var rocketDestinationTarget = document.getElementById('notification-rocketNotification');
  643. rocketDestinationObserver.observe(rocketDestinationTarget, { attributes : true, attributeFilter : ['style'] });
  644. // Furnace Idle
  645. var furnaceObserver = new MutationObserver(function(mutations) {
  646. mutations.forEach(function(mutationRecord) {
  647. if (document.getElementById("notification-profileNotificationsOffFurnace").style.display !== "none") {
  648. if ((localStorage.hNotifications === "true") && (localStorage.hFurnace === "true")) {
  649. var notification = new Notification("Furnace Empty",{ icon: 'images/goldFurnace.png' });
  650. }
  651. }
  652. });
  653. });
  654. var furnaceTarget = document.getElementById('notification-profileNotificationsOffFurnace');
  655. furnaceObserver.observe(furnaceTarget, { attributes : true, attributeFilter : ['style'] });
  656. // Foundry Idle
  657. var foundryObserver = new MutationObserver(function(mutations) {
  658. mutations.forEach(function(mutationRecord) {
  659. if (document.getElementById("notification-charcoalFoundryPercentage").style.display == "none") {
  660. if ((localStorage.hNotifications === "true") && (localStorage.hFoundry === "true")) {
  661. var notification = new Notification("Foundry Empty",{ icon: 'images/charcoalFoundry.png' });
  662. }
  663. }
  664. });
  665. });
  666. var foundryTarget = document.getElementById('notification-charcoalFoundryPercentage');
  667. foundryObserver.observe(foundryTarget, { attributes : true, attributeFilter : ['style'] });
  668. // Refinary Idle
  669. var refinaryObserver = new MutationObserver(function(mutations) {
  670. mutations.forEach(function(mutationRecord) {
  671. if (document.getElementById("notification-goldBarRefineryNotification").style.display !== "none") {
  672. if ((localStorage.hNotifications === "true") && (localStorage.hRefinary === "true")) {
  673. var notification = new Notification("Refinary Ready",{ icon: 'images/goldRefinary.png' });
  674. }
  675. }
  676. });
  677. });
  678. var refinaryTarget = document.getElementById('notification-goldBarRefineryNotification');
  679. refinaryObserver.observe(refinaryTarget, { attributes : true, attributeFilter : ['style'] });
  680. // Tree Ready
  681. var treeObserver = new MutationObserver(function(mutations) {
  682. mutations.forEach(function(mutationRecord) {
  683. if (document.getElementById("notification-treeNotification").style.display !== "none") {
  684. if ((localStorage.hNotifications === "true") && (localStorage.hTree === "true")) {
  685. var notification = new Notification("Tree Ready",{ icon: 'images/tree.png' });
  686. }
  687. }
  688. });
  689. });
  690. var treeTarget = document.getElementById('notification-treeNotification');
  691. treeObserver.observe(treeTarget, { attributes : true, attributeFilter : ['style'] });
  692. // Planter Empty
  693. var planterObserver = new MutationObserver(function(mutations) {
  694. mutations.forEach(function(mutationRecord) {
  695. if (document.getElementById("notification-profileNotificationsOffPlanter").style.display !== "none") {
  696. if ((localStorage.hNotifications === "true") && (localStorage.hPlanter === "true")) {
  697. var notification = new Notification("Planter Idle",{ icon: 'images/planter.png' });
  698. }
  699. }
  700. });
  701. });
  702. var planterTarget = document.getElementById('notification-profileNotificationsOffPlanter');
  703. planterObserver.observe(planterTarget, { attributes : true, attributeFilter : ['style'] });
  704. // Explorer Idle
  705. var explorerObserver = new MutationObserver(function(mutations) {
  706. mutations.forEach(function(mutationRecord) {
  707. if (document.getElementById("notification-exploringNotification").style.display !== "none") {
  708. if ((localStorage.hNotifications === "true") && (localStorage.hExplorer === "true")) {
  709. var notification = new Notification("Explorer Idle",{ icon: 'images/explorer.png' });
  710. }
  711. }
  712. });
  713. });
  714. var explorerTarget = document.getElementById('notification-exploringNotification');
  715. explorerObserver.observe(explorerTarget, { attributes : true, attributeFilter : ['style'] });
  716. // Cousin Idle
  717. var cousinObserver = new MutationObserver(function(mutations) {
  718. mutations.forEach(function(mutationRecord) {
  719. if (document.getElementById("notification-exploringNotification2").style.display !== "none") {
  720. if ((localStorage.hNotifications === "true") && (localStorage.hCousin === "true")) {
  721. var notification = new Notification("Cousin Idle",{ icon: 'images/goblinCousin.png' });
  722. }
  723. }
  724. });
  725. });
  726. var cousinTarget = document.getElementById('notification-exploringNotification2');
  727. cousinObserver.observe(cousinTarget, { attributes : true, attributeFilter : ['style'] });
  728. // Boat Idle
  729. var boatObserver = new MutationObserver(function(mutations) {
  730. mutations.forEach(function(mutationRecord) {
  731. if (document.getElementById("notification-rowBoatNotification").style.display !== "none") {
  732. if ((localStorage.hNotifications === "true") && (localStorage.hBoat === "true")) {
  733. var notification = new Notification("Boat Ready",{ icon: 'images/rowBoat.png' });
  734. }
  735. }
  736. });
  737. });
  738. var boatTarget = document.getElementById('notification-rowBoatNotification');
  739. boatObserver.observe(boatTarget, { attributes : true, attributeFilter : ['style'] });
  740. // Canoe Idle
  741. var canoeObserver = new MutationObserver(function(mutations) {
  742. mutations.forEach(function(mutationRecord) {
  743. if (document.getElementById("notification-canoeBoatNotification").style.display !== "none") {
  744. if ((localStorage.hNotifications === "true") && (localStorage.hBoat === "true")) {
  745. var notification = new Notification("Canoe Ready",{ icon: 'images/canoeBoat.png' });
  746. }
  747. }
  748. });
  749. });
  750. var canoeTarget = document.getElementById('notification-canoeBoatNotification');
  751. canoeObserver.observe(canoeTarget, { attributes : true, attributeFilter : ['style'] });
  752. // Sail Idle
  753. var sailObserver = new MutationObserver(function(mutations) {
  754. mutations.forEach(function(mutationRecord) {
  755. if (document.getElementById("notification-sailBoatNotification").style.display !== "none") {
  756. if ((localStorage.hNotifications === "true") && (localStorage.hBoat === "true")) {
  757. var notification = new Notification("Sail Ready",{ icon: 'images/sailBoat.png' });
  758. }
  759. }
  760. });
  761. });
  762. var sailTarget = document.getElementById('notification-sailBoatNotification');
  763. sailObserver.observe(sailTarget, { attributes : true, attributeFilter : ['style'] });
  764. // Steam Idle
  765. var steamObserver = new MutationObserver(function(mutations) {
  766. mutations.forEach(function(mutationRecord) {
  767. if (document.getElementById("notification-steamBoatNotification").style.display !== "none") {
  768. if ((localStorage.hNotifications === "true") && (localStorage.hBoat === "true")) {
  769. var notification = new Notification("Steam Ready",{ icon: 'images/steamBoat.png' });
  770. }
  771. }
  772. });
  773. });
  774. var steamTarget = document.getElementById('notification-steamBoatNotification');
  775. steamObserver.observe(steamTarget, { attributes : true, attributeFilter : ['style'] });
  776. // Trawler Idle
  777. var trawlerObserver = new MutationObserver(function(mutations) {
  778. mutations.forEach(function(mutationRecord) {
  779. if (document.getElementById("notification-trawlerNotification").style.display !== "none") {
  780. if ((localStorage.hNotifications === "true") && (localStorage.hBoat === "true")) {
  781. var notification = new Notification("Trawler Ready",{ icon: 'images/trawler.png' });
  782. }
  783. }
  784. });
  785. });
  786. var trawlerTarget = document.getElementById('notification-trawlerNotification');
  787. trawlerObserver.observe(trawlerTarget, { attributes : true, attributeFilter : ['style'] });
  788. // Chef Ready
  789. var chefObserver = new MutationObserver(function(mutations) {
  790. mutations.forEach(function(mutationRecord) {
  791. if (document.getElementById("notification-chefNotification").style.display !== "none") {
  792. if ((localStorage.hNotifications === "true") && (localStorage.hChef === "true")) {
  793. var notification = new Notification("Chef Ready",{ icon: 'images/chef.png' });
  794. }
  795. }
  796. });
  797. });
  798. var chefTarget = document.getElementById('notification-chefNotification');
  799. chefObserver.observe(chefTarget, { attributes : true, attributeFilter : ['style'] });
  800. // Goblin Shop
  801. var goblinShopObserver = new MutationObserver(function(mutations) {
  802. mutations.forEach(function(mutationRecord) {
  803. if (document.getElementById("notification-gemGoblinShopNotification").style.display !== "none") {
  804. if ((localStorage.hNotifications === "true") && (localStorage.hGoblinShop === "true")) {
  805. var notification = new Notification("Goblin Shop New Items",{ icon: 'images/gemGoblinShopIcon.png' });
  806. }
  807. }
  808. });
  809. });
  810. var goblinShopTarget = document.getElementById('notification-gemGoblinShopNotification');
  811. goblinShopObserver.observe(goblinShopTarget, { attributes : true, attributeFilter : ['style'] });
  812. }
  813. });
  814.  
  815.  

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址