Skip to content

Commit

Permalink
Check that the debug server wants to receive remote debugging users b…
Browse files Browse the repository at this point in the history
…efore allowing users to enable remote debugging
  • Loading branch information
NotLazy committed Aug 26, 2024
1 parent 33774fe commit 91a98c0
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/app.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,18 @@
<div class="divider"></div>
<div style="color: #666; font-size: 12px; text-align: center">
<p>Made with ❤ by <a href="https://github.com/hainguyents13/mechvibes/" class="open-in-browser">hainguyents13</a></p>
<p>
<div style="display:flex;gap:1em;justify-content: center;">
<a href="https://mechvibes.com" class="open-in-browser">Home page</a>
&nbsp;&nbsp;|&nbsp;&nbsp;
<!-- <a href="https://mechvibes.com/#qna" class="open-in-browser">FAQs</a>
&nbsp;&nbsp;|&nbsp;&nbsp; -->
<span>|</span>
<a href="https://buymeacoff.ee/hainguyents13" class="open-in-browser">Buy me a coffee</a>
&nbsp;&nbsp;|&nbsp;&nbsp;
<a href="#" id="open-debug-options">Advanced</a>
</p>
<!--
Though access to the advanced window can be disabled by the server,
it's important to remember that users can *always* disable remote debugging
via the link in div#remote-in-use
-->
<span id="debug-options-seperator" class="hidden">|</span>
<a href="#" id="open-debug-options" class="hidden">Advanced</a>
</div>
<p id="app-version" style="color: #999">-</p>
<div style="position: relative;">
<div id="update-available" class="hidden alert">
Expand Down
15 changes: 15 additions & 0 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ function packsToOptions(packs, pack_list) {
const pack_list = document.getElementById('pack-list');
const random_button = document.getElementById('random-button');
const debug_button = document.getElementById('open-debug-options');
const debug_button_seperator = document.getElementById('debug-options-seperator');
const volume_value = document.getElementById('volume-value-display');
const volume = document.getElementById('volume');
const tray_icon_toggle = document.getElementById("tray_icon_toggle");
Expand Down Expand Up @@ -341,6 +342,20 @@ function packsToOptions(packs, pack_list) {
}
});

// check if remote debugging can be enabled by user
fetch("https://beta.mechvibes.com/debug/status/", {
method: "GET",
headers: {
"User-Agent": `Mechvibes/${APP_VERSION} (Electron/${process.versions.electron})`
}
}).then(async (res) => {
const body = await res.text();
if(res.status == 200 && body == "enabled"){
debug_button.classList.remove("hidden");
debug_button_seperator.classList.remove("hidden");
}
});

// a little hack for open link in browser
Array.from(document.getElementsByClassName('open-in-browser')).forEach((elem) => {
elem.addEventListener('click', (e) => {
Expand Down

0 comments on commit 91a98c0

Please sign in to comment.