Skip to content
This repository has been archived by the owner on May 24, 2024. It is now read-only.

Commit

Permalink
SHADOWBAN DETECTION
Browse files Browse the repository at this point in the history
  • Loading branch information
PoneyClairDeLune committed Jul 25, 2023
1 parent 75d57d8 commit 89b9ef6
Show file tree
Hide file tree
Showing 9 changed files with 98 additions and 14 deletions.
4 changes: 2 additions & 2 deletions dist/web.js.txt

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion sh/bunTest.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/bin/bash
export NO_UPDATE=1
export TEMPLATE_URL=
bun run dist/bun.js "$@"
exit
1 change: 0 additions & 1 deletion sh/denoTest.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/bin/bash
export NO_UPDATE=1
export TEMPLATE_URL=
deno run --allow-net --allow-env --allow-read --allow-write dist/deno.js "$@"
exit
1 change: 0 additions & 1 deletion sh/nodeTest.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/bin/bash
export NO_UPDATE=1
export TEMPLATE_URL=
node dist/node.js "$@"
exit
7 changes: 6 additions & 1 deletion src/core/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,12 @@ let waitForProxy = async function () {
};

let main = async function (args) {
svc.tpl = WingBlade.env.get("TEMPLATE_URL", "https://uis246.github.io/template/pointer.json");
svc.tpl = WingBlade.env.get("TEMPLATE_URL");
if (!svc.tpl) {
console.info(`[Core] No custom pointer defined. Using default template.`);
//console.info(WingBlade.env.toObject());
svc.tpl = "https://uis246.github.io/template/pointer.json";
};
let acct = args[1], pass = args[2], otp = args[3];
console.info(`${BuildInfo.name}@${WingBlade.rt.variant} ${WingBlade.rt.os}_v${BuildInfo.ver}`);
let updateThread;
Expand Down
34 changes: 29 additions & 5 deletions src/core/monalisa.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ let Monalisa = class extends CustomEventSource {
loggedIn = false;
wsActive = false;
userdata;
username;
session;
appUrl;
colourIndex = -1;
Expand Down Expand Up @@ -143,15 +144,15 @@ let Monalisa = class extends CustomEventSource {
//console.info(graphQlRep);
let graphQlRaw = await graphQlRep.json();
console.info(graphQlRaw);
return graphQlRaw.data.act.data[0].data;
return graphQlRaw?.data?.act?.data[0]?.data;
};
async partitionPixels() {
if (this.pg) {
console.info("Waiting for CanvasConfiguration.");
console.info("[Monalisa] Waiting for CanvasConfiguration.");
await this.whenCcReady();
console.info("CanvasConfiguration OK. Waiting for template.");
console.info("[Monalisa] CanvasConfiguration OK. Waiting for template.");
await this.pg.whenTemplateReady();
console.info("Template OK. Partitioning...");
console.info("[Monalisa] Template OK. Partitioning...");
delete this.cc.pp;
let partitionPixels = [];
// Add canvas ID information to each pixel
Expand Down Expand Up @@ -333,12 +334,35 @@ let Monalisa = class extends CustomEventSource {
console.info(`[Monalisa] No palette colour available for (${selectedPixel[4]}, ${selectedPixel[5]}, ${selectedPixel[6]}).`);
return;
};
let beforePlacement = await this.getPixelHistory(this.#x, this.#y, colour[3]);
//console.info(beforePlacement);
this.lastColour = `rgba(${colour[0]},${colour[1]},${colour[2]})`;
if (await this.placePixel({ci: colour[3]})) {
this.cc.damage.remove(selectedPixel);
this.cc.damaged --;
console.info(`[Monalisa] Painted (${this.#x}, ${this.#y}) as ${colour[3]}, P(${colour[0], colour[1], colour[2]}) D(${selectedPixel[4]}, ${selectedPixel[5]}, ${selectedPixel[6]}).`);
} else {
await WingBlade.util.sleep(600);
let afterPlacement = await this.getPixelHistory(this.#x, this.#y, colour[3]);
//console.info(afterPlacement);
if (afterPlacement?.userInfo?.username == this.username) {
// Confirmed placement
this.dispatchEvent("pixelconfirm");
console.info(`[Monalisa] Pixel placement confirmed for user ${this.username}!`);
} else {
if (afterPlacement.lastModifiedTimestamp != beforePlacement.lastModifiedTimestamp) {
// The canvas was overwritten
this.dispatchEvent("pixeloverwrite");
console.info(`[Monalisa] Weak pixel contradiction for user ${this.username}!`);
console.info(`[Monalisa] Before: ${JSON.stringify(beforePlacement)}`);
console.info(`[Monalisa] After: ${JSON.stringify(afterPlacement)}`);
} else {
// The canvas hasn't changed at all
this.dispatchEvent("pixelcontradict");
console.info(`[Monalisa] Strong pixel contradiction for user ${this.username}!`);
console.info(`[Monalisa] Before: ${JSON.stringify(beforePlacement)}`);
console.info(`[Monalisa] After: ${JSON.stringify(afterPlacement)}`);
};
};
console.info(`[Monalisa] Failed to paint (${this.#x}, ${this.#y}) as ${colour[3]}, P(${colour[0], colour[1], colour[2]}) D(${selectedPixel[4]}, ${selectedPixel[5]}, ${selectedPixel[6]}).`);
};
};
Expand Down
54 changes: 53 additions & 1 deletion src/core/multiman.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ let MultiUserManager = class extends CustomEventSource {
e.redditAuth = new RedditAuth(e.fc);
e.monalisa.cc = this.cc;
e.monalisa.pg = this.pg;
e.monalisa.username = confObj.acct;
e.conf = confObj;
confObj.placed = confObj.placed || 0;
let genericUpdate = async () => {
Expand Down Expand Up @@ -272,6 +273,57 @@ let MultiUserManager = class extends CustomEventSource {
};
this.dispatchEvent("userupdate", acct);
});
e.monalisa.addEventListener("pixelban", async () => {
confObj.pstate = 0;
await genericUpdate();
if (this.pg.name == "mlp") {
this.an?.sendError("PALETTE_PIXEL_");
} else if (this.pg.name) {
this.an?.sendError(`PALETTE_PIXEL__${this.pg.name.toUpperCase()}`);
} else {
this.an?.sendError("PALETTE_PIXEL__OTHER");
};
this.dispatchEvent("userupdate", acct);
});
e.monalisa.addEventListener("pixelconfirm", async () => {
confObj.pstate = 0;
await genericUpdate();
confObj.confirm = (confObj.confirm || 0) + 1;
if (this.pg.name == "mlp") {
this.an?.sendError("PALETTE_PIXEL_CONFIRM");
} else if (this.pg.name) {
this.an?.sendError(`PALETTE_PIXEL_CONFIRM_${this.pg.name.toUpperCase()}`);
} else {
this.an?.sendError("PALETTE_PIXEL_CONFIRM_OTHER");
};
this.dispatchEvent("userupdate", acct);
});
e.monalisa.addEventListener("pixeloverwrite", async () => {
confObj.pstate = 0;
await genericUpdate();
confObj.nfp = (confObj.nfp || 0) + 1;
if (this.pg.name == "mlp") {
this.an?.sendError("PALETTE_PIXEL_OVERWRITE");
} else if (this.pg.name) {
this.an?.sendError(`PALETTE_PIXEL_OVERWRITE_${this.pg.name.toUpperCase()}`);
} else {
this.an?.sendError("PALETTE_PIXEL_OVERWRITE_OTHER");
};
this.dispatchEvent("userupdate", acct);
});
e.monalisa.addEventListener("pixelcontradict", async () => {
confObj.pstate = 0;
await genericUpdate();
confObj.nfn = (confObj.nfn || 0) + 1;
if (this.pg.name == "mlp") {
this.an?.sendError("PALETTE_PIXEL_CONTRADICT");
} else if (this.pg.name) {
this.an?.sendError(`PALETTE_PIXEL_CONTRADICT_${this.pg.name.toUpperCase()}`);
} else {
this.an?.sendError("PALETTE_PIXEL_CONTRADICT_OTHER");
};
this.dispatchEvent("userupdate", acct);
});
e.monalisa.addEventListener("pixelwait", async () => {
confObj.pstate = 4;
await genericUpdate();
Expand Down Expand Up @@ -396,7 +448,7 @@ let MultiUserManager = class extends CustomEventSource {
console.info(`[MultiMan] User ${uname} is selected on sweep.`);
if (this.conf.users[uname].nextAt <= Date.now()) {
console.info(`[MultiMan] Waiting out rate limits for ${uname}.`);
await WingBlade.util.sleep(15000, 5000);
await WingBlade.util.sleep(5000, 5000);
};
(async () => {
if (e.active) {
Expand Down
2 changes: 1 addition & 1 deletion src/web/index.htm

Large diffs are not rendered by default.

8 changes: 7 additions & 1 deletion src/web/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,10 @@ document.addEventListener("alpine:init", () => {
lastColour: userData.lastColour,
placed: userData.placed,
nextAt: userData.nextAt,
pstate: userData.pstate
pstate: userData.pstate,
confirm: userData.confirm,
nfp: userData.nfp,
nfn: userData.nfn
});
rebuildAcctIndex();
} else {
Expand All @@ -183,6 +186,9 @@ document.addEventListener("alpine:init", () => {
e.placed = userData.placed;
e.nextAt = userData.nextAt;
e.pstate = userData.pstate;
e.confirm = userData.confirm;
e.nfp = userData.nfp;
e.nfn = userData.nfn;
};
let manipulator = userMan[userIndex[data.data]];
break;
Expand Down

0 comments on commit 89b9ef6

Please sign in to comment.