()
| 108 | } |
| 109 | |
| 110 | function initGhostSwitcher() { |
| 111 | console.log("DIM ready"); |
| 112 | |
| 113 | var ghosts = {}; |
| 114 | var rows = document.querySelectorAll(".store-row"); |
| 115 | |
| 116 | for (var row of rows) { |
| 117 | if (!row.querySelector("[aria-label=Ghost]")) { continue; } |
| 118 | |
| 119 | var items = row.querySelectorAll(".item"); |
| 120 | |
| 121 | for (let item of items) { |
| 122 | var text = item.querySelector("span"); |
| 123 | if (!text) { continue; } |
| 124 | |
| 125 | var aoe = text.innerText.replace("+", "plus"); // area of effect |
| 126 | if (!aoe) { continue; } |
| 127 | |
| 128 | var equip = () => doubleClick(item); |
| 129 | var name = item.title.trim().replace(/(\r\n\t|\n|\r\t)/gm, " ");; |
| 130 | var node = item; |
| 131 | var ghost = { equip, aoe, name, ghost }; |
| 132 | ghosts[aoe] = ghosts[aoe] || ghost; // keep first, assuming best is first |
| 133 | ghosts.default = ghosts.default || ghost; |
| 134 | } |
| 135 | } |
| 136 | |
| 137 | var arr = Object.values(ghosts); |
| 138 | console.log("Found " + arr.length + " special ghosts:\n" + arr.map(i => i.name).join("\n")); |
| 139 | monitorInGameStatus(ghosts); |
| 140 | } |
| 141 | |
| 142 | function observeDIM() { |
| 143 | var observer = new MutationObserver((records) => { |
no test coverage detected