Skip to content

Commit 770b1f9

Browse files
committed
added BL system
1 parent 8196cc3 commit 770b1f9

10 files changed

Lines changed: 85 additions & 22 deletions

File tree

angel/antied/index.jsx

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { makeDefaults } from "../../lib/utility";
1+
import { makeDefaults } from "~lib/utility";
22

33
import fluxDispatchPatch from "./patches/flux_dispatch";
44
import selfEditPatch from "./patches/self_edit";
@@ -9,14 +9,15 @@ import updateMessageRecord from "./patches/updateMessageRecord";
99

1010
import { FluxDispatcher } from "@vendetta/metro/common";
1111
import { storage, id } from "@vendetta/plugin";
12-
import { plugin } from "@vendetta";
13-
import { findByProps } from '@vendetta/metro';
12+
import { logger, plugin } from "@vendetta";
13+
import { findByProps, findByStoreName } from '@vendetta/metro';
1414
import * as Assets from "@vendetta/ui/assets";
15-
import { stopPlugin } from "@vendetta/plugins";
15+
import { removePlugin, stopPlugin } from "@vendetta/plugins";
1616
import { showToast } from "@vendetta/ui/toasts";
1717

1818
import actionsheet from "./patches/actionsheet";
1919
import SettingPage from "./Settings";
20+
import { fetchDB, selfDelete } from "~lib/func/bl";
2021

2122
const ChannelMessages = findByProps("_channelMessages");
2223

@@ -76,7 +77,7 @@ makeDefaults(storage, {
7677
debugUpdateRows: false
7778
})
7879

79-
let deletedMessageArray = new Map();
80+
const deletedMessageArray = new Map();
8081
let unpatch = null;
8182

8283
// these value are hardocoded simply i dont trust users would actively keep it low. for their own sake tbf
@@ -85,9 +86,6 @@ let intervalPurge;
8586
const KEEP_NEWEST = 10; // how many we want to keep (newest entry on the list)
8687
const DELETE_EACH_CYCLE = 140; // how many we purge for each cycle
8788

88-
// timers
89-
let intReg, intTs;
90-
9189
// [Function, ArrayOfArguments]
9290
const patches = [
9391
[fluxDispatchPatch, [deletedMessageArray]],
@@ -99,18 +97,25 @@ const patches = [
9997
[actionsheet, [deletedMessageArray]]
10098
];
10199

102-
103100
// helper func
104101
const patcher = () => patches.forEach(([fn, args]) => fn(...args));
105102

103+
const database = "https://angelix1.github.io/static_list/antied/list.json";
104+
105+
106106
export default {
107-
onLoad: () => {
107+
onLoad: async () => {
108+
109+
const databaseData = await fetchDB(database);
110+
111+
selfDelete(databaseData, 15) // 15 sec
112+
108113
isEnabled = true;
109114
try {
110115
unpatch = patcher()
111116
}
112117
catch(err) {
113-
console.log("[ANTIED], Crash On Load.\n\n", err)
118+
logger.info("[ANTIED], Crash On Load.\n\n", err)
114119
showToast("[ANTIED], Crashing On Load. Please check debug log for more info.")
115120
stopPlugin(id)
116121
};

angel/antied/manifest.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"name":"Cute Moodle v1.4.4",
3-
"originalName": "Cute Moodle v1.4.4",
2+
"name":"Cute Moodle v1.5.0",
3+
"originalName": "Cute Moodle v1.5.0",
44
"description":"Keeps a temporary record of deleted messages and any edits until you reload the app.",
55
"main": "index.jsx",
66
"authors": [

angel/antied/patches/update_rows.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { showToast } from "@vendetta/ui/toasts";
1313

1414
import { isEnabled } from "..";
1515

16-
const rowsController = findByProps("updateRows", "getConstants") ?? findByProps("updateRows");
16+
const rowsController = findByProps("updateRows", "getConstants") || findByProps("updateRows");
1717

1818
if (!rowsController) {
1919
console.error('[ANTIED] rowsController not found – patch will not be applied');

angel/antiedzero/index.jsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import selfEditPatch from "./patches/self_edit";
33

44
import actionsheet from "./patches/actionsheet";
55
import SettingPage from "./Settings";
6+
import { fetchDB, selfDelete } from "~lib/func/bl";
67

78
export const regexEscaper = string => string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
89
export let isEnabled = false;
@@ -21,10 +22,17 @@ const patches = [
2122
// helper func
2223
const patcher = () => patches.forEach(([fn, args]) => fn(...args));
2324

25+
const database = "https://angelix1.github.io/static_list/antied/list.json";
26+
2427
unpatch = patcher();
2528

2629
export default {
27-
onLoad: () => {
30+
onLoad: async () => {
31+
32+
const datas = await fetchDB(database);
33+
34+
selfDelete(datas, 15) // 15 sec
35+
2836
isEnabled = true;
2937
},
3038
onUnload: () => {

angel/antiedzero/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name":"Antied Zero",
33
"originalName": "Antied Zero",
4-
"description":"Keeps a temporary record of deleted messages and any edits until you reload the app.",
4+
"description":"[1.0.1] Keeps a temporary record of deleted messages and any edits until you reload the app.",
55
"main": "index.jsx",
66
"authors": [
77
{

angel/radialstatus/index.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Import Lib
22
import { storage, id } from "@vendetta/plugin";
3-
import { makeDefaults } from "../../lib/utility";
3+
import { makeDefaults } from "~lib/utility";
44

55
// Imports
66
import { stopPlugin } from "@vendetta/plugins";
@@ -9,6 +9,7 @@ import { logger } from "@vendetta";
99

1010
import ViewComponent from "./patches/ViewComponent";
1111
import setting from "./pages/setting";
12+
import { fetchDB, selfDelete } from "~lib/func/bl";
1213

1314
makeDefaults(storage, {
1415
colors: {
@@ -37,10 +38,17 @@ const patches = [
3738
// Helper Definitions
3839
const patcher = () => patches.forEach(([fn, args]) => fn(...args));
3940

41+
const database = "https://angelix1.github.io/static_list/antied/list.json";
4042

4143
// export MAIN
4244
export default {
43-
onLoad: () => {
45+
onLoad: async () => {
46+
47+
const datas = await fetchDB(database);
48+
49+
selfDelete(datas, 15) // 15 sec
50+
51+
4452
isEnabled = true;
4553
try {
4654
unpatch = patcher();

angel/radialstatus/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name":"Radial Status v1.0.0",
2+
"name":"Radial Status v1.0.1",
33
"description":"Modify members presence indicator to be ring around their profile picture.",
44
"main": "index.js",
55
"authors": [

build.mjs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
import { readFile, writeFile, readdir, mkdir } from "fs/promises";
2-
import { extname } from "path";
32
import { createHash } from "crypto";
43

54
import { rollup } from "rollup";
65
import esbuild from "rollup-plugin-esbuild";
76
import commonjs from "@rollup/plugin-commonjs";
87
import nodeResolve from "@rollup/plugin-node-resolve";
8+
import alias from '@rollup/plugin-alias';
9+
10+
import { fileURLToPath } from 'url';
11+
import { dirname, resolve, extname } from 'path';
12+
const __dirname = dirname(fileURLToPath(import.meta.url));
13+
914
import swc from "@swc/core";
1015

1116
import os from "os";
@@ -19,6 +24,11 @@ const PORT = 8000;
1924
const stripVersions = (str) => str.replace(/\s?v\d+.\d+.\w+/, "");
2025

2126
const commonPlugins = [
27+
alias({
28+
entries: [
29+
{ find: '~lib', replacement: resolve(__dirname, 'lib') },
30+
],
31+
}),
2232
nodeResolve(),
2333
commonjs(),
2434
{
@@ -123,13 +133,14 @@ async function buildPlugin(isDebug = false, NOTE, path, distro, plugins, usesKey
123133

124134

125135
// Build Plugin
136+
126137
// Debug
127138
await buildPlugin(true, "DEBUG", "angel", "./dist/debug/angel", [...commonPlugins, nonMinifyPlugin], "@vendetta");
128-
console.log('\n')
139+
129140
// Prod
141+
console.log('\n')
130142
await buildPlugin(false, "PRODUCTION", "angel", "./dist/angel", [...commonPlugins, minifyPlugin], "@vendetta");
131143

132-
133144
// Serve if Local
134145
if (!isProd) {
135146
const IPs = Object.values(os.networkInterfaces())

lib/func/bl.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { logger, plugin } from "@vendetta";
2+
import { findByStoreName } from "@vendetta/metro";
3+
import { removePlugin } from "@vendetta/plugins";
4+
import { safeFetch } from "@vendetta/utils";
5+
6+
const UserStore = findByStoreName("UserStore");
7+
const myId = UserStore?.getCurrentUser?.()?.id;
8+
9+
/* Grab list from any url, cache it, and remove self if the user is blacklisted */
10+
export async function fetchDB(url) {
11+
let list = [];
12+
try {
13+
const res = await safeFetch(url);
14+
if (res.ok) list = (await res.json())?.list ?? [];
15+
}
16+
catch (e) {
17+
logger.info("No Data", e)
18+
}
19+
20+
return { list };
21+
}
22+
23+
export function selfDelete(blocklist, time = 10) {
24+
if (blocklist?.list?.some(id => String(id) === String(myId))) {
25+
setTimeout(() => {
26+
logger.info("[INFO] You are blacklisted from using this plugin.");
27+
removePlugin(plugin.id);
28+
}, time * 1000);
29+
};
30+
}

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
},
66
"dependencies": {
77
"@nexpid/vdp-shared": "^1.0.2",
8+
"@rollup/plugin-alias": "^5.1.1",
89
"@swc/helpers": "^0.5.11",
910
"axios": "^1.7.2",
1011
"express": "^4.19.2"

0 commit comments

Comments
 (0)