Skip to content

Commit

Permalink
Rework BlurNSFW away from ZPL
Browse files Browse the repository at this point in the history
  • Loading branch information
zerebos committed Dec 15, 2024
1 parent 615f28b commit 5d6c14a
Show file tree
Hide file tree
Showing 11 changed files with 719 additions and 463 deletions.
563 changes: 326 additions & 237 deletions Plugins/BlurNSFW/BlurNSFW.plugin.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions scripts/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ async function buildPlugin() {
bundle: true,
format: "cjs",
target: ["chrome128"],
external: ["events"],
loader: {".css": "text", ".html": "text"},
logLevel: "info",
metafile: true,
Expand Down
129 changes: 129 additions & 0 deletions src/BetterDiscord/discord.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
export interface User {
avatar: string;
avatarDecorationData: null | {
asset: string;
skuId: string;
};
banner: string | null;
bot: boolean;
clan: string | null;
desktop: boolean;
discriminator: string;
displayName: string;
email: string | null;
flags: number;
globalName: string;
guildMemberAvatars: object;
hasAnyStaffLevel(): boolean;
hasBouncedEmail: boolean;
hasFlag(f: number): boolean;
id: string;
isStaff(): boolean;
isStaffPersonal(): boolean;
mfaEnabled: boolean;
mobile: boolean;
nsfwAllowed: boolean | undefined;
personalConnectionId: null | string;
phone: string | null;
premiumType: number | undefined;
premiumUsageFlags: number;
primaryGuild: string | null;
publicFlags: number;
purchasedFlags: number;
system: boolean;
username: string;
verified: boolean;

readonly avatarDecoration: null | {
asset: string;
skuId: string;
};
readonly createdAt: Date;
readonly isProvisional: boolean;
readonly tag: string;
}

export interface DMUser {
avatar: string;
avatar_decoration_data: {
asset: string;
expires_at: string | null;
sku_id: string;
};
bot: boolean;
clan: string | null;
discriminator: string;
display_name: string;
global_name: string;
id: string;
primary_guild: string | null;
public_flags: number;
username: string;
}

export interface PermissionOverwrite {
allow: bigint;
deny: bigint;
id: string;
type: number;
}

export interface Channel {
application_id: string | undefined;
flags_: number;
guild_id: string | null;
icon: string | undefined;
id: string;
isMessageRequest: boolean;
isMessageRequestTimestamp: boolean | null;
isSpam: boolean;
lastMessageId: string;
lastPinTimestamp: string;
name: string;
nicks: {
[key: string]: string;
}
ownerId: string;
rawRecipients: User[];
recipientFlags: number;
recipients: string[];
safetyWarnings: string[];
type: number;

readonly accessPermissions: bigint;
readonly bitrate: number;
readonly flags: number;
readonly isHDStreamSplashed: boolean;
readonly nsfw: boolean;
readonly permissionOverwrites: {
[id: string]: PermissionOverwrite;
};
readonly position: number;
readonly rateLimitPerUser: number;
readonly topic: string;
readonly userLimit: number;
}

export interface DMChannel extends Channel {
type: 1;
}

export interface GuildChannel extends Channel {
defaultAutoArchiveDuration: number | undefined;
defaultThreadRateLimitPerUser: number | undefined;
hdStreamingBuyerId: string | undefined;
hdStreamingUntil: Date | undefined;
iconEmoji: undefined;
linkedLobby: undefined;
memberListId: undefined;
parent_id: string;
permissionOverwrites_: {
[id: string]: PermissionOverwrite;
};
position_: number;
rateLimitPerUser_: number;
themeColor: string | undefined;
topic_: string;
type: 0;
version: number;
}
2 changes: 2 additions & 0 deletions src/BetterDiscord/dom.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ export interface AnimateOptions {
export interface DOM {
animate(update: (progress: number) => void, duration: number, options?: AnimateOptions): void;
parseHTML<T extends boolean = false>(html: string, fragment?: T): T extends true ? DocumentFragment : NodeList | HTMLElement;
addStyle(id: string, css: string): void;
removeStyle(id: string): void;
}
24 changes: 24 additions & 0 deletions src/BetterDiscord/modules.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
export type ClassModule = Record<string, string>;


export interface Dispatcher {
register<T>(callback: (payload: T) => void): string;
unregister(id: string): void;
waitFor(IDs: string[]): void;
dispatch<T>(payload: T): void;
isDispatching(): boolean;
}

export type StoreChangeListener = () => void;

export interface FluxStore {
addChangeListener(fn: StoreChangeListener): void;
removeChangeListener(fn: StoreChangeListener): void;

emitChange(): void;
getDispatchToken(): string;
getName(): string;
initialize(): void;
_dispatchToken: string;
_isInitialized: boolean;
}
1 change: 1 addition & 0 deletions src/BetterDiscord/webpack.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export interface Webpack {
Filters: Filters;
getModule<T>(filter: FilterFunction, options?: FilterOptions): T | undefined;
getByKeys<T>(...keys: string[]): T | undefined;
getByPrototypeKeys<T>(...keys: string[] | [...string[], FilterOptions]): T | undefined;
getStore<T>(name: string): T | undefined;
}

Expand Down
62 changes: 0 additions & 62 deletions src/BlurNSFW/config.json

This file was deleted.

74 changes: 74 additions & 0 deletions src/BlurNSFW/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import {Manifest} from "../BetterDiscord/manifest";

const manifest: Manifest = {
info: {
name: "BlurNSFW",
authors: [{
name: "Zerebos",
discord_id: "249746236008169473",
github_username: "zerebos",
twitter_username: "IAmZerebos"
}],
version: "1.0.4",
description: "Blurs images and videos until you hover over them.",
github: "https://github.com/zerebos/BetterDiscordAddons/tree/master/Plugins/BlurNSFW",
github_raw: "https://raw.githubusercontent.com/zerebos/BetterDiscordAddons/master/Plugins/BlurNSFW/BlurNSFW.plugin.js"
},
changelog: [
{
title: "What's New?",
type: "added",
items: [
"Plugin no longer relies on ZeresPluginLibrary!",
]
},
{
title: "Bug Fixes & Info",
type: "fixed",
items: [
"Media should be blurred properly once again!",
"If things aren't blurred properly for you, it might be due to an experiment Discord is doing.",
"Once the experiment is more widely rolled out, I will add compatibility for it in this plugin."
]
}
],
config: [
{
type: "switch",
id: "blurNSFW",
name: "Blur NSFW Channels",
note: "This setting automatically blurs media in channels marked NSFW.",
value: true
},
{
type: "slider",
id: "blurSize",
name: "Blur Size",
note: "The size (in px) of the blurred pixels.",
value: 10,
min: 0,
max: 50,
units: "px"
},
{
type: "slider",
id: "blurTime",
name: "Blur Time",
note: "The time (in ms) it takes for the blur to disappear and reappear.",
value: 200,
min: 0,
max: 5000,
units: "ms"
},
{
type: "switch",
id: "blurOnFocus",
name: "Blur When Focused",
note: "This setting keeps the blur when clicking on/expanding an image.",
value: true
}
],
main: "index.ts"
};

export default manifest;
Loading

0 comments on commit 5d6c14a

Please sign in to comment.