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

Commit

Permalink
Don't always show the download button
Browse files Browse the repository at this point in the history
  • Loading branch information
reisxd committed Aug 8, 2022
1 parent 7af4066 commit 68cb6b0
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 26 deletions.
16 changes: 9 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,15 @@ app.use(

server.listen(8080, () => {
console.log('The webserver is now running!');
try {
console.log('Opening the app in the default browser...');
open('http://localhost:8080');
console.log('Done. Check if a browser window has opened');
} catch (e) {
console.log('Failed. Open up http://localhost:8080 in your browser.');
}
if (require('os').platform() !== 'android') {
try {
console.log('Opening the app in the default browser...');
open('http://localhost:8080');
console.log('Done. Check if a browser window has opened');
} catch (e) {
console.log('Failed. Open up http://localhost:8080 in your browser.');
}
} else console.log('Open up http://localhost:8080 in your browser.');
});

process.on('uncaughtException', (reason) => {
Expand Down
4 changes: 3 additions & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ <h1>Select the app you want to patch</h1>
onclick="openAbout();"
></i>
<span class="right"></span>
<button class="highlighted" id="continue" onclick="setApp()">Continue</button>
<button class="highlighted" id="continue" onclick="setApp()">
Continue
</button>
</footer>
</div>
</body>
Expand Down
23 changes: 15 additions & 8 deletions public/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ function setAppVersion (arch, version) {

sendCommand({
event: 'selectAppVersion',
versionChoosen: version || document.querySelector('input[name="version"]:checked').value,
versionChoosen:
version ||
document.querySelector('input[name="version"]:checked').value,
arch
});

Expand Down Expand Up @@ -139,13 +141,13 @@ function toTitleCase (phrase) {
.join(' ');
}

window.addEventListener("keypress", (e) => {
if(e.key === "Enter"){
window.addEventListener('keypress', (e) => {
if (e.key === 'Enter') {
e.preventDefault();

document.getElementById("continue").click();
document.getElementById('continue').click();
}
})
});

ws.onmessage = (msg) => {
const message = JSON.parse(msg.data);
Expand All @@ -162,7 +164,9 @@ ws.onmessage = (msg) => {
<span style="float:right;"><strong>${
patch.isRooted ? 'Needed for Non-Root Building' : ''
}</strong></span>
<span><strong>${toTitleCase(patch.name)}</strong>&nbsp;&nbsp;(${patch.maxVersion !== " " ? patch.maxVersion : "ALL"})</span>
<span><strong>${toTitleCase(patch.name)}</strong>&nbsp;&nbsp;(${
patch.maxVersion !== ' ' ? patch.maxVersion : 'ALL'
})</span>
<span class="patch-description">${patch.description}</span>
</label>
</li>`;
Expand Down Expand Up @@ -229,7 +233,7 @@ ws.onmessage = (msg) => {

if (message.selectedApp === 'music' && !message.foundDevice) {
document.getElementById('continue').onclick = () => {
let version = document.querySelector(
const version = document.querySelector(
'input[name="version"]:checked'
).value;
document.getElementsByTagName('header')[0].innerHTML = `
Expand Down Expand Up @@ -301,8 +305,11 @@ ws.onmessage = (msg) => {
case 'buildFinished': {
document.getElementsByTagName('header')[0].innerHTML =
'<h1>ReVanced has been built.</h1>';
if (WS_URI !== 'ws://localhost:8080') {
document.getElementsByTagName('footer')[0].innerHTML +=
'<button class="highlighted" onclick="window.open(\'/revanced.apk\', \'_blank\')">Download</button>';
}
document.getElementsByTagName('footer')[0].innerHTML +=
'<button class="highlighted" onclick="window.open(\'/revanced.apk\', \'_blank\')">Download</button>' +
'<button class="highlighted" onclick="location.href = \'/\'">Build Again</button>';
break;
}
Expand Down
4 changes: 3 additions & 1 deletion public/patches/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ <h1>Select patches to include</h1>
></i>
<span class="right"></span>
<button onclick="history.back()">Back</button>
<button class="highlighted" id="continue" onclick="setPatches();">Continue</button>
<button class="highlighted" id="continue" onclick="setPatches();">
Continue
</button>
</footer>
</div>
</body>
Expand Down
4 changes: 3 additions & 1 deletion wsEvents/GetAppVersion.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ module.exports = async function (message, ws) {
);
}
if (global.jarNames.selectedApp === 'music') {
const deviceArch = await actualExec('adb shell getprop ro.product.cpu.abi');
const deviceArch = await actualExec(
'adb shell getprop ro.product.cpu.abi'
);
return await downloadApp(appVersion, ws, deviceArch.stdout);
} else return await downloadApp(appVersion, ws);
}
Expand Down
14 changes: 9 additions & 5 deletions wsEvents/GetPatches.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ module.exports = async function (message, ws) {
/:\s+(?<pkg>\S+)\s+(?<name>\S+)\s+(?<description>.+)\t+(?<versions>.+)/g
);


let hasRoot = true;
if (os.platform() === 'android') {
await actualExec('su -c exit').catch((err) => {
Expand All @@ -38,12 +37,17 @@ module.exports = async function (message, ws) {
const { name, description, pkg, versions } = match.groups;
const isRooted = rootedPatches.includes(name);
const isCompatible = pkg === global.jarNames.selectedApp;
const versionsArr = versions.split(", ")
const maxVersion = versionsArr.sort()[versionsArr.length - 1]

const versionsArr = versions.split(', ');
const maxVersion = versionsArr.sort()[versionsArr.length - 1];

if (isCompatible && (!isRooted || hasRoot)) {
patchList.push({ name, description: description.trim(), maxVersion: maxVersion, isRooted });
patchList.push({
name,
description: description.trim(),
maxVersion,
isRooted
});
}
}

Expand Down
3 changes: 2 additions & 1 deletion wsEvents/PatchApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const { exec, spawn } = require('child_process');
const os = require('os');
const mountReVanced = require('../utils/mountReVanced.js');
const actualExec = promisify(exec);
const fs = require('fs');

async function mount (ws) {
let pkg;
Expand All @@ -28,6 +29,7 @@ async function mount (ws) {
}

async function afterBuild (ws) {
fs.rmdirSync('./revanced', { recursive: true, force: true });
if (!global.jarNames.isRooted && os.platform() === 'android') {
await actualExec(
'cp revanced/revanced.apk /storage/emulated/0/revanced.apk'
Expand Down Expand Up @@ -137,7 +139,6 @@ module.exports = async function (message, ws) {
if (global.jarNames.deviceID) {
args.push('-d');
args.push(global.jarNames.deviceID);
args.push('-c');
}

for (const patch of global.jarNames.patches.split(' ')) {
Expand Down
9 changes: 7 additions & 2 deletions wsEvents/SelectAppVersion.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,14 @@ const actualExec = promisify(exec);

module.exports = async function (message, ws) {
let arch = message.arch;
if (global.jarNames.selectedApp === 'music' && global.jarNames.deviceID || os.platform() === 'android') {
if (
(global.jarNames.selectedApp === 'music' && global.jarNames.deviceID) ||
os.platform() === 'android'
) {
if (global.jarNames.deviceID) {
const deviceArch = await actualExec('adb shell getprop ro.product.cpu.abi');
const deviceArch = await actualExec(
'adb shell getprop ro.product.cpu.abi'
);
arch = deviceArch.arch;
} else {
const deviceArch = await actualExec('getprop ro.product.cpu.abi');
Expand Down

6 comments on commit 68cb6b0

@shrihankp
Copy link
Collaborator

@shrihankp shrihankp commented on 68cb6b0 Aug 8, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From 68cb6b094a87aac1d793537384b716ce8ee70fde Mon Sep 17 00:00:00 2001
From: GramingFoxTeam <ibrahimbozkurt0270@gmail.com>
Date: Mon, 8 Aug 2022 11:52:29 +0300
Subject: [PATCH] Don't always show the download button

---
 index.js                     | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/index.js b/index.js
index 96d3898..a88ee0a 100644
--- a/index.js
+++ b/index.js
@@ -28,13 +28,15 @@ app.use(
 
 server.listen(8080, () => {
   console.log('The webserver is now running!');
-  try {
-    console.log('Opening the app in the default browser...');
-    open('http://localhost:8080');
-    console.log('Done. Check if a browser window has opened');
-  } catch (e) {
-    console.log('Failed. Open up http://localhost:8080 in your browser.');
-  }
+  if (require('os').platform() !== 'android') {
+    try {
+      console.log('Opening the app in the default browser...');
+      open('http://localhost:8080');
+      console.log('Done. Check if a browser window has opened');
+    } catch (e) {
+      console.log('Failed. Open up http://localhost:8080 in your browser.');
+    }
+  } else console.log('Open up http://localhost:8080 in your browser.');
 });
 
 process.on('uncaughtException', (reason) => {

💀 Why'd you not open the browser on Android?

@reisxd
Copy link
Owner Author

@reisxd reisxd commented on 68cb6b0 Aug 8, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From 68cb6b094a87aac1d793537384b716ce8ee70fde Mon Sep 17 00:00:00 2001
From: GramingFoxTeam <ibrahimbozkurt0270@gmail.com>
Date: Mon, 8 Aug 2022 11:52:29 +0300
Subject: [PATCH] Don't always show the download button

---
 index.js                     | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/index.js b/index.js
index 96d3898..a88ee0a 100644
--- a/index.js
+++ b/index.js
@@ -28,13 +28,15 @@ app.use(
 
 server.listen(8080, () => {
   console.log('The webserver is now running!');
-  try {
-    console.log('Opening the app in the default browser...');
-    open('http://localhost:8080');
-    console.log('Done. Check if a browser window has opened');
-  } catch (e) {
-    console.log('Failed. Open up http://localhost:8080 in your browser.');
-  }
+  if (require('os').platform() !== 'android') {
+    try {
+      console.log('Opening the app in the default browser...');
+      open('http://localhost:8080');
+      console.log('Done. Check if a browser window has opened');
+    } catch (e) {
+      console.log('Failed. Open up http://localhost:8080 in your browser.');
+    }
+  } else console.log('Open up http://localhost:8080 in your browser.');
 });
 
 process.on('uncaughtException', (reason) => {

💀 Why'd you not open the browser on Android?

Because it doesn't open. So making it display "Go to http://localhost:8080" is better.

@shrihankp
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because it doesn't open

It does???

vidma_recorder_edited_08082022_184809.mp4

@reisxd
Copy link
Owner Author

@reisxd reisxd commented on 68cb6b0 Aug 8, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Weird, doesn't for me. Make a PR and i'll merge.

@shrihankp
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesn't for me

Which device? What Android version?

@reisxd
Copy link
Owner Author

@reisxd reisxd commented on 68cb6b0 Aug 8, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redmi Note 7, Android 10

Please sign in to comment.