// // ==UserScript== // @author jaiperdu // @name Dialog List // @category Misc // @version 0.1.0 // @description List open dialogs in the sidebar // @id dialogs@jaiperdu // @namespace https://github.com/IITC-CE/ingress-intel-total-conversion // @updateURL https://raw.githubusercontent.com/IITC-CE/Community-plugins/master/dist/jaiperdu/dialogs.meta.js // @downloadURL https://raw.githubusercontent.com/IITC-CE/Community-plugins/master/dist/jaiperdu/dialogs.user.js // @match https://intel.ingress.com/* // @grant none // ==/UserScript== function wrapper(plugin_info) { // ensure plugin framework is there, even if iitc is not yet loaded if(typeof window.plugin !== 'function') window.plugin = function() {}; const W = window; let DIALOGS = {}; function itemOnClick(ev) { const id = ev.target.closest("tr").dataset.id; const dialog = $(DIALOGS[id]); dialog.dialog("moveToTop"); } function itemOnClose(ev) { const id = ev.target.closest("tr").dataset.id; const dialog = $(DIALOGS[id]); dialog.dialog("close"); } function dialogListItem(id) { const dialog = $(DIALOGS[id]); const option = dialog.dialog("option"); const text = option.title; const tr = document.createElement("tr"); tr.dataset.id = id; const title = document.createElement("td"); tr.appendChild(title); title.textContent = text; if (!dialog.is(":hidden")) title.classList.add("ui-dialog-title-inactive"); title.addEventListener("click", itemOnClick); const closeButton = document.createElement("td"); tr.appendChild(closeButton); closeButton.textContent = "X"; closeButton.addEventListener("click", itemOnClose); return tr; } function updateList() { const list = document.getElementById("dialog-list"); list.textContent = ""; Object.keys(DIALOGS).forEach((id) => { list.appendChild(dialogListItem(id)); }); } const dialogMonitor = { set: function (obj, prop, valeur) { obj[prop] = valeur; updateList(); return true; }, deleteProperty: function (obj, prop) { delete obj[prop]; updateList(); return true; }, }; function setup () { DIALOGS = W.DIALOGS = new Proxy(W.DIALOGS, dialogMonitor); $("