Adding Blur option

This commit is contained in:
Jean Ouina 2020-06-06 21:10:14 +02:00
parent 002ba418bf
commit da94a8e5c1
8 changed files with 97 additions and 12 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -55,6 +55,7 @@ export const settings = {
/** LightCord */
"Disable BetterDiscord": {id: "bd-disable", info: "Disable Betterdiscord (plugins, themes, etc).", implemented: false, hidden: false, cat: "lightcord", category: "Lightcord"},
"Blur Personnal Informations":{id: "lightcord-6", info: "Blur sensitive informations like email, payment infos and more.", implemented: true, hidden: false, cat: "lightcord", category: "Lightcord"},
"Calling Ring Beat": {id: "lightcord-2", info: "Enable Discord's special calling beat.", implemented: true, hidden: false, cat: "lightcord", category: "Lightcord"},
"Developer Options": {id: "lightcord-1", info: "Enable Discord's Internal Developer Options. This allow the \"Experiments\" tab and the \"Developer Options\" tab. (must close and reopen settings)", implemented: true, hidden: false, cat: "lightcord", category: "Lightcord"},
"Ad Block": {id: "lightcord-4", info: "Block any BOT that dm you with an invite link. Even in an embed.", implemented: true, hidden: false, cat: "lightcord", category: "Lightcord"},
@ -105,7 +106,8 @@ export const defaultCookie = {
"lightcord-presence-1": false,
"lightcord-3": false,
"lightcord-4": false,
"lightcord-5": true
"lightcord-5": true,
"lightcord-6": true
};

View File

@ -7,6 +7,12 @@ let DMModule = BDModules.get(e => e.default && e.default.closePrivateChannel)[0]
const blocked = {}
let userModule = BDModules.get(e => e.default && e.default.getCurrentUser)[0]
function getCurrentUser(){
if(userModule)return userModule.default.getCurrentUser()
return null
}
export default new class AntiBotDM {
constructor(){
this.antiDM = this.antiDM.bind(this)
@ -29,6 +35,7 @@ export default new class AntiBotDM {
antiDM(ev){
if(!ev.message.author.bot)return
if(ev.message.author.id === getCurrentUser().id)
if(ev.message.guild_id)return
const channel = ChannelModule.getChannel(ev.message.channel_id)

View File

@ -0,0 +1,53 @@
/**
* Credits to @hellbound1337 on github for the css
*/
import DOMTools from "./domtools"
let selectors
function getSelectors(){
let standardSidebarView = BDModules.get(e => e.standardSidebarView)[0]
if(!standardSidebarView)return null
let defaultClassName = removeDa(standardSidebarView.standardSidebarView)
let selects = []
selects.push(`#app-mount .${defaultClassName} .payment-info .${removeDa(BDModules.get(e => e.description && typeof e.description === "string" && e.description.includes("formText"))[0].description)}`)
selects.push(`#app-mount .${defaultClassName} .${removeDa(BDModules.get(e => e.paymentSourceRow)[0].paymentSourceRow)} .${removeDa(BDModules.get(e => e.subText && e.descriptionWrapper)[0].subText)}`)
selects.push(`#app-mount .${defaultClassName} .${removeDa(BDModules.get(e => e.userSettingsAccount)[0].userSettingsAccount)} div:nth-child(2)>div:nth-child(2)>.${removeDa(BDModules.get(e => e.viewBody)[0].viewBody)}`)
return selects
}
function removeDa(className){
if(!className)return className
return className.split(" ").filter(e => !e.startsWith("da-")).join(" ")
}
export default new class BlurPrivate {
constructor(){
this.enabled = false
}
enable(){
if(this.enabled)return
this.enabled = true
selectors = selectors || getSelectors()
if(!selectors)console.error(new Error("Couldn't find selectors to blur personnal informations."))
DOMTools.addStyle("blurPrivate", `
${selectors[0]}, ${selectors[1]}, ${selectors[2]} {
transition: all 150ms cubic-bezier(.55,.085,.68,.53);
filter: blur(4px);
opacity: .8;
}
${selectors[0]}:hover, ${selectors[1]}:hover, ${selectors[2]}:hover {
transition: all 150ms cubic-bezier(.55,.09,.68,.53);
filter: none;
opacity: 1;
}`)
}
disable(){
if(!this.enabled)return
this.enabled = false
DOMTools.removeStyle("blurPrivate")
}
}

View File

@ -26,6 +26,7 @@ import CustomRichPresence from "./CustomRichPresence";
import V2C_AccountInfos from "../ui/AccountInfos";
import { remote } from "electron";
import AntiAdDM from "./AntiAdDM";
import blurPrivate from "./blurPrivate";
export default new class V2_SettingsPanel {
@ -236,6 +237,13 @@ export default new class V2_SettingsPanel {
AntiAdDM.disable()
}
}
if (id === "lightcord-6") {
if(enabled){
blurPrivate.enable()
}else{
blurPrivate.disable()
}
}
this.saveSettings();
}
@ -255,6 +263,7 @@ export default new class V2_SettingsPanel {
if (settingsCookie["lightcord-presence-1"]) CustomRichPresence.enable()
if (settingsCookie["lightcord-3"]) remote.getCurrentWindow().setAlwaysOnTop(true)
if (settingsCookie["lightcord-4"]) AntiAdDM.enable()
if (settingsCookie["lightcord-6"]) blurPrivate.enable()
if (settingsCookie["fork-ps-5"]) {
ContentManager.watchContent("plugin");

View File

@ -277,10 +277,9 @@ async function privateInit(){
data.user.premium = true
data.user.premium_type = 1
data.user.email = data.user.email || uuid()+"@lightcord.xyz" // filler email, not a real one
data.experiments = data.experiments ||[]
data.experiments = data.experiments || []
data.guild_experiments = data.guild_experiments || [];
data.connected_accounts = data.connected_accounts || [];
data.user_guild_settings = data.user_guild_settings || [];
data.relationships = data.relationships || [];
data.notes = data.notes || {};
data.user_feed_settings = data.user_feed_settings || [];
@ -787,7 +786,7 @@ require.extensions[".css"] = (m, filename) => {
let content = fs.readFileSync(filename, "binary")
let style = document.createElement("style")
style.id = btoa(filename)
style.innerText = content
style.innerHTML = content
document.head.appendChild(style)
m.exports = {
id: style.id,

View File

@ -5,7 +5,8 @@ const moduleUpdater = electron.remote.getGlobal('moduleUpdater');
const remoteApp = electron.remote.app;
function getVersion() {
return remoteApp.getVersion();
// Hardcoding HostVersion so Discord doesn't detect Lightcord by this
return "0.0.306" //remoteApp.getVersion();
}
const allowedAppPaths = new Set(['home', 'appData', 'desktop', 'documents', 'downloads']);