Last active
August 23, 2021 01:13
-
-
Save tnytown/82774d7c71a693d6d05fafc2f425eb91 to your computer and use it in GitHub Desktop.
LD_LIBRARY_PATH=.:<pipewire lib path>:<gcc lib path>:$LD_LIBRARY_PATH electron -- --enable-features=UseOzonePlatform --ozone-platform=wayland --enable-gpu --enable-features=WebRTCPipeWireCapturer --disable-smooth-scrolling wldiscord.js <discord installation root>
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let process = require('process'); | |
console.log(process.argv); | |
let idx = process.argv.findIndex(e => e == 'wldiscord.js'); | |
process.argv.splice(0, idx); | |
console.log(process.argv); | |
let data = process.argv[1]; | |
console.log(module.paths); | |
var Module = require('module'); | |
var assert = require('assert'); | |
(function() { | |
var origRequire = Module.prototype.require; | |
var _require = function(context, path) { | |
return origRequire.call(context, path); | |
}; | |
var main = require.main; | |
Module.prototype.require = function(path) { | |
let base = _require(this, path); | |
let newBase = new Proxy(base, { | |
get: function(t, prop, recv) { | |
if(prop !== "BrowserWindow") | |
return t[prop]; | |
return new Proxy(base.BrowserWindow, { | |
construct: function(t, args) { | |
console.log(`Writing wrapper for ${args[0].webPreferences.preload}`); | |
if(args[0].webPreferences.preload !== "") { | |
require('fs').writeFileSync("/tmp/wldiscord.preload.js", ` | |
require("process").resourcesPath = "${data}/resources"; | |
let p = require("${args[0].webPreferences.preload}"); | |
`); | |
} | |
args[0].webPreferences.preload = "/tmp/wldiscord.preload.js"; | |
console.log(args); | |
let win = new base.BrowserWindow(args[0]); | |
win.webContents.setUserAgent("Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.114 Safari/537.36"); | |
return win; | |
}, | |
}); | |
} | |
}); | |
return newBase; | |
}; | |
})(); | |
if(process.argv[process.argv.length - 1 - 1] !== "poo") { | |
console.log(process.resourcesPath); | |
process.resourcesPath = `${data}/resources`; | |
console.log(process.resourcesPath); | |
module.paths.push(`${data}/resources`); | |
require(`${data}/resources/app.asar/`); | |
} else { | |
const { app, BrowserWindow } = require('electron') | |
const path = require('path') | |
function createWindow () { | |
const win = new BrowserWindow({ | |
width: 800, | |
height: 600, | |
webPreferences: { | |
preload: path.join(__dirname, 'preload.js') | |
} | |
}); | |
win.webContents.setUserAgent("Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.114 Safari/537.36"); | |
win.once('ready-to-show', () => { | |
console.log(`Window ready to show`); | |
win.show(); | |
win.webContents.openDevTools(); | |
}); | |
//win.loadFile('index.html') | |
win.loadURL(process.argv[process.argv.length - 1]) | |
} | |
app.whenReady().then(() => { | |
createWindow() | |
app.on('activate', () => { | |
if (BrowserWindow.getAllWindows().length === 0) { | |
createWindow() | |
} | |
}) | |
}) | |
app.on('window-all-closed', () => { | |
if (process.platform !== 'darwin') { | |
app.quit() | |
} | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment