mirror of
				https://github.com/smartfrigde/armcord.git
				synced 2024-08-14 23:56:58 +00:00 
			
		
		
		
	update.rocks updater, desktop capture fix, url changed back to stable
This commit is contained in:
		
							parent
							
								
									747e98c5af
								
							
						
					
					
						commit
						6bec720084
					
				
					 7 changed files with 236 additions and 6 deletions
				
			
		|  | @ -3,7 +3,7 @@ | ||||||
| 
 | 
 | ||||||
| <head> | <head> | ||||||
|   <meta charset="UTF-8" /> |   <meta charset="UTF-8" /> | ||||||
|   <meta http-equiv="refresh" content="5; URL=https://canary.discord.com/app" /> |   <meta http-equiv="refresh" content="5; URL=https://discord.com/app" /> | ||||||
|   <title>ArmCord</title> |   <title>ArmCord</title> | ||||||
|   <style> |   <style> | ||||||
|     :root { |     :root { | ||||||
|  |  | ||||||
							
								
								
									
										3
									
								
								main.js
									
										
									
									
									
								
							
							
						
						
									
										3
									
								
								main.js
									
										
									
									
									
								
							|  | @ -2,10 +2,9 @@ | ||||||
| const { app, BrowserWindow, session } = require('electron') | const { app, BrowserWindow, session } = require('electron') | ||||||
| const path = require('path') | const path = require('path') | ||||||
| require("v8-compile-cache"); | require("v8-compile-cache"); | ||||||
| require("update-electron-app")(); | require("./utils/updater"); | ||||||
| let mainWindow | let mainWindow | ||||||
| require("./menu.js") | require("./menu.js") | ||||||
| 
 |  | ||||||
| function createWindow() { | function createWindow() { | ||||||
|   mainWindow = new BrowserWindow({ |   mainWindow = new BrowserWindow({ | ||||||
|     width: 800, |     width: 800, | ||||||
|  |  | ||||||
							
								
								
									
										2
									
								
								package-lock.json
									
										
									
										generated
									
									
									
								
							
							
						
						
									
										2
									
								
								package-lock.json
									
										
									
										generated
									
									
									
								
							|  | @ -11727,4 +11727,4 @@ | ||||||
|       "dev": true |       "dev": true | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
| } | } | ||||||
|  | @ -66,4 +66,4 @@ | ||||||
|       ] |       ] | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
| } | } | ||||||
|  | @ -6,4 +6,5 @@ window.addEventListener('DOMContentLoaded', () => { | ||||||
|   }); |   }); | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| }) | }) | ||||||
|  | require("./utils/capturer.js") | ||||||
							
								
								
									
										164
									
								
								utils/capturer.js
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										164
									
								
								utils/capturer.js
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,164 @@ | ||||||
|  | // This desktop capturer has been taken from https://github.com/SpacingBat3/electron-discord-webapp
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | /* | ||||||
|  |  * Thanks, @WesselKroos! | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | /*function l10n(origin, locale){ | ||||||
|  |   if(originalString == 'Entire Screen') { | ||||||
|  |     return locale; | ||||||
|  |   } else { | ||||||
|  |     return origin; | ||||||
|  |   } | ||||||
|  | }*/ | ||||||
|  | const { desktopCapturer } = require("electron"); | ||||||
|  | 
 | ||||||
|  | navigator.mediaDevices.getDisplayMedia = () => { | ||||||
|  |   return new Promise(async (resolve, reject) => { | ||||||
|  |     try { | ||||||
|  |       const sources = await desktopCapturer.getSources({ | ||||||
|  |         types: ["screen", "window"], | ||||||
|  |       }); | ||||||
|  |       const selectionElem = document.createElement("div"); | ||||||
|  |       selectionElem.setAttribute("class", "desktop-capturer-selection"); | ||||||
|  |       selectionElem.innerHTML = ` | ||||||
|  |         <style> | ||||||
|  |         .desktop-capturer-selection { | ||||||
|  |           position: fixed; | ||||||
|  |           top: 0; | ||||||
|  |           left: 0; | ||||||
|  |           width: 100%; | ||||||
|  |           height: 100vh; | ||||||
|  |           background: rgba(30,30,30,.75); | ||||||
|  |           color: #fff; | ||||||
|  |           z-index: 10000000; | ||||||
|  |           display: flex; | ||||||
|  |           align-items: center; | ||||||
|  |           justify-content: center; | ||||||
|  |         } | ||||||
|  |         .desktop-capturer-selection__scroller { | ||||||
|  |           width: 100%; | ||||||
|  |           max-height: 100vh; | ||||||
|  |           overflow-y: auto; | ||||||
|  |         } | ||||||
|  |         .desktop-capturer-selection__list { | ||||||
|  |           max-width: calc(100% - 100px); | ||||||
|  |           margin: 50px; | ||||||
|  |           padding: 0; | ||||||
|  |           display: flex; | ||||||
|  |           flex-wrap: wrap; | ||||||
|  |           list-style: none; | ||||||
|  |           overflow: hidden; | ||||||
|  |           justify-content: center; | ||||||
|  |         } | ||||||
|  |         .desktop-capturer-selection__item { | ||||||
|  |           display: flex; | ||||||
|  |           margin: 4px; | ||||||
|  |         } | ||||||
|  |         .desktop-capturer-selection__btn { | ||||||
|  |           display: flex; | ||||||
|  |           flex-direction: column; | ||||||
|  |           align-items: stretch; | ||||||
|  |           width: 145px; | ||||||
|  |           margin: 0; | ||||||
|  |           border: 0; | ||||||
|  |           border-radius: 3px; | ||||||
|  |           padding: 4px; | ||||||
|  |           color: #FFFFFF; | ||||||
|  |           background: #36393F; | ||||||
|  |           text-align: left; | ||||||
|  |           transition: background-color .15s, box-shadow .15s; | ||||||
|  |         } | ||||||
|  |         .desktop-capturer-selection__btn:hover, | ||||||
|  |         .desktop-capturer-selection__btn:focus { | ||||||
|  |           background: #7289DA; | ||||||
|  |         } | ||||||
|  |         .desktop-capturer-selection__thumbnail { | ||||||
|  |           width: 100%; | ||||||
|  |           height: 81px; | ||||||
|  |           object-fit: cover; | ||||||
|  |         } | ||||||
|  |         .desktop-capturer-selection__name { | ||||||
|  |           margin: 6px 0 6px; | ||||||
|  |           white-space: nowrap; | ||||||
|  |           text-overflow: ellipsis; | ||||||
|  |           overflow: hidden; | ||||||
|  |         } | ||||||
|  |         .desktop-capturer-close { | ||||||
|  |           background-color: #36393F; | ||||||
|  |           position: fixed; | ||||||
|  |           top: 50%; | ||||||
|  |           transform: translateY(-50%); | ||||||
|  |           right: 15px; | ||||||
|  |           padding-top: 5px; | ||||||
|  |           transition: background-color .15s; | ||||||
|  |         } | ||||||
|  |         .desktop-capturer-close:hover { | ||||||
|  |           background-color: #823A3A; | ||||||
|  |         } | ||||||
|  |         </style> | ||||||
|  |         <div class="desktop-capturer-selection__scroller"> | ||||||
|  |           <ul class="desktop-capturer-selection__list"> | ||||||
|  |             ${sources | ||||||
|  |               .map( | ||||||
|  |                 ({ id, name, thumbnail }) => ` | ||||||
|  |               <li class="desktop-capturer-selection__item"> | ||||||
|  |                 <button class="desktop-capturer-selection__btn" data-id="${id}" title="${name}"> | ||||||
|  |                   <img class="desktop-capturer-selection__thumbnail" src="${thumbnail.toDataURL()}" /> | ||||||
|  |                   <span class="desktop-capturer-selection__name">${name}</span> | ||||||
|  |                 </button> | ||||||
|  |               </li> | ||||||
|  |             ` | ||||||
|  |               ) | ||||||
|  |               .join("")} | ||||||
|  |           </ul> | ||||||
|  |           <button class="desktop-capturer-close"> | ||||||
|  |             <svg viewBox="0 0 10 10" height=20px> | ||||||
|  |               <line x1="0" y1="10" x2="10" y2="0" stroke="white" /> | ||||||
|  |               <line x1="0" y1="0" x2="10" y2="10" stroke="white" /> | ||||||
|  |             </svg> | ||||||
|  |           </button> | ||||||
|  |         </div> | ||||||
|  |       `;
 | ||||||
|  |       document.body.appendChild(selectionElem); | ||||||
|  | 
 | ||||||
|  |       document | ||||||
|  |         .querySelectorAll(".desktop-capturer-selection__btn") | ||||||
|  |         .forEach((button) => { | ||||||
|  |           button.addEventListener("click", async () => { | ||||||
|  |             try { | ||||||
|  |               const id = button.getAttribute("data-id"); | ||||||
|  |               const source = sources.find((source) => source.id === id); | ||||||
|  |               if (!source) { | ||||||
|  |                 throw new Error(`Source with id ${id} does not exist`); | ||||||
|  |               } | ||||||
|  |               const stream = await navigator.mediaDevices.getUserMedia({ | ||||||
|  |                 audio: false, | ||||||
|  |                 video: { | ||||||
|  |                   mandatory: { | ||||||
|  |                     chromeMediaSource: "desktop", | ||||||
|  |                     chromeMediaSourceId: source.id, | ||||||
|  |                   }, | ||||||
|  |                 }, | ||||||
|  |               }); | ||||||
|  |               resolve(stream); | ||||||
|  |               selectionElem.remove(); | ||||||
|  |             } catch (err) { | ||||||
|  |               console.error("Error selecting desktop capture source:", err); | ||||||
|  |               reject(err); | ||||||
|  |             } | ||||||
|  |           }); | ||||||
|  |         }); | ||||||
|  |       document.querySelectorAll(".desktop-capturer-close").forEach((button) => { | ||||||
|  |         button.addEventListener("click", () => { | ||||||
|  |           selectionElem.remove(); | ||||||
|  |         }); | ||||||
|  |       }); | ||||||
|  |     } catch (err) { | ||||||
|  |       console.error("Error displaying desktop capture sources:", err); | ||||||
|  |       reject(err); | ||||||
|  |     } | ||||||
|  |   }); | ||||||
|  | }; | ||||||
|  | console.log("Desktop capturer has been preloaded 🎉️"); | ||||||
							
								
								
									
										66
									
								
								utils/updater.js
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										66
									
								
								utils/updater.js
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,66 @@ | ||||||
|  | const electron = require("electron"); | ||||||
|  | const APP_VERSION = require("../package.json").version; | ||||||
|  | 
 | ||||||
|  | /* IMPORTANT! | ||||||
|  |   This url will need to be modified for yours */ | ||||||
|  | // The url that the application is going to query for new release
 | ||||||
|  | const AUTO_UPDATE_URL = | ||||||
|  |   'https://api.dev.update.rocks/update/github.com/smartfrigde/armcord/stable/' + process.platform + '/' + APP_VERSION | ||||||
|  | 
 | ||||||
|  | function init() { | ||||||
|  |   if (process.platform === "linux") { | ||||||
|  |     /* There is no auto update for linux however you can still | ||||||
|  |        notify the user that a new update has been released | ||||||
|  |        our service will return an answer with the latest version. */ | ||||||
|  |     console.log("Auto updates not available on linux"); | ||||||
|  |   } else { | ||||||
|  |     initDarwinWin32(); | ||||||
|  |   } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | function initDarwinWin32() { | ||||||
|  |   electron.autoUpdater.on("error", (err) => | ||||||
|  |     console.error(`Update error: ${err.message}`) | ||||||
|  |   ); | ||||||
|  | 
 | ||||||
|  |   electron.autoUpdater.on("checking-for-update", () => | ||||||
|  |     console.log("Checking for update") | ||||||
|  |   ); | ||||||
|  | 
 | ||||||
|  |   electron.autoUpdater.on("update-available", () => | ||||||
|  |     console.log("Update available") | ||||||
|  |   ); | ||||||
|  | 
 | ||||||
|  |   electron.autoUpdater.on("update-not-available", () => | ||||||
|  |     console.log("No update available") | ||||||
|  |   ); | ||||||
|  | 
 | ||||||
|  |   // Ask the user if he wants to update if update is available
 | ||||||
|  |   electron.autoUpdater.on( | ||||||
|  |     "update-downloaded", | ||||||
|  |     (event, releaseNotes, releaseName) => { | ||||||
|  |       dialog.showMessageBox( | ||||||
|  |         window, | ||||||
|  |         { | ||||||
|  |           type: "question", | ||||||
|  |           buttons: ["Update", "Cancel"], | ||||||
|  |           defaultId: 0, | ||||||
|  |           message: `Version ${releaseName} is available, do you want to install it now?`, | ||||||
|  |           title: "Update available", | ||||||
|  |         }, | ||||||
|  |         (response) => { | ||||||
|  |           if (response === 0) { | ||||||
|  |             electron.autoUpdater.quitAndInstall(); | ||||||
|  |           } | ||||||
|  |         } | ||||||
|  |       ); | ||||||
|  |     } | ||||||
|  |   ); | ||||||
|  | 
 | ||||||
|  |   electron.autoUpdater.setFeedURL(AUTO_UPDATE_URL); | ||||||
|  |   electron.autoUpdater.checkForUpdates(); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | module.exports = { | ||||||
|  |   init, | ||||||
|  | }; | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue