diff --git a/extra.js b/extra.js index 614ed0f..5421096 100644 --- a/extra.js +++ b/extra.js @@ -5,109 +5,44 @@ if(window.PvInternals.services_client) { // custom rules (() => { const pv = window.PvInternals; - //#region custom modal class PvmeRulesModal extends pv.components_pv_popup_pv_popup { constructor() { - super(); - this.message = "yo" - - this.innerHTML = ` - `; + super(); + this.innerHTML = ``; } } customElements.define("pvme-rules-modal", PvmeRulesModal); pv.Modal.RULES = "pvme-rules-modal"; - - //#endregion custom modal - //#region break PopupMananger so it takes our new popup into account + let oldOpen = pv.PopupManager.open; pv.PopupManager.open = (e, ...t) => { - let i; - if (i = document.querySelector(e), - i && !i.querySelector("dialog").hasAttribute("closing")) - return i.close(), - i; - switch (e) { - case pv.Modal.BAN: - i = new pv.components_popups_pv_ban_pv_ban; - break; - case pv.Modal.PROFILE: - i = new pv.components_popups_pv_profile_pv_profile; - break; - case pv.Modal.SETTINGS: - i = new pv.components_popups_pv_settings_pv_settings; - break; - case pv.Modal.MESSAGE: - i = new pv.components_popups_pv_message_pv_message; - break; - case pv.Modal.NEW_ROOM: - i = new pv.components_popups_pv_new_room_pv_new_room; - break; - case pv.Modal.NEW_ROOM: - i = new pv.components_popups_pv_new_room_pv_new_room; - break; - case pv.Modal.RULES: - i = new PvmeRulesModal; - break; - case pv.Dialog.ROOMS: - i = new pv.components_popups_pv_rooms_pv_rooms; - break; - case pv.Dialog.ACTIONS: - i = new pv.components_popups_pv_actions_pv_actions; - break; - case pv.Dialog.DEVICES: - i = new pv.components_popups_pv_devices_pv_devices; - break; - case pv.Dialog.SOUNDS: - i = new pv.components_popups_pv_sounds_pv_sounds; - break; - case pv.Dialog.TRANSPOSE: - i = new pv.components_popups_pv_transpose_pv_transpose; - break; - case pv.Dialog.VELOCITY: - i = new pv.components_popups_pv_velocity_pv_velocity; - break; - default: - throw new Error(`Popup ${e} not found`) + if(pv.Modal.RULES == e) { + let i = new PvmeRulesModal(); + if (i == document.querySelector(e) && !i.querySelector("dialog").hasAttribute("closing")) + return i.close(); + + document.body.append(i) + i.open(...t) + + return i; + } else { + return oldOpen(e, ...t) } - return i && (document.body.append(i), - i.open(...t)), - i } - //#endregion - //#region pvme rules + class PvmeRules extends HTMLElement {} customElements.define("pvme-rules", PvmeRules); let g = document.querySelector("body > pv-header > div.left"); { let a = document.createElement("div"); a.className = "divider"; a.style.marginLeft = "20px"; g.appendChild(a); } { - let a = document.createElement("pvme-rules"); - a.innerHTML = `