diff --git a/syncHime/_locales/en/messages.json b/syncHime/_locales/en/messages.json index e0c9052..a926d02 100644 --- a/syncHime/_locales/en/messages.json +++ b/syncHime/_locales/en/messages.json @@ -1,10 +1,14 @@ { "websocketConnectStart": { "message": "websocket connect start", - "description": "The string we search for. Put %20 between words that go together." + "description": "nope" }, "save": { "message": "save", - "description": "The string we search for. Put %20 between words that go together." + "description": "nope" + }, + "saving": { + "message": "saving", + "description": "nope" } } \ No newline at end of file diff --git a/syncHime/_locales/zh_CN/messages.json b/syncHime/_locales/zh_CN/messages.json index 0e5ff4c..c50a806 100644 --- a/syncHime/_locales/zh_CN/messages.json +++ b/syncHime/_locales/zh_CN/messages.json @@ -1,10 +1,14 @@ { "websocketConnectStart": { "message": "websocket 开始连接", - "description": "The string we search for. Put %20 between words that go together." + "description": "nope" }, "save": { "message": "保存", - "description": "The string we search for. Put %20 between words that go together." + "description": "nope" + }, + "saving": { + "message": "保存中", + "description": "nope" } } \ No newline at end of file diff --git a/syncHime/domAppend.js b/syncHime/domAppend.js index 33fe56a..bcbe65f 100644 --- a/syncHime/domAppend.js +++ b/syncHime/domAppend.js @@ -1,4 +1,4 @@ -document.addEventListener("DOMContentLoaded", function () { +document.addEventListener("DOMContentLoaded", async function () { let send = chrome.runtime.getURL("icon/send.svg"); let connect = chrome.runtime.getURL("icon/connect.svg"); let disconnect = chrome.runtime.getURL("icon/disconnect.svg"); @@ -26,5 +26,17 @@ document.addEventListener("DOMContentLoaded", function () { if (location.href.match("bilibili")) document.querySelector("#bilibiliPlayer").appendChild(div); if (location.href.match("youtube")) document.body.appendChild(div); + if (location.href.match("iqiyi")) { + await waitSec(2); + document.querySelector(".iqp-player").appendChild(div); + } // document.body.appendChild(div) }); + +function waitSec(sec) { + return new Promise((resolve, reject) => { + setTimeout(() => { + resolve(); + }, sec * 1000); + }); +} \ No newline at end of file diff --git a/syncHime/index.css b/syncHime/index.css index 97a75d7..a4414b0 100644 --- a/syncHime/index.css +++ b/syncHime/index.css @@ -1,4 +1,5 @@ #connect-window { + box-sizing: content-box !important; position: fixed; bottom: 20px; right: 20px; @@ -15,7 +16,9 @@ transition: background-color 1s 0s, height 1s 0s, width 1s 0s, color 1s 0s, padding 1s 0s, border-color 1s 0s; } + #connect-window * { + box-sizing: content-box !important; opacity: 1; transition: opacity 1s 0.5s; } diff --git a/syncHime/index.js b/syncHime/index.js index 75ba01a..d63b0ed 100644 --- a/syncHime/index.js +++ b/syncHime/index.js @@ -44,6 +44,10 @@ document.addEventListener("DOMContentLoaded", async function () { video = document.querySelector(".bilibili-player-video video"); if (location.href.match("youtube")) video = document.querySelector(".ytd-player video"); + if (location.href.match("iqiyi")) { + await waitSec(2); + video = document.querySelector(".iqp-player video"); + } const messageBox = document.querySelector("#message-box"); const connectWindow = document.querySelector("#connect-window"); const start = document.querySelector("#start-button"); @@ -352,3 +356,29 @@ function storageGet(key) { }); }); } + +function waitFor(propertyName, value) { + return new Promise((resolve, reject) => { + let observer = new MutationObserver((mutations) => { + mutations.forEach((mutation) => { + if (!mutation.addedNodes) return; + for (let i = 0; i < mutation.addedNodes.length; i++) { + // do things to your newly added nodes here + let node = mutation.addedNodes[i]; + if (node[propertyName] === value) { + resolve(); + // stop watching using: + observer.disconnect(); + } + } + }); + }); + + observer.observe(document.body, { + childList: true, + subtree: true, + attributes: false, + characterData: false, + }); + }); +} diff --git a/syncHime/manifest.json b/syncHime/manifest.json index ac8dca0..39a9d60 100644 --- a/syncHime/manifest.json +++ b/syncHime/manifest.json @@ -13,6 +13,7 @@ "matches": [ "https://www.bilibili.com/video/*", "https://www.bilibili.com/bangumi/play/*", + "https://www.iqiyi.com/v_*", "https://www.youtube.com/watch*" ], "js": [ diff --git a/syncHime/popup.js b/syncHime/popup.js index f2b198f..4c079d7 100644 --- a/syncHime/popup.js +++ b/syncHime/popup.js @@ -2,6 +2,7 @@ const url = document.querySelector("#websocket-url"); const type = document.querySelector("#connection-type"); const save = document.querySelector("#save"); +save.innerText = chrome.i18n.getMessage("save"); chrome.storage.sync.get(["websocket", "connectionType"], function (result) { url.value = result.websocket || "synchime.herokuapp.com";