Skip to content

Commit f5b711c

Browse files
committed
update
1 parent 35b358f commit f5b711c

File tree

5 files changed

+132
-1
lines changed

5 files changed

+132
-1
lines changed

popup/styles/style.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,8 @@ a:hover {
351351
height: 100vh;
352352
background-color: rgb(0, 0, 0);
353353
background-color: rgba(0, 0, 0, 0.4);
354+
-webkit-backdrop-filter: blur(.1rem);
355+
backdrop-filter: blur(.1rem);
354356
}
355357

356358
.modal-content {
@@ -396,6 +398,8 @@ a:hover {
396398
right: 0;
397399
bottom: 0;
398400
background: #e8e8e8db;
401+
-webkit-backdrop-filter: blur(.1rem);
402+
backdrop-filter: blur(.1rem);
399403
}
400404

401405
.loading-container {

popup/tabs.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ const tabs = [
200200
scripts: [
201201
s.shortenURL,
202202
s.unshorten,
203+
s.changeAudioOutput,
203204
createTitle("--- QRCode ---", "--- QRCode ---"),
204205
s.textToQRCode,
205206
s.webToQRCode,

scripts/changeAudioOutput.js

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
export default {
2+
icon: "",
3+
name: {
4+
en: "",
5+
vi: "",
6+
},
7+
description: {
8+
en: "",
9+
vi: "",
10+
},
11+
12+
// Fb Post: https://www.facebook.com/groups/j2team.community/posts/1362716140727169
13+
// Source: https://gist.github.com/monokaijs/44ef4bd0770f83272b83c038a2769c90
14+
onClick: async () => {
15+
await navigator.mediaDevices.getUserMedia({ audio: true, video: true });
16+
let popupParent = document.createElement("div");
17+
/* positioning for the dialog */
18+
popupParent.style.width = "320px";
19+
popupParent.style.height = "120px";
20+
popupParent.style.position = "fixed";
21+
popupParent.style.left = "50%";
22+
popupParent.style.top = "50%";
23+
popupParent.style.marginLeft = "-160px";
24+
popupParent.style.marginTop = "-60px";
25+
/* stylizing the dialog */
26+
popupParent.style.backgroundColor = "#fff";
27+
popupParent.style.border = "1px solid rgba(0, 0, 0, .08)";
28+
popupParent.style.zIndex = "999999";
29+
30+
/* navigation bar */
31+
let navbar = document.createElement("div");
32+
navbar.style.width = "100%";
33+
navbar.style.height = "28px";
34+
navbar.style.backgroundColor = "rgba(0, 0, 0, .05)";
35+
36+
let closeButton = document.createElement("button");
37+
closeButton.innerText = "Close";
38+
closeButton.style.padding = "6px 8px";
39+
closeButton.style.backgroundColor = "transparent";
40+
closeButton.style.color = "black";
41+
closeButton.style.position = "absolute";
42+
closeButton.style.right = "0";
43+
closeButton.style.top = "0";
44+
closeButton.style.border = "none";
45+
46+
navbar.appendChild(closeButton);
47+
48+
closeButton.onclick = function (e) {
49+
popupParent.parentNode.removeChild(popupParent);
50+
};
51+
closeButton.onmouseover = function (e) {
52+
e.target.style.backgroundColor = "#e74c3c";
53+
e.target.style.color = "white";
54+
};
55+
closeButton.onmouseleave = function (e) {
56+
e.target.style.backgroundColor = "transparent";
57+
e.target.style.color = "black";
58+
};
59+
60+
/* PLEASE DO NOT REMOVE CREDIT LINE */
61+
let popupTitle = document.createElement("div");
62+
popupTitle.innerHTML =
63+
"SoundSwitcher - by <a href='https://north.studio' target='_blank'>NorthStudio</a>";
64+
popupTitle.style.fontSize = "12px";
65+
popupTitle.style.position = "absolute";
66+
popupTitle.style.left = "6px";
67+
popupTitle.style.top = "8px";
68+
navbar.appendChild(popupTitle);
69+
70+
let titleLink = popupTitle.querySelector("a");
71+
titleLink.style.fontWeight = "500";
72+
titleLink.style.textDecoration = "none";
73+
74+
let popupContent = document.createElement("div");
75+
popupContent.style.height = "92px";
76+
popupContent.style.display = "relative";
77+
popupContent.style.width = "100%";
78+
79+
let bottomArea = document.createElement("div");
80+
bottomArea.style.position = "absolute";
81+
bottomArea.style.left = "10px";
82+
bottomArea.style.right = "10px";
83+
bottomArea.style.bottom = "10px";
84+
85+
let submitButton = document.createElement("button");
86+
submitButton.style.backgroundColor = "#3498db";
87+
submitButton.style.color = "#FFF";
88+
submitButton.style.width = "100%";
89+
submitButton.style.padding = "6px";
90+
submitButton.style.border = "none";
91+
submitButton.style.borderRadius = "3px";
92+
submitButton.innerText = "Set Device";
93+
94+
submitButton.onclick = function (e) {
95+
document.querySelectorAll("audio,video").forEach((el) => {
96+
el.setSinkId(deviceSelector.value);
97+
});
98+
};
99+
100+
bottomArea.appendChild(submitButton);
101+
102+
let deviceSelector = document.createElement("select");
103+
navigator.mediaDevices.enumerateDevices().then((devices) => {
104+
devices = devices.filter((x) => x.kind === "audiooutput");
105+
devices.forEach((device) => {
106+
let choice = document.createElement("option");
107+
choice.innerText = device.label;
108+
choice.value = device.deviceId;
109+
deviceSelector.appendChild(choice);
110+
});
111+
popupContent.appendChild(deviceSelector);
112+
});
113+
114+
deviceSelector.style.margin = "10px";
115+
deviceSelector.style.padding = "5px";
116+
deviceSelector.style.width = "calc(100% - 20px)";
117+
118+
popupContent.appendChild(bottomArea);
119+
120+
popupParent.appendChild(navbar);
121+
popupParent.appendChild(popupContent);
122+
document.body.appendChild(popupParent);
123+
},
124+
};

scripts/fb_moreReactionStory.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export default {
2525

2626
loadModal(EMOJI_LIST);
2727
} catch (e) {
28-
console.error(e);
28+
alert("ERROR: " + e);
2929
}
3030
})();
3131

scripts/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ import fb_revealDeletedMessages from "./fb_revealDeletedMessages.js";
161161
import fb_whoIsTyping from "./fb_whoIsTyping.js";
162162
import detect_zeroWidthCharacters from "./detect_zeroWidthCharacters.js";
163163
import fb_moreReactionStory from "./fb_moreReactionStory.js";
164+
import changeAudioOutput from "./changeAudioOutput.js";
164165

165166
// inject badges
166167
const allScripts = {
@@ -343,6 +344,7 @@ const allScripts = {
343344
fb_whoIsTyping: addBadge(fb_whoIsTyping, BADGES.new),
344345
detect_zeroWidthCharacters: addBadge(detect_zeroWidthCharacters, BADGES.new),
345346
fb_moreReactionStory: addBadge(fb_moreReactionStory, BADGES.new),
347+
changeAudioOutput: addBadge(changeAudioOutput, BADGES.new),
346348
};
347349

348350
// alert(Object.keys(allScripts).length);

0 commit comments

Comments
 (0)