Skip to content

Commit

Permalink
...again, regenerate hashes.
Browse files Browse the repository at this point in the history
Now, I've decided to actually hash the string directly, as I've noticed
varrying results when Electon has sometimes "crashed". I've also added a
check to prevent hashing empty strings and probably getting invalid
results.
  • Loading branch information
SpacingBat3 committed Aug 28, 2022
1 parent 441dc75 commit f698e45
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
4 changes: 2 additions & 2 deletions sources/code/common/global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ export function isJsonSyntaxCorrect(string: string) {
/** SHA1 hashes of Discord favicons (in RAW bitmap format). */
export const discordFavicons = {
/** Default favicon (without *blue dot* indicator). */
default: "a971976200e0abf8d8a9fad46b7309363ef3cd01",
unread: "3133ab8ef98ea83f1573f6c3902c027015c005bf"
default: "6f637da8422057ec825c3249f2b37714de34a65b",
unread: "f88f58f3f6689b21c3a3426c4c76855f9ad2044c"
};

/**
Expand Down
8 changes: 3 additions & 5 deletions sources/code/main/windows/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
BrowserView,
systemPreferences
} from "electron/main";
import { NativeImage, nativeImage } from "electron/common";
import * as getMenu from "../modules/menu";
import { discordFavicons, knownInstancesList } from "../../common/global";
import packageJson from "../../common/modules/package";
Expand Down Expand Up @@ -281,11 +280,10 @@ export default function createMainWindow(flags:MainWindowFlags): BrowserWindow {
// "Red dot" icon feature
let setFavicon: string | undefined;
win.webContents.on("page-favicon-updated", (_event, favicons) => {
let icon: NativeImage, flash = false;
// Convert from DataURL to RAW.
const faviconBuffer = nativeImage.createFromDataURL(favicons[0]??"").toPNG();
if(favicons[0] === undefined) return;
let icon: Electron.NativeImage, flash = false;
// Hash discord favicon.
const faviconHash = createHash("sha1").update(faviconBuffer).digest("hex");
const faviconHash = createHash("sha1").update(favicons[0]).digest("hex");
// Stop execution when icon is same as the one set.
if (faviconHash === setFavicon) return;
// Stop code execution on Fosscord instances.
Expand Down

0 comments on commit f698e45

Please sign in to comment.