75 lines
2.6 KiB
JavaScript
75 lines
2.6 KiB
JavaScript
const CONFIG_KEY = "rscord_config";
|
|
const DEFAULT_CONFIG = { customCss: "", revertStatusIcons: false };
|
|
|
|
function urlBase64ToUint8Array(base64String) {
|
|
const padding = "=".repeat((4 - (base64String.length % 4)) % 4);
|
|
const base64 = (base64String + padding)
|
|
.replace(/\-/g, "+")
|
|
.replace(/_/g, "/");
|
|
|
|
const rawData = atob(base64);
|
|
const outputArray = new Uint8Array(rawData.length);
|
|
|
|
for (let i = 0; i < rawData.length; i++) {
|
|
outputArray[i] = rawData.charCodeAt(i);
|
|
}
|
|
|
|
return outputArray;
|
|
}
|
|
|
|
function loadConfig() {
|
|
try {
|
|
return {
|
|
...DEFAULT_CONFIG,
|
|
...JSON.parse(localStorage_.getItem(CONFIG_KEY) || "{}")
|
|
};
|
|
} catch {
|
|
return { ...DEFAULT_CONFIG };
|
|
}
|
|
}
|
|
|
|
function saveConfig(patch) {
|
|
const config = loadConfig();
|
|
const updated = { ...config, ...patch };
|
|
localStorage_.setItem(CONFIG_KEY, JSON.stringify(updated));
|
|
return updated;
|
|
}
|
|
|
|
let proxied = window.XMLHttpRequest.prototype.setRequestHeader;
|
|
window.XMLHttpRequest.prototype.setRequestHeader = function() {
|
|
if (arguments[0] === "Authorization") {
|
|
window.AUTH_TOKEN = arguments[1];
|
|
}
|
|
return proxied.apply(this, [].slice.call(arguments));
|
|
};
|
|
|
|
window.CSS_CLASSES = {
|
|
container: "container-1zDvAE",
|
|
labelRow: "labelRow-2jl9gK",
|
|
label: "title-2dsDLn",
|
|
control: "control-1fl03-",
|
|
switchControl: "container-2nx-BQ",
|
|
switchControlChecked: "checked-25WXMf",
|
|
input: "input-2XRLou",
|
|
slider: "slider-32CRPX",
|
|
note: "note-2C4pGr",
|
|
description: "colorStandard-1Xxp1s size14-k_3Hy4 description-30xx7u formText-2ngGjI modeDefault-2fEh7a",
|
|
divider: "divider-_0um2u dividerDefault-3C2-ws",
|
|
tabItem: "item-3XjbnG",
|
|
selected: "selected-g-kMVV",
|
|
contentColumn: "contentColumn-1C7as6",
|
|
settingsRegion: "sidebarRegion-1VBisG",
|
|
contentRegion: "contentRegion-3HkfJJ",
|
|
settingsSidebar: "standardSidebarView-E9Pc3j",
|
|
userInfoTitle: "eyebrow-Ejf06y defaultColor-HXu-5n userInfoTitle-39qq0Y",
|
|
userInfoBody: "userInfoBody-1zgAd0 markup-eYLPri clamped-2ZePhX",
|
|
userInfoSectionHeader: "defaultColor-24IHKz eyebrow-Ejf06y defaultColor-HXu-5n userInfoSectionHeader-2mYYun",
|
|
userInfoText: "userInfoText-2MFCmH markup-eYLPri clamped-2ZePhX",
|
|
userInfoSection: "userInfoSection-3her-v",
|
|
title: "colorStandard-1Xxp1s size14-k_3Hy4 h1-34Txb0 title-3hptVQ defaultColor-2cKwKo defaultMarginh1-EURXsm",
|
|
miniTitle: "colorStandard-1Xxp1s size14-k_3Hy4 h5-2RwDNl title-3hptVQ title-1HgbhV",
|
|
hidden: "hidden-27eifz",
|
|
hamburger: "btnHamburger-3GF0_5",
|
|
textInput: "inputDefault-3FGxgL input-2g-os5",
|
|
nitroBadge: ".clickable-1knRMS[aria-label]",
|
|
}; |