From 009b1452b9252a82c461ec4aca91fb181b62877d Mon Sep 17 00:00:00 2001 From: ArgoWizbang Date: Sat, 15 Feb 2025 19:24:46 -0500 Subject: [PATCH] Mass Ban Tool 1.0.1 * Fixed: Add-on not running properly in the browser extension version of FFZ when the add-on was already enabled before loading the mod view page --- src/mass-ban-tool/index.jsx | 61 +++++++++++++++++++++++---------- src/mass-ban-tool/manifest.json | 4 +-- 2 files changed, 44 insertions(+), 21 deletions(-) diff --git a/src/mass-ban-tool/index.jsx b/src/mass-ban-tool/index.jsx index e65dd70..d56b535 100644 --- a/src/mass-ban-tool/index.jsx +++ b/src/mass-ban-tool/index.jsx @@ -18,6 +18,7 @@ class MassBanTool extends Addon { this.toolIsRunning = false; this.inject( 'site.chat' ); + this.inject( 'site.fine' ); } buildMassBanToolModal() { @@ -166,9 +167,11 @@ class MassBanTool extends Addon { } checkForModView() { - this.modViewContainer = document.querySelector( '.modview-dock > div:last-child' ); + this.modBar = this.fine.define( 'mod-view-bar' ); + + if ( this.modBar ) { + this.reactModBar(); - if ( this.modViewContainer ) { return true; } @@ -185,28 +188,48 @@ class MassBanTool extends Addon { } } - insertModViewButton() { - this.modViewBtn =(
this.insertmassBanToolModal() }> -
- + reactModBar() { + this.modBar.ready( () => { this.update(); } ); + this.modBar.on( 'mount', this.insertModViewButton, this ); + this.modBar.on( 'update', this.insertModViewButton, this ); + } -
Mass Ban Tool
-
-
); + update() { + requestAnimationFrame( () => { + for ( const inst of this.modBar.instances ) { + this.insertModViewButton( inst ); + } + } ); + } - // Insert mod view button - this.modViewContainer.insertBefore( this.modViewBtn, document.getElementsByClassName( 'ffz-mod-view-button' )[0].nextElementSibling ); + insertModViewButton( inst, modBarContainer, _is_sunlight ) { + const root = this.fine.getChildNode( inst ); + + if ( inst?.childContext && ! root.contains( this.modViewBtn ) ) { + this.modBarContainer = root && root.querySelector('.modview-dock > div:last-child'); + + this.modViewBtn = (
this.insertmassBanToolModal() }> +
+ + +
Mass Ban Tool
+
+
); + + // Insert mod view button + this.modBarContainer.insertBefore( this.modViewBtn, this.modBarContainer.lastElementChild ); + } } removeModViewButton() { - if ( this.modViewContainer.contains( this.modViewBtn ) ) { - this.modViewContainer.removeChild( this.modViewBtn ); + if ( this.modBarContainer.contains( this.modViewBtn ) ) { + this.modBarContainer.removeChild( this.modViewBtn ); } } diff --git a/src/mass-ban-tool/manifest.json b/src/mass-ban-tool/manifest.json index 3fc47f4..b585331 100644 --- a/src/mass-ban-tool/manifest.json +++ b/src/mass-ban-tool/manifest.json @@ -1,12 +1,12 @@ { "enabled": true, "requires": [], - "version": "1.0.0", + "version": "1.0.1", "short_name": "MassBanTool", "name": "Mass Ban Tool", "author": "ArgoWizbang", "description": "A tool for mass banning/unbanning users via mod view in channels that you moderate or own.\n\nThe button to open the tool can be found in the mod dock on the bottom left section of the mod view page.", "website": "https://argowizbang.com/ffz-add-on/mass-ban-tool/", "created": "2025-01-31T05:34:58.994Z", - "updated": "2025-02-03T22:52:21.851Z" + "updated": "2025-02-16T00:24:48.096Z" } \ No newline at end of file