Skip to content

Commit

Permalink
✨ Add popup message when disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
richardfrost committed Mar 19, 2024
1 parent cd43cd3 commit bef5955
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/script/popup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,15 @@ export default class Popup {
this.Class.disable(domainToggle);
}

get disabledReason() {
if (this.isRestrictedPage) return 'Popup disabled by browser';
if (this.isPasswordProtected) return 'Popup disabled by password';
if (this.cfg.enabledDomainsOnly && !this.domain.enabled) return 'Popup disabled by domain mode';
if (this.disabledTab) return 'Popup disabled for tab';
if (this.domain.disabled) return 'Popup disabled for domain';
return '';
}

disableOptions() {
const domainModeSelect = document.getElementById('domainModeSelect') as HTMLSelectElement;
const filterMethodSelect = document.getElementById('filterMethodSelect') as HTMLSelectElement;
Expand Down Expand Up @@ -182,6 +191,12 @@ export default class Popup {
this.disableOptions();
}

handleDisabledMessage() {
const element = document.querySelector('#disabledMessage') as HTMLElement;
element.textContent = ` ${this.disabledReason}`;
this.isDisabled ? this.Class.show(element) : this.Class.hide(element);
}

handleEnabled() {
this.setDomainSwitch(true);
this.enableOptions();
Expand Down Expand Up @@ -297,6 +312,8 @@ export default class Popup {

if (this.wordlistsEnabled) this.handleWordlistsEnabled();

this.handleDisabledMessage();

if (this.isRestrictedPage) {
this.handleRestrictedPage();
return false;
Expand Down
6 changes: 6 additions & 0 deletions src/static/popup.css
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ body {
font-size: 10px;
}

#footer #disabledMessage {
color: red;
font-size: small;
text-align: center;
}

h4 {
margin-bottom: 5px;
}
Expand Down
1 change: 1 addition & 0 deletions src/static/popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
<a id="gettingStarted" href="https://github.com/FrostCo/AdvancedProfanityFilter/wiki" target="_blank">Help</a>
- <a href="https://github.com/FrostCo/AdvancedProfanityFilter/releases" target="_blank">Changelog</a>
- <a href="https://github.com/FrostCo/AdvancedProfanityFilter/issues" target="_blank">Support</a>
<div id="disabledMessage"></div>
</div>

<div id="uncaughtErrors"></div>
Expand Down

0 comments on commit bef5955

Please sign in to comment.