NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name Fahrzeugtableu // @namespace http://tampermonkey.net/ // @version 0.1 // @description try to take over the world! // @author You // @license MIT // @match https://www.leitstellenspiel.de/ // @grant none // @require http://localhost:3000/socket.io/socket.io.js // ==/UserScript== (function() { window.onload = function () { var timer = 10; var classname = document.getElementsByClassName("building_list_vehicle_element"); // console.log(classname); for (var i = 0; i < classname.length; i++) { // Select the node that will be observed for mutations const targetNode = classname[i]; // Options for the observer (which mutations to observe) const config = { attributes: true, childList: true, subtree: true }; // Callback function to execute when mutations are observed const callback = function(mutationsList, observer) { for(let mutation of mutationsList) { if (mutation.type === 'childList') { //Send Element 1 + 3 //var xhttp1 = new XMLHttpRequest();xhttp1.open("POST", "http://localhost:3000/updatedata", true);xhttp1.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");xhttp1.send("Status="+mutation.addedNodes[1].innerText+"&ID="+mutation.addedNodes[3].id); setTimeout(function(){console.log('A child node has been added or removed. ' +timer); console.log(mutation.addedNodes[3].id);console.log("SEND POST"); socket.emit('Test', { Status : mutation.addedNodes[1].innerText, ID : mutation.addedNodes[3].id });}, timer*100); timer+=20; if(timer> 70) timer =10; } else if (mutation.type === 'attributes') { console.log('The ' + mutation.attributeName + ' attribute was modified.'); } } }; // Create an observer instance linked to the callback function const observer = new MutationObserver(callback); // Start observing the target node for configured mutations observer.observe(targetNode, config); } }; 'use strict'; console.log("LOADING"); // Your code here... var socket = io.connect('http://localhost:3000/'); socket.on('connect', function () { socket.emit("hasData"); }); socket.on('yourdata', function(msg){ console.log(msg); if(!msg) { var buildings, vehicles; var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange=function() { if (this.readyState == 4 && this.status == 200) { console.log(this.responseText); buildings = this.responseText; xhttp = new XMLHttpRequest(); xhttp.onreadystatechange=function() { if (this.readyState == 4 && this.status == 200) { console.log(this.responseText); vehicles = this.responseText; socket.emit('Setup', { buildings : buildings, vehicles : vehicles}); } }; xhttp.open("GET", "https://www.leitstellenspiel.de/api/vehicles", true); xhttp.send(); } }; xhttp.open("GET", "https://www.leitstellenspiel.de/api/buildings", true); xhttp.send(); } }); })();