Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mass Ban Tool 1.0.1 #265

Merged
merged 1 commit into from
Feb 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 42 additions & 19 deletions src/mass-ban-tool/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class MassBanTool extends Addon {
this.toolIsRunning = false;

this.inject( 'site.chat' );
this.inject( 'site.fine' );
}

buildMassBanToolModal() {
Expand Down Expand Up @@ -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;
}

Expand All @@ -185,28 +188,48 @@ class MassBanTool extends Addon {
}
}

insertModViewButton() {
this.modViewBtn =( <div class="tw-relative tw-mg-b-1" onClick={ () => this.insertmassBanToolModal() }>
<div id="ffz-mass-ban-tool-btn" class="tw-inline-flex tw-relative ffz-il-tooltip__container">
<button class="tw-align-items-center tw-align-middle tw-border-bottom-left-radius-medium tw-border-bottom-right-radius-medium tw-border-top-left-radius-medium tw-border-top-right-radius-medium tw-button-icon ffz-core-button ffz-core-button--border tw-inline-flex tw-interactive tw-justify-content-center tw-overflow-hidden tw-relative">
<div class="tw-align-items-center tw-flex tw-flex-grow-0">
<span class="tw-button-icon__icon">
<figure class="ffz-i-block"></figure>
</span>
</div>
</button>
reactModBar() {
this.modBar.ready( () => { this.update(); } );
this.modBar.on( 'mount', this.insertModViewButton, this );
this.modBar.on( 'update', this.insertModViewButton, this );
}

<div class="ffz-il-tooltip ffz-il-tooltip--up ffz-il-tooltip--align-left">Mass Ban Tool</div>
</div>
</div> );
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 = ( <div class="tw-relative tw-mg-b-1" onClick={ () => this.insertmassBanToolModal() }>
<div id="ffz-mass-ban-tool-btn" class="tw-inline-flex tw-relative ffz-il-tooltip__container">
<button class="tw-align-items-center tw-align-middle tw-border-bottom-left-radius-medium tw-border-bottom-right-radius-medium tw-border-top-left-radius-medium tw-border-top-right-radius-medium tw-button-icon ffz-core-button ffz-core-button--border tw-inline-flex tw-interactive tw-justify-content-center tw-overflow-hidden tw-relative">
<div class="tw-align-items-center tw-flex tw-flex-grow-0">
<span class="tw-button-icon__icon">
<figure class="ffz-i-block"></figure>
</span>
</div>
</button>

<div class="ffz-il-tooltip ffz-il-tooltip--up ffz-il-tooltip--align-left">Mass Ban Tool</div>
</div>
</div> );

// 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 );
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/mass-ban-tool/manifest.json
Original file line number Diff line number Diff line change
@@ -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"
}