|
27 | 27 | // @include https://web1.dawnofthedragons.com/* |
28 | 28 | // @include https://50.18.191.15/* |
29 | 29 | // ==/UserScript== |
30 | | -( function () { |
31 | | - if(window.location.host==='50.18.191.15'||window.location.host==='web1.dawnofthedragons.com') { |
32 | | - window.idrinth = {}; |
33 | | - window.idrinth.add=function(data) { |
34 | | - var s=document.createElement('script'); |
35 | | - s.appendChild(document.createTextNode(data)); |
36 | | - document.getElementsByTagName('head')[0].appendChild(s); |
37 | | - }; |
38 | | - window.addEventListener( |
39 | | - "message", |
40 | | - function (event){ |
41 | | - try{ |
42 | | - var data = JSON.parse(event.data); |
43 | | - if(data.to !== 'idotd'||!window.idrinth.hasOwnProperty (data.task)||!data.data) { |
44 | | - return; |
45 | | - } |
46 | | - window.idrinth[data.task](data.data); |
47 | | - } catch(e) { |
48 | | - //nothing |
49 | | - } |
50 | | - }, |
51 | | - false |
52 | | - ); |
53 | | - return; |
54 | | - } |
55 | | - var sc = document.createElement ( 'script' ); |
56 | | - sc.setAttribute ( 'src', 'https://dotd.idrinth.de/static/userscript/' + GM_info.script.version + '/' ); |
57 | | - sc.setAttribute ( 'id', 'idotd-loader' ); |
58 | | - sc.setAttribute ( 'async', 'async' ); |
59 | | - sc.errorCounter = 0; |
60 | | - sc.errorFunction = function () { |
61 | | - var self = document.getElementById ( 'idotd-loader' ); |
62 | | - self.parentNode.removeChild ( self ); |
63 | | - var sc = document.createElement ( 'script' ); |
64 | | - sc.onerror = self.onerror; |
65 | | - sc.errorCounter = self.errorCounter + 1; |
66 | | - sc.errorFunction = self.errorFunction; |
67 | | - sc.setAttribute ( 'id', 'idotd-loader' ); |
68 | | - sc.setAttribute ( 'async', 'async' ); |
69 | | - sc.setAttribute ( 'src', ( self.getAttribute ( 'src' ) + '' ).replace ( /(userscript\/.*?\/).*$/, '$1' ) + Math.random () + '/' ); |
70 | | - document.getElementsByTagName ( 'head' )[0].appendChild ( sc ); |
| 30 | +(function() { |
| 31 | + if ( |
| 32 | + window.location.host === "50.18.191.15" || |
| 33 | + window.location.host === "web1.dawnofthedragons.com" |
| 34 | + ) { |
| 35 | + window.idrinth = {}; |
| 36 | + window.idrinth.add = function(data) { |
| 37 | + var s = document.createElement("script"); |
| 38 | + s.appendChild(document.createTextNode(data)); |
| 39 | + document.getElementsByTagName("head")[0].appendChild(s); |
71 | 40 | }; |
72 | | - sc.onerror = function () { |
73 | | - console.log ( "Failed loading IDotD, retry in " + ( 500 + 100 * this.errorCounter * this.errorCounter ) / 1000 + "sec." ); |
74 | | - window.setTimeout ( this.errorFunction, 500 + 100 * this.errorCounter * this.errorCounter ); |
75 | | - }; |
76 | | - document.getElementsByTagName ( 'head' )[0].appendChild ( sc ); |
77 | | -} () ); |
| 41 | + window.addEventListener( |
| 42 | + "message", |
| 43 | + function(event) { |
| 44 | + try { |
| 45 | + var data = JSON.parse(event.data); |
| 46 | + if ( |
| 47 | + data.to !== "idotd" || |
| 48 | + !window.idrinth.hasOwnProperty(data.task) || |
| 49 | + !data.data |
| 50 | + ) { |
| 51 | + return; |
| 52 | + } |
| 53 | + window.idrinth[data.task](data.data); |
| 54 | + } catch (e) { |
| 55 | + //nothing |
| 56 | + } |
| 57 | + }, |
| 58 | + false |
| 59 | + ); |
| 60 | + return; |
| 61 | + } |
| 62 | + var sc = document.createElement("script"); |
| 63 | + sc.setAttribute( |
| 64 | + "src", |
| 65 | + "https://dotd.idrinth.de/static/userscript/" + GM_info.script.version + "/" |
| 66 | + ); |
| 67 | + sc.setAttribute("id", "idotd-loader"); |
| 68 | + sc.setAttribute("async", "async"); |
| 69 | + sc.errorCounter = 0; |
| 70 | + sc.errorFunction = function() { |
| 71 | + var self = document.getElementById("idotd-loader"); |
| 72 | + self.parentNode.removeChild(self); |
| 73 | + var sc = document.createElement("script"); |
| 74 | + sc.onerror = self.onerror; |
| 75 | + sc.errorCounter = self.errorCounter + 1; |
| 76 | + sc.errorFunction = self.errorFunction; |
| 77 | + sc.setAttribute("id", "idotd-loader"); |
| 78 | + sc.setAttribute("async", "async"); |
| 79 | + sc.setAttribute( |
| 80 | + "src", |
| 81 | + (self.getAttribute("src") + "").replace(/(userscript\/.*?\/).*$/, "$1") + |
| 82 | + Math.random() + |
| 83 | + "/" |
| 84 | + ); |
| 85 | + document.getElementsByTagName("head")[0].appendChild(sc); |
| 86 | + }; |
| 87 | + sc.onerror = function() { |
| 88 | + console.log( |
| 89 | + "Failed loading IDotD, retry in " + |
| 90 | + (500 + 100 * this.errorCounter * this.errorCounter) / 1000 + |
| 91 | + "sec." |
| 92 | + ); |
| 93 | + window.setTimeout( |
| 94 | + this.errorFunction, |
| 95 | + 500 + 100 * this.errorCounter * this.errorCounter |
| 96 | + ); |
| 97 | + }; |
| 98 | + document.getElementsByTagName("head")[0].appendChild(sc); |
| 99 | +})(); |
0 commit comments