Skip to content
This repository has been archived by the owner on Jul 18, 2023. It is now read-only.

Commit

Permalink
run eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
ActuallyTheSun committed Aug 19, 2022
1 parent b6a0128 commit d091241
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 30 deletions.
32 changes: 16 additions & 16 deletions public/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ let hasFinished = false;
let arch;
let versionChoosen;

function sendCommand(args) {
function sendCommand (args) {
ws.send(JSON.stringify(args));
}

function setApp() {
function setApp () {
if (!document.querySelector('input[name="app"]:checked')) {
return alert("You didn't select an app to patch!");
}
Expand All @@ -27,31 +27,31 @@ function setApp() {
location.href = '/dependencies';
}

function loadPatches() {
function loadPatches () {
sendCommand({ event: 'getPatches' });
}

function updateFiles() {
function updateFiles () {
sendCommand({ event: 'updateFiles' });
}

function toggle(bool) {
function toggle (bool) {
for (const checkbox of document.getElementsByClassName('select')) {
checkbox.checked = bool;
}
}

function goToPatches() {
function goToPatches () {
if (hasFinished) {
location.href = '/patches';
}
}

function checkForUpdates() {
function checkForUpdates () {
sendCommand({ event: 'checkForUpdates' });
}

function setPatches() {
function setPatches () {
const patchElementList = [...document.querySelectorAll('.select')];
const selectedPatchElementList = patchElementList.filter(
(x) => x.checked === true
Expand All @@ -77,7 +77,7 @@ function setPatches() {
location.href = '/versions';
}

function setAppVersion(arch, version) {
function setAppVersion (arch, version) {
if (!isDownloading) {
if (!arch) {
if (!document.querySelector('input[name="version"]:checked')) {
Expand Down Expand Up @@ -105,7 +105,7 @@ function setAppVersion(arch, version) {
}
}

function getAppVersions(isRooted) {
function getAppVersions (isRooted) {
document.getElementsByTagName('header')[0].innerHTML = `
<h1>Select the version you want to download</h1>
Versions marked as beta might have bugs or be unstable, unless marked as recommended
Expand All @@ -124,29 +124,29 @@ function getAppVersions(isRooted) {
sendCommand({ event: 'getAppVersion' });
}

function buildReVanced() {
function buildReVanced () {
sendCommand({ event: 'patchApp' });
}

function getAlreadyExists() {
function getAlreadyExists () {
sendCommand({ event: 'checkFileAlreadyExists' });
}
function openAbout() {
function openAbout () {
window.open('/about', '_blank');
}

function openGitHub() {
function openGitHub () {
window.open('https://github.com/reisxd/revanced-builder', '_blank');
}

function toTitleCase(phrase) {
function toTitleCase (phrase) {
return phrase
.split('-')
.map((word) => word.charAt(0).toUpperCase() + word.slice(1))
.join(' ');
}

function exitApp() {
function exitApp () {
sendCommand({ event: 'exit' });
const tempW = window.open(location, '_self');
tempW.close();
Expand Down
8 changes: 4 additions & 4 deletions utils/FileDownloader.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ async function overWriteJarNames (fileName) {

// yes.

function insert (str, index, value) {
return str.substr(0, index) + value + str.substr(index);
}
// function insert (str, index, value) {
// return str.substr(0, index) + value + str.substr(index);
// }

async function getDownloadLink (json) {
const apiRequest = await fetchURL(
Expand Down Expand Up @@ -71,7 +71,7 @@ async function downloadFile (assets) {
const dir = fs.readdirSync('./revanced/');
let fileExt = asset.browser_download_url.split('/').pop().split('.');
fileExt = fileExt[fileExt.length - 1];
let fileName = assets.repo
let fileName = assets.repo;
fileName += `-${assets.version}.${fileExt}`;
overWriteJarNames(fileName);
if (dir.includes(fileName)) continue;
Expand Down
7 changes: 4 additions & 3 deletions utils/mountReVanced.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,12 @@ module.exports = async function (pkg, ws) {
// await actualExec(`su -c 'monkey -p ${pkg} 1 && kill $(pidof -s ${pkg})'`);

// Mount APK with command so it doesn't require restart
await actualExec(`su -mm -c 'base_path="/data/adb/revanced/${pkg}.apk";stock_path=$( pm path ${pkg} | grep base | sed 's/package://g' );mount -o bind $base_path $stock_path'`)
// Kill app process
await actualExec(
`su -mm -c 'base_path="/data/adb/revanced/${pkg}.apk";stock_path=$( pm path ${pkg} | grep base | sed 's/package://g' );mount -o bind $base_path $stock_path'`
);
// Kill app process
await actualExec(`su -c 'am force-stop ${pkg}'`);


ws.send(
JSON.stringify({
event: 'patchLog',
Expand Down
10 changes: 5 additions & 5 deletions wsEvents/GetAppVersion.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const lt = require('semver/functions/lt');

const actualExec = promisify(exec);

async function getPage(pageUrl) {
async function getPage (pageUrl) {
const pageRequest = await fetchURL(pageUrl, {
headers: {
'user-agent':
Expand Down Expand Up @@ -137,17 +137,17 @@ module.exports = async function (message, ws) {
versionList.push({
version: versionName.split(' ')[0], // remove beta suffix if there is one
recommended: global.versions.includes(versionName.split(' ')[0]),
beta: versionName.split(' ')[1] ? true : false
beta: !!versionName.split(' ')[1]
});
}
versionList.sort(
(a, b) =>
lt(
a.version.replace(/\.0(?<digit>\d)/gi, ".$1"), // because apparently x.0y.z (ex. 5.09.51) isn't a valid version
b.version.replace(/\.0(?<digit>\d)/gi, ".$1")
a.version.replace(/\.0(?<digit>\d)/gi, '.$1'), // because apparently x.0y.z (ex. 5.09.51) isn't a valid version
b.version.replace(/\.0(?<digit>\d)/gi, '.$1')
)
? 1
: -1 /* yes i need to add this to the end, the sort function is stupid*/
: -1 /* yes i need to add this to the end, the sort function is stupid */
);
return ws.send(
JSON.stringify({
Expand Down
2 changes: 1 addition & 1 deletion wsEvents/GetPatches.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ module.exports = async function (message, ws) {
const isCompatible = pkg === global.jarNames.selectedApp;

const versionsArr = versions.split(', ');
global.versions = versionsArr.map(i => i.trim());
global.versions = versionsArr.map((i) => i.trim());
const maxVersion = versionsArr.sort()[versionsArr.length - 1];

if (isCompatible && (!isRooted || hasRoot)) {
Expand Down
4 changes: 3 additions & 1 deletion wsEvents/PatchApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ async function afterBuild (ws) {
await actualExec(
`cp revanced/${global.outputName} /storage/emulated/0/${global.outputName}`
);
await actualExec(`cp ${global.jarNames.microG} /storage/emulated/0/microg.apk`);
await actualExec(
`cp ${global.jarNames.microG} /storage/emulated/0/microg.apk`
);

ws.send(
JSON.stringify({
Expand Down

0 comments on commit d091241

Please sign in to comment.