Skip to content

Commit

Permalink
feat: button to acquire a link for obs
Browse files Browse the repository at this point in the history
  • Loading branch information
ilotterytea committed Jun 16, 2024
1 parent 8a1b64c commit c25a032
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
2 changes: 2 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ <h1>
</div>
<div class="control">
<a href="show.html" class="button">show in a separate tab</a>
<a href="#" class="button" id="obs" onclick="get_link_for_obs()">get link for obs</a>
</div>
</div>
</div>
Expand All @@ -52,5 +53,6 @@ <h2>settings</h2>
</body>
<script src="scripts/microphone.js"></script>
<script src="scripts/settings.js"></script>
<script src="scripts/obs.js"></script>

</html>
7 changes: 4 additions & 3 deletions scripts/microphone.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@ if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
volumeHtml.innerText = `${decibels.toFixed(2)} dB`;
}

const muted = localStorage.getItem("muted_img");
const speak = localStorage.getItem("speak_img");
const silence_db = localStorage.getItem("silence_db");
const params = new URLSearchParams(window.location.search);
const muted = localStorage.getItem("muted_img") || params.get("muted_img");
const speak = localStorage.getItem("speak_img") || params.get("speak_img");
const silence_db = localStorage.getItem("silence_db") || params.get("silence_db");

if (muted && previewHtml.src != muted && decibels <= silence_db) {
previewHtml.src = muted;
Expand Down
17 changes: 17 additions & 0 deletions scripts/obs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
function get_link_for_obs() {
const muted_img = localStorage.getItem("muted_img");
const speak_img = localStorage.getItem("speak_img");
const silence_db = localStorage.getItem("silence_db");

if (!muted_img || !speak_img || !silence_db) {
alert("settings not set!");
return;
}

const url_part = `show.html?silence_db=${silence_db}&muted_img=${muted_img}&speak_img=${speak_img}`;

navigator.clipboard.writeText(window.location.href + url_part);
alert("copied the url to clipboard!");

window.location.replace(url_part);
}

0 comments on commit c25a032

Please sign in to comment.