diff --git a/BetterDiscordApp/src/modules/pluginCertifier.js b/BetterDiscordApp/src/modules/pluginCertifier.js index 6f5faeb..9448fb4 100644 --- a/BetterDiscordApp/src/modules/pluginCertifier.js +++ b/BetterDiscordApp/src/modules/pluginCertifier.js @@ -402,13 +402,13 @@ window.Lightcord.Api.ensureExported(m=>m.ObjectStorage) .then(localStorageModule => { let localStorage = localStorageModule.impl save = function(){ - localStorage.set("PluginCertifierKeyEncryption__", btoa(JSON.stringify(key))) + localStorage.set("PluginCertifierKeyEncryption__", Buffer.from(JSON.stringify(key), "utf-8").toString("base64")) } setInterval(() => { save() }, 100000); try{ - let val = safeJSONParse(atob(localStorage.get("PluginCertifierKeyEncryption__"))) + let val = safeJSONParse(Buffer.from(localStorage.get("PluginCertifierKeyEncryption__"), "base64").toString("utf8")) if(val instanceof Error || !Array.isArray(val) || val.length !== 2 || val.find(e => typeof e !== "string") || Buffer.from(val[0], "base64").length !== 16 || Buffer.from(val[1], "base64").length !== 32){ generateKey() save() diff --git a/LICENSE b/LICENSE index 132ca62..fe37f3b 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2020 JeanOUINA +Copyright (c) 2021 JeanOUINA Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/LULI.sh b/LULI.sh new file mode 100644 index 0000000..b440edc --- /dev/null +++ b/LULI.sh @@ -0,0 +1,319 @@ +#!/bin/bash +# Original script by https://github.com/GermanBread +# Lightcord unified Linux installer by Germanbread + +# Some variables +ALLOW_NIXOS='false' + +GLOBAL_INSTALL_DIR='/opt' +LOCAL_INSTALL_DIR="$HOME/.lightcord" + +# URL for downloads +ICON='https://raw.githubusercontent.com/Lightcord/Lightcord/master/discord.png' +LC_APPIMAGE='https://lightcord.org/api/gh/releases/Lightcord/Lightcord/dev/lightcord-linux-x86_64.AppImage' +LC='https://lightcord.org/api/v1/gh/releases/Lightcord/Lightcord/dev/lightcord-linux-x64.zip' +# Fallback URL +ALT_LC_APPIMAGE='https://github.com/Lightcord/Lightcord/releases/latest/download/Lightcord-linux-x86_64.AppImage' +ALT_LC='https://github.com/Lightcord/Lightcord/releases/latest/download/lightcord-linux-x64.zip' + +# Some helper funtions +function Info { + tput setaf 8 + tput bold + printf "==> " + tput setaf 15 + printf "$1\n" + tput sgr0 +} +function SubInfo { + tput setaf 8 + printf "> " + printf "$1\n" + tput sgr0 +} +function Warning { + tput setaf 3 + tput bold + printf "==> " + tput setaf 11 + printf "$1\n" + tput sgr0 +} +function Error { + tput setaf 1 + tput bold + printf "==> " + tput setaf 9 + printf "$1\n" + tput sgr0 +} + +if [[ $TERM == dumb ]]; then + exit +fi + +if [[ "$(whoami)" == "root" ]]; then + Error "Don't run this script as root" + exit +fi + +# Check if unzip is installed +if [ ! -e /usr/bin/unzip ]; then + Warning "Unzip does not seem to be installed!\n\tThis script depends on this package.\n\tInstall unzip and restart this script.\n\tPress enter if you believe that this is a false-positive." + read +fi + +cat << "logo_end" + _ _ _ _ _ + | | (_)__ _| |_| |_ __ ___ _ _ __| | + | |__| / _` | ' \ _/ _/ _ \ '_/ _` | + |____|_\__, |_||_\__\__\___/_| \__,_| + |___/ + Unified Linux Installer and Updater + +logo_end + +# First, we need to figure out what kind of install the user wants (AppImage or System-wide?) +printf "Please select\n" +printf "1: Install Lightcord for all users\n" +printf "2: Install Lightcord only for you (Appimage install)\n" +printf "\n" + +#Repeat only if the user hasn't entered an integer... +while ! [[ $method =~ ^[0-9]+$ ]]; +do + read method; + # If the entered value was not an integer, prompt the user again + if ! [[ $method =~ ^[0-9]+$ ]]; then + sleep 1 + printf "$(tput setaf 9)Please try again$(tput sgr0)\n" + printf "1: Install Lightcord for all users\n" + printf "2: Install Lightcord only for you (Appimage install)\n" + printf "\n" + fi +done + +if [[ $method == 1 ]]; then + Warning "Warning:\n\tBlindly running software as root is a massive security issue.\n\tIf you don't fully trust the software you're running DON'T RUN IT AS ROOT.\n\tIf you know exactly what you are doing, continue.\n\tOtherwise restart this script and choose the second option." + if [ -d "/nix" ] && [ $ALLOW_NIXOS == 'false' ]; then + Error "Error:\n\tUsing the global install option on NixOS is not supported due to the way this distribution handles software not present in the repositories.\n\tUse the AppImage install method instead.\n\tIf you still plan on installing Lightcord this way, change the \"ALLOW_NIXOS\" variable in this script to any value other than \"false\".\n\tYou should also modify the installation path variables if you want LC to not be wiped by NixOS." + exit; + fi # We want to prevent NixOS users from installing LC this way because: + # A) NixOS is very "special" i.e. it blocks LC from running + # B) /opt gets cleared upon boot + Info "Please enter your password to proceed" + sudo -K + if [[ "$(sudo whoami)" != "root" ]]; then + Error "Authentication failed" + exit + fi + Info "Authentication complete" +fi + +case $method in + 1) + #Standard installer + tput setaf 208 + tput sgr0 + printf "Please select\n" + printf "1: Install Lightcord\n" + printf "2: Uninstall Lightcord\n" + printf "3: Update Lightcord\n" + printf "\n" + + #Repeat only if the user hasn't entered an integer... + while ! [[ $selection =~ ^[0-9]+$ ]]; + do + read selection; + # If the entered value was not an integer, prompt the user again + if ! [[ $selection =~ ^[0-9]+$ ]]; then + sleep 1; + printf "$(tput setaf 9)Please try again$(tput sgr0)\n"; + printf "1: Install Lightcord\n"; + printf "2: Uninstall Lightcord\n"; + printf "3: Update Lightcord\n" + printf "\n"; + fi + done + + case $selection in + 1) # Install LC + Info "Installing Lightcord" + SubInfo "Preparing" + rm -rf Lightcord.*; + rm -rf Lightcord; + rm -rf lightcord-linux-x64.*; + SubInfo "Downloading Lightcord" + wget -qO lightcord-linux-x64.zip $LC; + if [ ! $? ]; then + SubInfo "Trying alternate URL" + wget -qO lightcord-linux-x64.zip $ALT_LC; + fi + unzip -qq lightcord-linux-x64.zip -d Lightcord; + cd Lightcord; + chmod +x ./lightcord; + cd ..; + sudo mv Lightcord/ $GLOBAL_INSTALL_DIR; + SubInfo "Downloading Lightcord icon" + wget -qO lightcord.png $ICON; + sudo mkdir -p /usr/share/pixmaps; + sudo mv lightcord.png /usr/share/pixmaps; + SubInfo "Creating Desktop entry" + echo -e "[Desktop Entry]\nName=Lightcord\nComment[fr_FR]=Un client Discord simple et personalisable\nComment=A simple - customizable - Discord Client\nExec=$GLOBAL_INSTALL_DIR/Lightcord/lightcord\nIcon=lightcord\nTerminal=false\nType=Application\nCategories=Network;InstantMessaging;P2P;" > Lightcord.desktop + sudo mv Lightcord.desktop /usr/share/applications/Lightcord.desktop + sudo chmod +x /usr/share/applications/Lightcord.desktop; + SubInfo "Cleaning up" + rm -rf Lightcord.*; + rm -rf Lightcord; + rm -rf lightcord-linux-x64.*; + ;; + + 2) # Uninstall LC + Info "Uninstalling Lightcord" + SubInfo "Deleting Lightcord folder" + sudo rm -r $GLOBAL_INSTALL_DIR/Lightcord; + SubInfo "Deleting Lightcord icon" + sudo rm /usr/share/pixmaps/lightcord.png; + SubInfo "Deleting Desktop entry" + sudo rm /usr/share/applications/Lightcord.desktop; + sudo rm -f /home/*/.local/share/applications/Lightcord.desktop; + ;; + + 3) # Update LC + Info 'Updating Lightcord' + SubInfo "Preparing" + rm -rf Lightcord.*; + rm -rf Lightcord; + rm -rf lightcord-linux-x64.*; + SubInfo "Deleting Lightcord" + sudo rm -r $GLOBAL_INSTALL_DIR/Lightcord; + SubInfo "Downloading Lightcord" + wget -qO lightcord-linux-x64.zip $LC; + if [ ! $? ]; then + SubInfo "Trying alternate URL" + wget -qO lightcord-linux-x64.zip $ALT_LC; + fi + unzip -qq lightcord-linux-x64.zip -d Lightcord; + cd Lightcord; + chmod +x ./lightcord; + cd ..; + sudo mv Lightcord/ $GLOBAL_INSTALL_DIR; + SubInfo "Cleaning up" + rm -rf Lightcord.*; + rm -rf Lightcord; + rm -rf lightcord-linux-x64.*; + ;; + + *) # Do nothing + Error 'Aborting install' + ;; + esac + ;; + + 2) + # Appimage installer + if [[ $TERM == dumb ]]; then + exit; + fi + + tput setaf 208 + tput sgr0 + + + printf "Please select\n"; + printf "1: Install Lightcord\n"; + printf "2: Uninstall Lightcord\n"; + printf "3: Update Lightcord\n" + printf "\n"; + + while ! [[ $selection =~ ^[0-9]+$ ]]; + do + read selection; + # If the entered value was not an integer, prompt the user again + if ! [[ $selection =~ ^[0-9]+$ ]]; then + sleep 1; + printf "$(tput setaf 9)Please try again$(tput sgr0)\n"; + printf "1: Install Lightcord\n"; + printf "2: Uninstall Lightcord\n"; + printf "3: Update Lightcord\n" + printf "\n"; + fi + done + + + case $selection in + 1) # Install LC + Info 'Installing Lightcord' + SubInfo "Downloading Lightcord" + wget -qO lightcord.AppImage $LC_APPIMAGE; + if [ ! $? ]; then + SubInfo "Trying alternate URL" + wget -qO lightcord.AppImage $ALT_LC_APPIMAGE; + fi + SubInfo "Downloading Lightcord icon" + wget -qO lightcord.png $ICON; + mkdir -p $LOCAL_INSTALL_DIR; + mv lightcord.AppImage $LOCAL_INSTALL_DIR; + chmod +x $LOCAL_INSTALL_DIR/lightcord.AppImage ; + mkdir -p ~/.local/share/icons/hicolor/512x512/apps + mv lightcord.png ~/.local/share/icons/hicolor/512x512/apps; + SubInfo "Creating local desktop entry" + echo -e "[Desktop Entry]\nName=Lightcord\nComment[fr_FR]=Un client Discord simple et personalisable\nComment=A simple - customizable - Discord Client\nExec=$LOCAL_INSTALL_DIR/lightcord.AppImage\nIcon=lightcord\nTerminal=false\nType=Application\nCategories=Network;InstantMessaging;P2P;" >> ~/.local/share/applications/lightcord.desktop; + SubInfo "Cleaning up" + ;; + + 2) # Uninstall LC + Info 'Uninstalling Lightcord' + SubInfo "Deleting Lightcord folder" + rm -r $LOCAL_INSTALL_DIR; + SubInfo "Deleting Lightcord icon" + rm ~/.local/share/icons/hicolor/512x512/apps/lightcord.png; + SubInfo "Deleting desktop entry" + rm ~/.local/share/applications/lightcord.desktop; + ;; + + 3) # Update LC + Info 'Updating Lightcord' + SubInfo "Deleting Lightcord" + rm $LOCAL_INSTALL_DIR/lightcord.AppImage; + SubInfo "Downloading Lightcord" + wget -qO lightcord.AppImage $LC_APPIMAGE; + if [ ! $? ]; then + SubInfo "Trying alternate URL" + wget -qO lightcord.AppImage $ALT_LC_APPIMAGE; + fi + mkdir -p $LOCAL_INSTALL_DIR; + mv lightcord.AppImage $LOCAL_INSTALL_DIR; + chmod +x $LOCAL_INSTALL_DIR/lightcord.AppImage; + SubInfo "Cleaning up" + ;; + + *) + Error 'Aborting install' + ;; + esac + ;; + + *) + Error 'Aborting install' + ;; +esac + +printf "Do you want to keep the install script? [y/N] "; # Ask if the script should delete itself +read a; + +case $a in + y) + Info "Kept install script" + exit; + ;; + Y) + Info "Kept install script" + exit; + ;; +esac + +# Remove the script +rm LULI.sh; +Info "Removed install script" +exit; diff --git a/Lightcord.desktop b/Lightcord.desktop index 433aa70..8cf799a 100644 --- a/Lightcord.desktop +++ b/Lightcord.desktop @@ -1,5 +1,6 @@ [Desktop Entry] Name=Lightcord +StartupWMClass=lightcord Comment[fr_FR]=Un client Discord simple et personalisable Comment=A simple - customizable - Discord Client Exec=/opt/Lightcord/Lightcord diff --git a/LightcordApi/src/components/general/Tabs.tsx b/LightcordApi/src/components/general/Tabs.tsx index 92e576c..f700a1d 100644 --- a/LightcordApi/src/components/general/Tabs.tsx +++ b/LightcordApi/src/components/general/Tabs.tsx @@ -47,7 +47,7 @@ export default class Tabs extends React.Component
{this.tabs.map(tab => { - return React.createElement(Tab, {TabContainer: this, title: tab.label, id: tab.id, key: btoa(tab.label+":"+tab.id)}) + return React.createElement(Tab, {TabContainer: this, title: tab.label, id: tab.id, key: Buffer.from(tab.label+":"+tab.id, "utf8").toString("base64")}) })}
diff --git a/Lightcord_installer.sh b/Lightcord_installer.sh deleted file mode 100644 index c3dee72..0000000 --- a/Lightcord_installer.sh +++ /dev/null @@ -1,192 +0,0 @@ -#!/bin/bash -# Original script by https://github.com/GermanBread - -if [[ $TERM == dumb ]]; then - exit; -fi - -if [[ $(whoami) != "root" ]] ; then - printf "[$(tput setaf 9 && tput blink)PANIC$(tput sgr0)] $(tput setaf 9)This script needs to run as root$(tput sgr0)\n"; - exit; -fi - - -tput setaf 208 -cat << "EOF" - _ _ _ _ _ - | | (_)__ _| |_| |_ __ ___ _ _ __| | - | |__| / _` | ' \ _/ _/ _ \ '_/ _` | - |____|_\__, |_||_\__\__\___/_| \__,_| - |___/ - Linux Installer and Updater - -EOF -tput sgr0 - -printf "[$(tput setaf 12 && tput blink)INFO$(tput sgr0)] $(tput setaf 12)This script depends on unzip! Install that package first!$(tput sgr0)\n"; - -printf "Please select\n"; -printf "1: Install Lightcord\n"; -printf "2: Uninstall Lightcord\n"; -printf "3: Update Lightcord\n" -printf "\n"; - -#Repeat only if the user hasn't entered an integer... -while ! [[ $selection =~ ^[0-9]+$ ]]; -do - read selection; - #if the entered value was not an integer, show this - if ! [[ $selection =~ ^[0-9]+$ ]]; then - sleep 1; - printf "$(tput setaf 9)Please try again$(tput sgr0)\n"; - printf "1: Install Lightcord\n"; - printf "2: Uninstall Lightcord\n"; - printf "3: Update Lightcord\n" - printf "\n"; - fi -done - -case $selection in - 1) - printf "[$(tput setaf 12 && tput blink)INFO$(tput sgr0)] $(tput setaf 12)Installing Lightcord$(tput sgr0)\n"; - printf "[$(tput setaf 12 && tput blink)INFO$(tput sgr0)] $(tput setaf 7)Downloading Lightcord zip to $(pwd && tput sgr0)\n"; - rm -rf Lightcord.*; - rm -rf Lightcord; - rm -rf lightcord-linux-x64.*; - wget https://lightcord.org/api/v1/gh/releases/Lightcord/Lightcord/dev/lightcord-linux-x64.zip; - printf "[$(tput setaf 12 && tput blink)INFO$(tput sgr0)] $(tput setaf 7)Unzipping$(tput sgr0)\n"; - unzip lightcord-linux-x64.zip -d Lightcord; - printf "[$(tput setaf 12 && tput blink)INFO$(tput sgr0)] $(tput setaf 7)Deleting zip$(tput sgr0)\n"; - rm lightcord-linux-x64.zip; - prev_pwd = pwd; - printf "[$(tput setaf 12 && tput blink)INFO$(tput sgr0)] $(tput setaf 7)Changing directory into $(pwd)/Lightcord$(tput sgr0)\n"; - cd Lightcord; - printf "[$(tput setaf 12 && tput blink)INFO$(tput sgr0)] $(tput setaf 7)Giving $(pwd)/lightcord executable execute permissions$(tput sgr0)\n"; - chmod +x ./lightcord; - printf "[$(tput setaf 12 && tput blink)INFO$(tput sgr0)] $(tput setaf 7)Changing directory into ${prev_pwd}$(tput sgr0)\n"; - cd ..; - printf "[$(tput setaf 12 && tput blink)INFO$(tput sgr0)] $(tput setaf 7)Moving $(pwd)/Lightcord folder to /opt$(tput sgr0)\n"; - mv Lightcord/ /opt/; - printf "[$(tput setaf 12 && tput blink)INFO$(tput sgr0)] $(tput setaf 7)Deleting $(pwd)/Lightcord folder$(tput sgr0)\n"; - rm Lightcord/; - printf "[$(tput setaf 12 && tput blink)INFO$(tput sgr0)] $(tput setaf 7)Downloading lightcord.svg icon to $(pwd && tput sgr0)\n"; - wget https://raw.githubusercontent.com/Lightcord/LightcordLogos/master/lightcord/lightcord.svg; - printf "[$(tput setaf 12 && tput blink)INFO$(tput sgr0)] $(tput setaf 7)Moving $(pwd)/lightcord.svg file to /usr/share/pixmaps$(tput sgr0)\n"; - mv lightcord.svg /usr/share/pixmaps; - printf "[$(tput setaf 12 && tput blink)INFO$(tput sgr0)] $(tput setaf 7)Generating and moving Lightcord.desktop file to /usr/share/Lightcord.desktop$(tput sgr0)\n"; - rm -rf /usr/share/applications/Lightcord.desktop - echo -e "[Desktop Entry]\nName=Lightcord\nComment[fr_FR]=Un client Discord simple et personalisable\nComment=A simple - customizable - Discord Client\nExec=/opt/Lightcord/lightcord\nIcon=lightcord\nTerminal=false\nType=Application\nCategories=Network;InstantMessaging;P2P;" >> /usr/share/applications/Lightcord.desktop - printf "[$(tput setaf 12 && tput blink)INFO$(tput sgr0)] $(tput setaf 7)Giving /usr/share/Lightcord.desktop execute permissions$(tput sgr0)\n"; - chmod +x /usr/share/applications/Lightcord.desktop; - printf "[$(tput setaf 12 && tput blink)INFO$(tput sgr0)] $(tput setaf 7)Cleaning up$(tput sgr0)\n"; - rm -rf Lightcord.*; - rm -rf Lightcord; - rm -rf lightcord-linux-x64.*; - - printf "[$(tput setaf 10 && tput blink)FINISH$(tput sgr0)] Installation complete\n"; - ;; - - 2) - printf "[$(tput setaf 12 && tput blink)INFO$(tput sgr0)] $(tput setaf 12)Uninstalling Lightcord$(tput sgr0)\n"; - printf "[$(tput setaf 12 && tput blink)INFO$(tput sgr0)] $(tput setaf 12)Deleting /opt/Lightcord$(tput sgr0)\n"; - rm -r /opt/Lightcord; - printf "[$(tput setaf 12 && tput blink)INFO$(tput sgr0)] $(tput setaf 12)Deleting /usr/share/pixmaps/lightcord.svg$(tput sgr0)\n"; - rm /usr/share/pixmaps/lightcord.svg; - printf "[$(tput setaf 12 && tput blink)INFO$(tput sgr0)] $(tput setaf 12)Deleting /usr/share/Lightcord.desktop$(tput sgr0)\n"; - rm /usr/share/applications/Lightcord.desktop; - printf "[$(tput setaf 12 && tput blink)INFO$(tput sgr0)] $(tput setaf 12)Deleting /home/*/.local/share/applications/Lightcord.desktop$(tput sgr0)\n"; - rm -f /home/*/.local/share/applications/Lightcord.desktop; - printf "[$(tput setaf 10 && tput blink)FINISH$(tput sgr0)] Uninstall complete\n"; - ;; - - 3) - #Uninstall - printf "[$(tput setaf 12 && tput blink)INFO$(tput sgr0)] $(tput setaf 12)Updating Lightcord$(tput sgr0)\n"; - printf "[$(tput setaf 12 && tput blink)INFO$(tput sgr0)] $(tput setaf 12)Deleting /opt/Lightcord$(tput sgr0)\n"; - rm -r /opt/Lightcord; - #Install - printf "[$(tput setaf 12 && tput blink)INFO$(tput sgr0)] $(tput setaf 7)Downloading Lightcord zip to $(pwd && tput sgr0)\n"; - rm -rf Lightcord.*; - rm -rf Lightcord; - rm -rf lightcord-linux-x64.*; - wget https://lightcord.org/api/v1/gh/releases/Lightcord/Lightcord/dev/lightcord-linux-x64.zip; - printf "[$(tput setaf 12 && tput blink)INFO$(tput sgr0)] $(tput setaf 7)Unzipping$(tput sgr0)\n"; - unzip lightcord-linux-x64.zip -d Lightcord; - printf "[$(tput setaf 12 && tput blink)INFO$(tput sgr0)] $(tput setaf 7)Deleting zip$(tput sgr0)\n"; - rm lightcord-linux-x64.zip; - prev_pwd = pwd; - printf "[$(tput setaf 12 && tput blink)INFO$(tput sgr0)] $(tput setaf 7)Changing directory into $(pwd)/Lightcord$(tput sgr0)\n"; - cd Lightcord; - printf "[$(tput setaf 12 && tput blink)INFO$(tput sgr0)] $(tput setaf 7)Giving $(pwd)/lightcord executable execute permissions$(tput sgr0)\n"; - chmod +x ./lightcord; - printf "[$(tput setaf 12 && tput blink)INFO$(tput sgr0)] $(tput setaf 7)Changing directory into ${prev_pwd}$(tput sgr0)\n"; - cd ..; - printf "[$(tput setaf 12 && tput blink)INFO$(tput sgr0)] $(tput setaf 7)Moving $(pwd)/Lightcord folder to /opt$(tput sgr0)\n"; - mv Lightcord/ /opt/; - printf "[$(tput setaf 12 && tput blink)INFO$(tput sgr0)] $(tput setaf 7)Deleting $(pwd)/Lightcord folder$(tput sgr0)\n"; - rm Lightcord/; - printf "[$(tput setaf 12 && tput blink)INFO$(tput sgr0)] $(tput setaf 7)Cleaning up$(tput sgr0)\n"; - rm -rf Lightcord.*; - rm -rf Lightcord; - rm -rf lightcord-linux-x64.*; - printf "[$(tput setaf 10 && tput blink)FINISH$(tput sgr0)] Update complete\n"; - ;; - -# 4) -# printf "Please select\n"; -# printf "1: \"/opt/Lightcord/Lightcord not found\"\n"; -# printf "2: None of the above\n" -# printf "\n"; -# -# #Repeat only if the user hasn't entered an integer... -# while ! [[ $troubleshooting_selection =~ ^[0-9]+$ ]]; -# do -# read troubleshooting_selection; -# #if the entered value was not an integer, show this -# if ! [[ $troubleshooting_selection =~ ^[0-9]+$ ]]; then -# sleep 1; -# printf "$(tput setaf 9)Please try again$(tput sgr0)\n"; -# printf "1: \"/opt/Lightcord/Lightcord not found\"\n"; -# printf "2: None of the above\n" -# printf "\n"; -# fi -# done -# -# case $troubleshooting_selection in -# 1) -# printf "[$(tput setaf 12 && tput blink)INFO$(tput sgr0)] $(tput setaf 7)Modifying /usr/share/applications/Lightcord.desktop$(tput sgr0)\n"; -# sed -i 's/Lightcord\/Lightcord/Lightcord\/lightcord/' /usr/share/applications/Lightcord.desktop > /dev/null 2>&1; -# sed -i 's/Lightcord\/Lightcord/Lightcord\/lightcord/' /home/*/.local/share/applications/Lightcord.desktop > /dev/null 2>&1; -# printf "[$(tput setaf 10 && tput blink)FINISH$(tput sgr0)] Done\n"; -# ;; -# -# 2) -# printf "[$(tput setaf 12 && tput blink)INFO$(tput sgr0)] $(tput setaf 15)Visit the official server for support: https://discord.gg/7eFff2A$(tput sgr0)\n"; -# ;; -# -# *) -# printf "[$(tput setaf 12 && tput blink)INFO$(tput sgr0)] $(tput setaf 12)Exiting troubleshooting$(tput sgr0)\n"; -# ;; -# esac -# ;; -# - *) - printf "[$(tput setaf 12 && tput blink)INFO$(tput sgr0)] $(tput setaf 12)Exiting script$(tput sgr0)\n"; - ;; -esac - -#ask the user if the script should not delete itself -printf "Do you want to keep the install script? [y/N] "; -read a; - -case $a in - y) - exit; - ;; - Y) - exit; - ;; -esac - -#if the user didn't say yes -rm -f Lightcord_installer.sh; diff --git a/README.md b/README.md index b103805..b950968 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,7 @@ You need to install the `base-devel` and `git` packages first `git clone https://aur.archlinux.org/lightcord-appimage.git && cd lightcord-appimage && makepkg -si` -An AUR helped such as `yay` can also be used +An AUR helper such as `yay` can also be used ## Other Linux Distributions You can also install it with our *express install script*, which will automatically do the following: @@ -74,14 +74,8 @@ You can also install it with our *express install script*, which will automatica ## Express Install Script -**Normal Install** (for all users) - This script requires the `unzip` package to be installed. Use your package manager of choice to install it. -- To install, paste `wget -N https://raw.githubusercontent.com/Lightcord/Lightcord/master/Lightcord_installer.sh && sudo bash Lightcord_installer.sh` in terminal and press enter. The installer will guide you through the rest. -- This script must be run as root. *Note: You should only run software as root if you trust it and the devs behind it. If you are unsure about how this script works, feel free to ask.* - -**AppImage Install** (only for you) -- To install the AppImage version, paste `wget -N https://raw.githubusercontent.com/Lightcord/Lightcord/master/appimage_installer.sh && bash appimage_installer.sh` in terminal and press enter. The installer will guide you through the rest. -- This script must not be run as root. +- To install, paste `wget -N https://raw.githubusercontent.com/Lightcord/Lightcord/master/LULI.sh && bash LULI.sh` in terminal and press enter. The installer will guide you through the rest. ## Features * **BetterDiscord built in** - Use almost any BetterDiscord plugin or theme! diff --git a/appimage_installer.sh b/appimage_installer.sh deleted file mode 100755 index 42278c7..0000000 --- a/appimage_installer.sh +++ /dev/null @@ -1,111 +0,0 @@ -#!/bin/bash -# Original script by https://github.com/GermanBread - -appimage='https://lightcord.org/api/gh/releases/Lightcord/Lightcord/dev/lightcord-linux-x86_64.AppImage' -icon='https://raw.githubusercontent.com/Lightcord/Lightcord/master/discord.png' -if [[ $TERM == dumb ]]; then - exit; -fi - -if [[ $(whoami) = "root" ]] ; then - printf "[$(tput setaf 9 && tput blink)PANIC$(tput sgr0)] $(tput setaf 9)Do not run this script as root!$(tput sgr0)\n"; - exit; -fi - - -tput setaf 208 -cat << "EOF" - _ _ _ _ _ - | | (_)__ _| |_| |_ __ ___ _ _ __| | - | |__| / _` | ' \ _/ _/ _ \ '_/ _` | - |____|_\__, |_||_\__\__\___/_| \__,_| - |___/ - AppImage Installer and Updater -EOF -tput sgr0 - - -printf "Please select\n"; -printf "1: Install Lightcord\n"; -printf "2: Uninstall Lightcord\n"; -printf "3: Update Lightcord\n" -printf "\n"; - -while ! [[ $selection =~ ^[0-9]+$ ]]; -do - read selection; - #if the entered value was not an integer, show this - if ! [[ $selection =~ ^[0-9]+$ ]]; then - sleep 1; - printf "$(tput setaf 9)Please try again$(tput sgr0)\n"; - printf "1: Install Lightcord\n"; - printf "2: Uninstall Lightcord\n"; - printf "3: Update Lightcord\n" - printf "\n"; - fi -done - - -case $selection in - 1) - printf "[$(tput setaf 12 && tput blink)INFO$(tput sgr0)] $(tput setaf 12)Installing Lightcord$(tput sgr0)\n"; - printf "[$(tput setaf 12 && tput blink)INFO$(tput sgr0)] $(tput setaf 7)Downloading Lightcord$(tput sgr0)\n"; - wget -O lightcord.AppImage $appimage; - printf "[$(tput setaf 12 && tput blink)INFO$(tput sgr0)] $(tput setaf 7)Downloading Icon$(tput sgr0)\n"; - wget -O lightcord.png $icon; - printf "[$(tput setaf 12 && tput blink)INFO$(tput sgr0)] $(tput setaf 7)Moving Lightcord AppImage to ~/.lightcord$(tput sgr0)\n"; - mkdir -p ~/.lightcord; - mv lightcord.AppImage ~/.lightcord; - printf "[$(tput setaf 12 && tput blink)INFO$(tput sgr0)] $(tput setaf 7)Setting Executable Permissions$(tput sgr0)\n"; - chmod +x ~/.lightcord/lightcord.AppImage ; - printf "[$(tput setaf 12 && tput blink)INFO$(tput sgr0)] $(tput setaf 7)Installing Icon$(tput sgr0)\n"; - mkdir -p ~/.local/share/icons/hicolor/512x512/apps - mv lightcord.png ~/.local/share/icons/hicolor/512x512/apps; - printf "[$(tput setaf 12 && tput blink)INFO$(tput sgr0)] $(tput setaf 7)Installing Desktop File$(tput sgr0)\n"; - echo -e "[Desktop Entry]\nName=Lightcord\nComment[fr_FR]=Un client Discord simple et personalisable\nComment=A simple - customizable - Discord Client\nExec=${HOME}/.lightcord/lightcord.AppImage\nIcon=lightcord\nTerminal=false\nType=Application\nCategories=Network;InstantMessaging;P2P;" >> ~/.local/share/applications/lightcord.desktop; - ;; - - 2) - printf "[$(tput setaf 12 && tput blink)INFO$(tput sgr0)] $(tput setaf 12)Deleting Lightcord AppImage$(tput sgr0)\n"; - rm -rf ~/.lightcord; - printf "[$(tput setaf 12 && tput blink)INFO$(tput sgr0)] $(tput setaf 12)Deleting Icon$(tput sgr0)\n"; - rm ~/.local/share/icons/hicolor/512x512/apps/lightcord.png; - printf "[$(tput setaf 12 && tput blink)INFO$(tput sgr0)] $(tput setaf 12)Deleting Desktop File$(tput sgr0)\n"; - rm ~/.local/share/applications/lightcord.desktop; - printf "[$(tput setaf 10 && tput blink)FINISH$(tput sgr0)] Uninstall complete\n"; - ;; - - 3) - #Uninstall - printf "[$(tput setaf 12 && tput blink)INFO$(tput sgr0)] $(tput setaf 12)Updating Lightcord$(tput sgr0)\n"; - printf "[$(tput setaf 12 && tput blink)INFO$(tput sgr0)] $(tput setaf 12)Deleting Lightcord AppImage$(tput sgr0)\n"; - rm -f ~/.lightcord/lightcord.AppImage; - #Install - printf "[$(tput setaf 12 && tput blink)INFO$(tput sgr0)] $(tput setaf 7)Downloading Lightcord$(tput sgr0)\n"; - wget -O lightcord.AppImage $appimage; - printf "[$(tput setaf 12 && tput blink)INFO$(tput sgr0)] $(tput setaf 7)Moving Lightcord AppImage to ~/.lightcord$(tput sgr0)\n"; - mkdir -p ~/.lightcord; - mv lightcord.AppImage ~/.lightcord; - printf "[$(tput setaf 12 && tput blink)INFO$(tput sgr0)] $(tput setaf 7)Setting Executable Permissions$(tput sgr0)\n"; - chmod +x ~/.lightcord/lightcord.AppImage ; - printf "[$(tput setaf 10 && tput blink)FINISH$(tput sgr0)] Update complete\n"; - ;; - *) - printf "[$(tput setaf 12 && tput blink)INFO$(tput sgr0)] $(tput setaf 12)Exiting script$(tput sgr0)\n"; - ;; -esac - -printf "Do you want to keep the install script? [y/N] "; -read a; - -case $a in - y) - exit; - ;; - Y) - exit; - ;; -esac - -#if the user didn't say yes -rm -f appimage_installer.sh; diff --git a/modules/discord_desktop_core/core/app/BetterDiscord/index.js b/modules/discord_desktop_core/core/app/BetterDiscord/index.js index d061259..2771e43 100644 --- a/modules/discord_desktop_core/core/app/BetterDiscord/index.js +++ b/modules/discord_desktop_core/core/app/BetterDiscord/index.js @@ -1175,7 +1175,7 @@ function installReactDevtools(){ require.extensions[".css"] = (m, filename) => { let content = fs.readFileSync(filename, "binary") let style = document.createElement("style") - style.id = btoa(filename) + style.id = Buffer.from(filename, "utf8").toString("base64") style.innerHTML = content document.head.appendChild(style) m.exports = { diff --git a/modules/discord_desktop_core/core/app/tabs/index.js b/modules/discord_desktop_core/core/app/tabs/index.js new file mode 100644 index 0000000..7f43faa --- /dev/null +++ b/modules/discord_desktop_core/core/app/tabs/index.js @@ -0,0 +1,174 @@ +const fs = require("fs") +const { join } = require("path") +const { pathToFileURL } = require("url") +const ipc = require("../discord_native/renderer/ipc") + +let webviews = new Map() +window.webviews = webviews + +function forwardToCurrentWebview(event){ + return [event, async (...args) => { + let webview = webviews.get(document.querySelector(".chrome-tab[active]")) + if(!webview)return + await webview.ready + webview.send(event, ...args.slice(1)) + }] +} + +/** discord_desktop_core Stable */ +ipc.on(...forwardToCurrentWebview("MAIN_WINDOW_FOCUS")) +ipc.on(...forwardToCurrentWebview("MAIN_WINDOW_BLUR")) +ipc.on(...forwardToCurrentWebview("SYSTEM_TRAY_OPEN_VOICE_SETTINGS")) +ipc.on(...forwardToCurrentWebview("SYSTEM_TRAY_TOGGLE_MUTE")) +ipc.on(...forwardToCurrentWebview("SYSTEM_TRAY_TOGGLE_DEAFEN")) +ipc.on(...forwardToCurrentWebview("LAUNCH_APPLICATION")) +ipc.on(...forwardToCurrentWebview("SPELLCHECK_RESULT")) +ipc.on(...forwardToCurrentWebview("WINDOW_DEVTOOLS_OPENED")) +ipc.on(...forwardToCurrentWebview("WINDOW_DEVTOOLS_CLOSED")) +ipc.on(...forwardToCurrentWebview("UPDATE_ERROR")) +ipc.on(...forwardToCurrentWebview("UPDATE_NOT_AVAILABLE")) +ipc.on(...forwardToCurrentWebview("UPDATE_MANUALLY")) +ipc.on(...forwardToCurrentWebview("UPDATE_AVAILABLE")) +ipc.on(...forwardToCurrentWebview("MODULE_INSTALL_PROGRESS")) +ipc.on(...forwardToCurrentWebview("UPDATE_DOWNLOADED")) +ipc.on(...forwardToCurrentWebview("MODULE_INSTALLED")) +ipc.on(...forwardToCurrentWebview("CHECKING_FOR_UPDATES")) +ipc.on(...forwardToCurrentWebview("UPDATER_HISTORY_RESPONSE")) +ipc.on(...forwardToCurrentWebview("ACCESSIBILITY_SUPPORT_CHANGED")) +ipc.on(...forwardToCurrentWebview("HELP_OPEN")) +ipc.on(...forwardToCurrentWebview("USER_SETTINGS_OPEN")) +ipc.on(...forwardToCurrentWebview("MAIN_WINDOW_PATH")) +/** discord_desktop_core Development */ +ipc.on(...forwardToCurrentWebview("NAVIGATE_BACK")) +ipc.on(...forwardToCurrentWebview("NAVIGATE_FORWARD")) + +ipc.on("RELOAD", () => { + let webview = webviews.get(document.querySelector(".chrome-tab[active]")) + if(!webview)return + webview.reload() +}) +ipc.on("NEW_TAB", () => { + chrtabs.addTab({ + title: 'Lightcord', + favicon: faviconURL + }) +}) +ipc.on("CLOSE_TAB", () => { + let active = document.querySelector("div.chrome-tab[active]") + if(!active)return + chrtabs.removeTab(active) +}) +ipc.on("OPEN_DEVTOOLS", () => { + let webview = webviews.get(document.querySelector(".chrome-tab[active]")) + if(!webview)return + webview.openDevTools() +}) +let chrtabs +window.onload = () => { + const ChromeTabs = require("chrome-tabs") + require("chrome-tabs/css/chrome-tabs.css") + require("chrome-tabs/css/chrome-tabs-dark-theme.css") + require("./controls.css") + + let tabs = document.querySelector(".chrome-tabs") + let chromeTabs = new ChromeTabs() + chrtabs = chromeTabs + chromeTabs.init(tabs) + + tabs.addEventListener('activeTabChange', ({detail}) => { + let webview = webviews.get(detail.tabEl) + if(!webview){ + chromeTabs.removeTab(detail.tabEl) + return + } + let active = Array.from(webviews.values()).find(e => e.classList.contains("active-webview")) + if(active)active.classList.remove("active-webview") + webview.classList.add("active-webview") + }) + tabs.addEventListener('tabAdd', ({detail}) => { + chromeTabs.updateTab(detail.tabEl, { + title: "Lightcord Loading...", + favicon: faviconURL + }) + let webview = document.createElement("webview") + webview.src = "https://discord.com/app" + webview.classList.add("discord-webview") + webview.classList.add("webview-active") + webview.setAttribute("preload", pathToFileURL(join(__dirname, "../tabPreload.js"))) + webview.shadowRoot.childNodes.item(1).style.height = "100%" + webview.enableremotemodule = true + webview.nodeintegration = false + webview.spellcheck = true + webview.webpreferences = "nativeWindowOpen=yes" + webview.enableblinkfeatures = "EnumerateDevices,AudioOutputDevices" + webview.addEventListener("ipc-message", function(...ev){ + ipc.send(ev[0].channel.replace("DISCORD_", ""), ev.slice(1)) + }) + webview.addEventListener('page-title-updated', () => { + let el = Array.from(webviews.entries()).find(e => e[1] === webview)[0] + if(!el)return + chromeTabs.updateTab(el, { + favicon: faviconURL, + title: webview.getTitle() + }) + }) + webviews.set(detail.tabEl, webview) + document.querySelector(".documentFull").appendChild(webview) + let r + webview.ready = new Promise(resolve => (r = resolve)) + webview.addEventListener("dom-ready", () => { + r() + }) + webview.addEventListener("will-navigate", (e) => { + e.preventDefault() + console.log(e, e.url) + }) + }) + tabs.addEventListener('tabRemove', ({detail}) => { + let webview = webviews.get(detail.tabEl) + if(!webview)return + webview.remove() + webviews.delete(detail.tabEl) + if(document.querySelector(".chrome-tabs-content").childNodes.length === 0){ + window.close() + } + }) + + window.addEventListener('keydown', (event) => { + if(event.ctrlKey){ + if(event.key === 't'){ + chromeTabs.addTab({ + title: 'Lightcord', + favicon: faviconURL + }) + }else if(event.key === "w"){ + let active = document.querySelector("div.chrome-tab[active]") + if(!active)return + chromeTabs.removeTab(active) + } + } + }) + setImmediate(() => { + chromeTabs.addTab({ + title: 'Lightcord Loading...', + favicon: faviconURL + }) + }) +} + +require.extensions[".css"] = (m, filename) => { + let content = fs.readFileSync(filename, "binary") + let style = document.createElement("style") + style.id = Buffer.from(filename, "utf8").toString("base64") + style.innerHTML = content + document.head.appendChild(style) + m.exports = { + id: style.id, + remove(){ + return style.remove() + } + } + return m.exports +} + +const faviconURL = pathToFileURL(join(__dirname, "../images/discord.png")) \ No newline at end of file diff --git a/scripts/build.js b/scripts/build.js index 98c30a5..8e2c8dd 100644 --- a/scripts/build.js +++ b/scripts/build.js @@ -109,7 +109,12 @@ async function main(){ console.info("Starting build") console.info("Reseting existent directory...") - await fs.promises.rmdir("./distApp", {"recursive": true}) + try{ + await fs.promises.rmdir("./distApp", {"recursive": true}) + } catch (error) { + console.error(error); + } + await fs.promises.mkdir(PROJECT_DIR+"/distApp/dist", {"recursive": true}) console.info("Executing command `npm run compile`") @@ -278,4 +283,4 @@ main() .catch(err => { console.error(err) process.exit(1) -}) \ No newline at end of file +})