Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name DH Helper
- // @version 1.0
- // @description
- // @author level
- // @match http://*.diamondhunt.co/game.php
- // @match https://*.diamondhunt.co/game.php
- // @run-at document-idle
- // @grant none
- // ==/UserScript==
- console.log('loaded');
- loading();
- var Hinterval = setInterval(loading, 100);
- function loading() {
- if (firstLoadGame === false) {
- console.log("trying init");
- init();
- }
- }
- function init() {
- clearInterval(Hinterval);
- //---- Create the settings elements ---//
- console.log('doing function');
- var settings = document.createElement('div');
- settings.setAttribute('class', 'Hsettings');
- settings.setAttribute('id', 'Hsettings');
- //document.getElementById('content').appendChild(main);
- //header
- var header = document.createElement('h1');
- header.setAttribute('class', 'container-title');
- header.setAttribute('id', 'HsettingsHeader');
- header.innerHTML = "DH Helper";
- //Table
- var table = document.createElement('table');
- //table.setAttribute('class', 'table-style1');
- table.setAttribute('id', 'Htable');
- table.setAttribute('width', '40%');
- table.style = "margin: auto; border-collapse: collapse; background-color: silver; display: table;";
- //Table Body
- var tableBody = document.createElement('tbody');
- tableBody.setAttribute('id', 'HtableBody');
- tableBody.style ="display: table-row-group; vertical-align: middle; border-color: inherit; border-collapse: collapse;";
- //-- Each Table Row --//
- //Headers
- var trHeader1 = document.createElement('tr');
- trHeader1.setAttribute('id', 'HtrHeader1');
- trHeader1.setAttribute('background-color', 'grey');
- trHeader1.style = "cursor: pointer; display: table-row; vertical-align: inherit; border-color: inherit;";
- var th1 = document.createElement('th');
- th1.innerHTML = "Configuration";
- th1.style = "background-color: grey; font-weight: bold; text-align: -internal-center; display: table-cell; vertical-align: inherit; cursor: pointer;";
- trHeader1.appendChild(th1);
- var th2 = document.createElement('th');
- th2.innerHTML = "Active";
- th2.style = "background-color: grey; font-weight: bold; text-align: -internal-center; display: table-cell; vertical-align: inherit; cursor: pointer;";
- trHeader1.appendChild(th2);
- //Desktop Global
- var trHeader2 = document.createElement('tr');
- trHeader2.setAttribute('id', 'HtrHeader2');
- trHeader2.setAttribute('onClick', 'HtrHeader2Click()');
- trHeader2.style = "cursor: pointer; display: table-row; vertical-align: inherit; border-color: inherit;";
- trHeader2.addEventListener('click', HtrHeader2Click, false);
- var td1 = document.createElement('td');
- td1.innerHTML = "Desktop Notifications";
- td1.style = "background-color: silver; text-align: center; display: table-cell; vertical-align: inherit; cursor: pointer; border: 1px solid black;";
- trHeader2.appendChild(td1);
- var td2 = document.createElement('td');
- td2.setAttribute('id', 'Htd2');
- td2.style = "background-color: silver; text-align: center; display: table-cell; vertical-align: inherit; cursor: pointer; border: 1px solid black;";
- if (localStorage.hdesktop == "true") {
- var himageyes1 = document.createElement('img');
- himageyes1.setAttribute('src', 'images/icons/check.png');
- himageyes1.setAttribute('class', 'image-icon-20');
- td2.appendChild(himageyes1);
- } else {
- var himageno1 = document.createElement('img');
- himageno1.setAttribute('src', 'images/icons/x.png');
- himageno1.setAttribute('class', 'image-icon-20');
- td2.appendChild(himageno1);
- }
- trHeader2.appendChild(td2);
- //Woodcutting
- var trHeader3 = document.createElement('tr');
- trHeader3.setAttribute('id', 'HtrHeader3');
- trHeader3.setAttribute('onClick', 'HtrHeader3Click()');
- trHeader3.style = "cursor: pointer; display: table-row; vertical-align: inherit; border-color: inherit;";
- trHeader3.addEventListener('click', HtrHeader3Click, false);
- var td3 = document.createElement('td');
- td3.innerHTML = "Woodcutting Notifications";
- td3.style = "background-color: silver; text-align: center; display: table-cell; vertical-align: inherit; cursor: pointer; border: 1px solid black;";
- trHeader3.appendChild(td3);
- var td4 = document.createElement('td');
- td4.setAttribute('id', 'Htd4');
- td4.style = "background-color: silver; text-align: center; display: table-cell; vertical-align: inherit; cursor: pointer; border: 1px solid black;";
- if (localStorage.hwoodcutting == "true") {
- var himageyes2 = document.createElement('img');
- himageyes2.setAttribute('src', 'images/icons/check.png');
- himageyes2.setAttribute('class', 'image-icon-20');
- td4.appendChild(himageyes2);
- } else {
- var himageno2 = document.createElement('img');
- himageno2.setAttribute('src', 'images/icons/x.png');
- himageno2.setAttribute('class', 'image-icon-20');
- td4.appendChild(himageno2);
- }
- trHeader3.appendChild(td4);
- //Farming
- var trHeader4 = document.createElement('tr');
- trHeader4.setAttribute('id', 'HtrHeader4');
- trHeader4.setAttribute('onClick', 'HtrHeader4Click()');
- trHeader4.style = "cursor: pointer; display: table-row; vertical-align: inherit; border-color: inherit;";
- trHeader4.addEventListener('click', HtrHeader4Click, false);
- var td5 = document.createElement('td');
- td5.innerHTML = "Farming Notifications";
- td5.style = "background-color: silver; text-align: center; display: table-cell; vertical-align: inherit; cursor: pointer; border: 1px solid black;";
- trHeader4.appendChild(td5);
- var td6 = document.createElement('td');
- td6.setAttribute('id', 'Htd6');
- td6.style = "background-color: silver; text-align: center; display: table-cell; vertical-align: inherit; cursor: pointer; border: 1px solid black;";
- if (localStorage.hfarming == "true") {
- var himageyes3 = document.createElement('img');
- himageyes3.setAttribute('src', 'images/icons/check.png');
- himageyes3.setAttribute('class', 'image-icon-20');
- td6.appendChild(himageyes3);
- } else {
- var himageno3 = document.createElement('img');
- himageno3.setAttribute('src', 'images/icons/x.png');
- himageno3.setAttribute('class', 'image-icon-20');
- td6.appendChild(himageno3);
- }
- trHeader4.appendChild(td6);
- //Combat
- var trHeader5 = document.createElement('tr');
- trHeader5.setAttribute('id', 'HtrHeader5');
- trHeader5.setAttribute('onClick', 'HtrHeader5Click()');
- trHeader5.style = "cursor: pointer; display: table-row; vertical-align: inherit; border-color: inherit;";
- trHeader5.addEventListener('click', HtrHeader5Click, false);
- var td7 = document.createElement('td');
- td7.innerHTML = "Combat Notifications";
- td7.style = "background-color: silver; text-align: center; display: table-cell; vertical-align: inherit; cursor: pointer; border: 1px solid black;";
- trHeader5.appendChild(td7);
- var td8 = document.createElement('td');
- td8.setAttribute('id', 'Htd8');
- td8.style = "background-color: silver; text-align: center; display: table-cell; vertical-align: inherit; cursor: pointer; border: 1px solid black;";
- if (localStorage.hfarming == "true") {
- var himageyes4 = document.createElement('img');
- himageyes4.setAttribute('src', 'images/icons/check.png');
- himageyes4.setAttribute('class', 'image-icon-20');
- td8.appendChild(himageyes4);
- } else {
- var himageno4 = document.createElement('img');
- himageno4.setAttribute('src', 'images/icons/x.png');
- himageno4.setAttribute('class', 'image-icon-20');
- td8.appendChild(himageno4);
- }
- trHeader5.appendChild(td8);
- //Adding everything together
- tableBody.appendChild(trHeader1);
- tableBody.appendChild(trHeader2);
- tableBody.appendChild(trHeader3);
- tableBody.appendChild(trHeader4);
- tableBody.appendChild(trHeader5);
- table.appendChild(tableBody);
- settings.appendChild(header);
- settings.appendChild(table);
- document.getElementById('tab-container-profile').appendChild(settings);
- console.log('done function');
- }
- function HtrHeader2Click() {
- var tdata = document.getElementById('Htd2');
- if (localStorage.hdesktop == "true") {
- localStorage.hdesktop = "false";
- tdata.removeChild(tdata.firstChild);
- var himageno5 = document.createElement('img');
- himageno5.setAttribute('src', 'images/icons/x.png');
- himageno5.setAttribute('class', 'image-icon-20');
- tdata.appendChild(himageno5);
- } else {
- localStorage.hdesktop = "true";
- tdata.removeChild(tdata.firstChild);
- var himageyes5 = document.createElement('img');
- himageyes5.setAttribute('src', 'images/icons/check.png');
- himageyes5.setAttribute('class', 'image-icon-20');
- tdata.appendChild(himageyes5);
- Notification.requestPermission();
- }
- }
- function HtrHeader3Click() {
- var tdata = document.getElementById('Htd4');
- if (localStorage.hwoodcutting == "true") {
- localStorage.hwoodcutting = "false";
- tdata.removeChild(tdata.firstChild);
- var himageno6 = document.createElement('img');
- himageno6.setAttribute('src', 'images/icons/x.png');
- himageno6.setAttribute('class', 'image-icon-20');
- tdata.appendChild(himageno6);
- } else {
- localStorage.hwoodcutting = "true";
- tdata.removeChild(tdata.firstChild);
- var himageyes6 = document.createElement('img');
- himageyes6.setAttribute('src', 'images/icons/check.png');
- himageyes6.setAttribute('class', 'image-icon-20');
- tdata.appendChild(himageyes6);
- }
- }
- function HtrHeader4Click() {
- var tdata = document.getElementById('Htd6');
- if (localStorage.hfarming == "true") {
- localStorage.hfarming = "false";
- tdata.removeChild(tdata.firstChild);
- var himageno7 = document.createElement('img');
- himageno7.setAttribute('src', 'images/icons/x.png');
- himageno7.setAttribute('class', 'image-icon-20');
- tdata.appendChild(himageno7);
- } else {
- localStorage.hfarming = "true";
- tdata.removeChild(tdata.firstChild);
- var himageyes7 = document.createElement('img');
- himageyes7.setAttribute('src', 'images/icons/check.png');
- himageyes7.setAttribute('class', 'image-icon-20');
- tdata.appendChild(himageyes7);
- }
- }
- function HtrHeader5Click() {
- var tdata = document.getElementById('Htd8');
- if (localStorage.hcombat == "true") {
- localStorage.hcombat = "false";
- tdata.removeChild(tdata.firstChild);
- var himageno8 = document.createElement('img');
- himageno8.setAttribute('src', 'images/icons/x.png');
- himageno8.setAttribute('class', 'image-icon-20');
- tdata.appendChild(himageno8);
- } else {
- localStorage.hcombat = "true";
- tdata.removeChild(tdata.firstChild);
- var himageyes8 = document.createElement('img');
- himageyes8.setAttribute('src', 'images/icons/check.png');
- himageyes8.setAttribute('class', 'image-icon-20');
- tdata.appendChild(himageyes8);
- }
- }
- //---- Create observers for each notification ----//
- //Woodcutting
- var woodobserver = new MutationObserver(function(mutations) {
- mutations.forEach(function(mutationRecord) {
- if (document.getElementById("notification-static-woodcutting").getAttribute("display") != "none") {
- if ((localStorage.hdesktop == "true") && (localStorage.hwoodcutting == "true")) {
- var notification = new Notification("Woodcutting",{ icon: 'images/icons/woodcutting.png' });
- }
- }
- });
- });
- var target1 = document.getElementById('notification-static-woodcutting');
- woodobserver.observe(target1, { attributes : true, attributeFilter : ['style'] });
- //Farming
- var farmingobserver = new MutationObserver(function(mutations) {
- mutations.forEach(function(mutationRecord) {
- if (document.getElementById("notification-static-farming").getAttribute("display") != "none") {
- if ((localStorage.hdesktop == "true") && (localStorage.hfarming == "true")) {
- var notification = new Notification("Farming",{ icon: 'images/icons/watering-can.png' });
- }
- }
- });
- });
- var target2 = document.getElementById('notification-static-farming');
- farmingobserver.observe(target2, { attributes : true, attributeFilter : ['style'] });
- //Combat
- var combatobserver = new MutationObserver(function(mutations) {
- mutations.forEach(function(mutationRecord) {
- if (document.getElementById("notification-static-combat").getAttribute("display") != "none") {
- if ((localStorage.hdesktop == "true") && (localStorage.hcombat == "true")) {
- var notification = new Notification("Combat",{ icon: 'images/icons/combat.png' });
- }
- }
- });
- });
- var target3 = document.getElementById('notification-static-combat');
- combatobserver.observe(target3, { attributes : true, attributeFilter : ['style'] });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement