Skip to content

Commit

Permalink
Bugfix, fixed the extension not working when server is set to any lan…
Browse files Browse the repository at this point in the history
…guage other than english
  • Loading branch information
Julian Weber committed May 17, 2021
1 parent 4e8eec6 commit 8e7af5e
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 13 deletions.
40 changes: 28 additions & 12 deletions extension/content.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
var id = "";
var message = "";
/* Arabic, Belarusian, Bulgarian, Catalan, Chinese Simplified, Chinese Traditional, Chinese Traditional (Hong Kong), Croatian, Czech,
* Danish, Dutch, English (UK), English (US), Estonian, Finnish, French, French (Canada), German, Greek, Hindi (India), Hungarian,
* Indonesian, Italian, Japanese, Kazakh, Korean, Lithuanian, Malay, Norwegian, Persian, Polish, Portuguese (Brazil), Portuguese (Portugal),
* Romanian, Russian, Slovak, Slovenian (Slovenia), Spanish, Spanish (Latin America), Spanish (Mexico), Spanish (United States), Swedish,
* Swiss German, Turkish, Ukrainian, Vietnamnese
*/
var button_play_array = ["تشغيل", "Play", "Изпълняване", "Reprodueix", "播放", "播放", "播放", "Pokreni", "Pokreni",
"Afspil", "Afspelen", "Play", "Play", "Esita", "Toista", "Lire", "Lire", "Abspielen", "Αναπαραγωγή", "נגן", "Play", "Lejátszás",
"Play", "Riproduci", "Play", "Ойнату", "재생", "Leisti", "Play", "Spill", "Play", "Odtwarzaj", "Reproduzir", "Reproduzir",
"Play", "Смотреть", "Prehrať", "Play", "Reproducir", "Play", "Reproducir", "Play", "Spela",
"Play", "Oynat", "Відтворити", ""];
var button_pause_array = ["إيقاف مؤقت", "Pause", "Пауза", "Pause", "暂停", "暫停", "Pause", "Pause", "Pause",
"Pause", "Pauze", "Pause", "Pause", "Paus", "Pysäytä", "Pause", "Pause", "Pause", "Παύση", "Pause", "Pause", "Szünet",
"Pause", "Pause", "Pause", "Pause", "일시정지", "Pause", "Pause", "Pause", "Pause", "Wstrzymaj", "Pausar", "Pause",
"Pause", "Пауза", "Pozastaviť", "Pause", "Pausa", "Pause", "Pausa", "Pause", "Pausa",
"Pause", "Pause", "Пауза", ""];

function writeLog(text, type) {
var today = new Date();
Expand Down Expand Up @@ -45,7 +61,7 @@ function pause() {

writeLog("Pausing.", "INFO");

if(pause_button.getAttribute("title") == "Pause") {
if(button_pause_array.includes(play_button.getAttribute("title"))){
pause_button.click();
}
}
Expand All @@ -54,7 +70,7 @@ function play() {
var pause_button = document.getElementsByClassName("videoOsd-btnPause")[0];


if(pause_button.getAttribute("title") == "Play") {
if(button_play_array.includes(play_button.getAttribute("title"))){
pause_button.click();
}
}
Expand Down Expand Up @@ -139,15 +155,15 @@ function connectToServer(server_tmp, port_tmp) {
percentage = percentage.split(":")[1].split("%")[0];

var play_button = document.getElementsByClassName("videoOsd-btnPause")[0];
if(play_button.getAttribute("title") == "Play") {
if(button_play_array.includes(play_button.getAttribute("title"))){
// Sending Play with percentage Server
sending = {
"command": "play",
"percentage": percentage
}
writeLog("Sending JSON data to server: " + JSON.stringify(sending), "INFO");
ws.send(JSON.stringify(sending));
} else if(play_button.getAttribute("title") == "Pause") {
}else if(button_pause_array.includes(play_button.getAttribute("title"))){
// Sending Play with percentage Server
sending = {
"command": "pause",
Expand All @@ -174,15 +190,15 @@ function connectToServer(server_tmp, port_tmp) {
percentage = percentage.split(":")[1].split("%")[0];

var play_button = document.getElementsByClassName("videoOsd-btnPause")[0];
if(play_button.getAttribute("title") == "Play") {
if(button_play_array.includes(play_button.getAttribute("title"))){
// Sending Play with percentage Server
sending = {
"command": "play",
"percentage": percentage
}
writeLog("Sending JSON data to server: " + JSON.stringify(sending), "INFO");
ws.send(JSON.stringify(sending));
} else if(play_button.getAttribute("title") == "Pause") {
}else if(button_pause_array.includes(play_button.getAttribute("title"))){
// Sending Play with percentage Server
sending = {
"command": "pause",
Expand Down Expand Up @@ -252,15 +268,15 @@ function connectToServer(server_tmp, port_tmp) {
var percentage = (((time_left - 10) / (time_right + time_left)) * 100).toFixed(2);

var play_button = document.getElementsByClassName("videoOsd-btnPause")[0];
if(play_button.getAttribute("title") == "Play") {
if(button_play_array.includes(play_button.getAttribute("title"))){
// Sending Pause with percentage Server
sending = {
"command": "pause",
"percentage": percentage
}
writeLog("Sending JSON data to server: " + JSON.stringify(sending), "INFO");
ws.send(JSON.stringify(sending));
} else if(play_button.getAttribute("title") == "Pause") {
}else if(button_pause_array.includes(play_button.getAttribute("title"))){
// Sending Play with percentage Server
sending = {
"command": "play",
Expand Down Expand Up @@ -296,15 +312,15 @@ function connectToServer(server_tmp, port_tmp) {
var percentage = (((time_left + 10) / (time_right + time_left)) * 100).toFixed(2);

var play_button = document.getElementsByClassName("videoOsd-btnPause")[0];
if(play_button.getAttribute("title") == "Play") {
if(button_play_array.includes(play_button.getAttribute("title"))){
// Sending Pause with percentage Server
sending = {
"command": "pause",
"percentage": percentage
}
writeLog("Sending JSON data to server: " + JSON.stringify(sending), "INFO");
ws.send(JSON.stringify(sending));
} else if(play_button.getAttribute("title") == "Pause") {
}else if(button_pause_array.includes(play_button.getAttribute("title"))){
// Sending Play with percentage Server
sending = {
"command": "play",
Expand All @@ -326,15 +342,15 @@ function connectToServer(server_tmp, port_tmp) {
percentage = percentage.split(":")[1].split("%")[0];

var play_button = document.getElementsByClassName("videoOsd-btnPause")[0];
if(play_button.getAttribute("title") == "Play") {
if(button_play_array.includes(play_button.getAttribute("title"))){
// Sending Pause with percentage Server
sending = {
"command": "pause",
"percentage": percentage
}
writeLog("Sending JSON data to server: " + JSON.stringify(sending), "INFO");
ws.send(JSON.stringify(sending));
} else if(play_button.getAttribute("title") == "Pause") {
}else if(button_pause_array.includes(play_button.getAttribute("title"))){
// Sending Play with percentage Server
sending = {
"command": "play",
Expand Down
2 changes: 1 addition & 1 deletion extension/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Emby Sync Watch",
"description": "A Chrome Extension for sync video watching on Emby.",
"version": "1.4",
"version": "1.5",
"manifest_version": 3,
"background": {
"service_worker": "background.js"
Expand Down

0 comments on commit 8e7af5e

Please sign in to comment.