From ee63bbedfe5b42c984bb40904f079c6f9450142a Mon Sep 17 00:00:00 2001 From: "DONOKO.Anoko" <46491591+donokoanoko@users.noreply.github.com> Date: Thu, 16 Nov 2023 22:24:31 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=9A=E3=83=BC=E3=82=B8=E7=A7=BB=E5=8B=95?= =?UTF-8?q?=E3=81=AE=E6=99=82=E3=82=82=E3=83=8F=E3=83=BC=E3=83=88=E3=82=92?= =?UTF-8?q?=E5=8B=95=E3=81=8B=E3=81=9B=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- background.js | 11 +++++++++++ manifest.json | 13 +++++++++++-- move_heart.js | 54 ++++++++++++++++++++++++++------------------------- 3 files changed, 50 insertions(+), 28 deletions(-) create mode 100644 background.js diff --git a/background.js b/background.js new file mode 100644 index 0000000..c60a3dc --- /dev/null +++ b/background.js @@ -0,0 +1,11 @@ +chrome.tabs.onUpdated.addListener((tabId, changeInfo, tab) => { + if (changeInfo.status === 'complete' && tab.url.indexOf("https://www.youtube.com/watch?v=") !== -1) { + chrome.scripting.executeScript({ + target: { + "tabId": tabId, + "allFrames": true + }, + files: ["move_heart.js"], + }); + }; +}); \ No newline at end of file diff --git a/manifest.json b/manifest.json index 719ab46..b156d19 100644 --- a/manifest.json +++ b/manifest.json @@ -11,7 +11,11 @@ "128": "img/icon_128.png" }, "permissions": [ - "tabs" + "tabs", + "scripting" + ], + "host_permissions": [ + "https://www.youtube.com/watch?v=*" ], "content_scripts": [ { @@ -29,8 +33,13 @@ ], "js": [ "move_heart.js" - ] + ], + "run_at": "document_start" } ], + "background": { + "service_worker": "background.js" + }, + "action": {}, "key": "MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCV5mvNShSrZg+ZkF/rTWR8HhS7TgwNIu+zPO7yCfYA6tQRAeoTb7thtyqP4/pDHSAxXjqHwhViBGIptPd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y6nqql5JK+I7xvWErJfR3T+OgrhlY1ZcH67lIPJ4Bi3Rlnu6LzVzcenwQ6BN1uybqwKBgQC/17nbFR5AKDp5dUiaxSTu90zoB5TteV5rzc4qtHmGNmAAfceidn3R6FJBjvGgPowSwkQ9jQSsAPc9G3loy+WLraVavhk6c34gpbKl7EF8GCKudSWvXZqLLD4nia6oSGNq0qcOePRP0EoHAywk0wHS/cAZwoqhxopiK+pev3KH/wKBgFnG9dhSqX8dxrwXFP42kLj4ENDXg6AsMINHdVD8ZMQY6fE7W4VDRVpeQq6CGOBoS5nNktOdLSpFl7mxqWy+P8BjAoKSK+gZ1BUa90bzLtfzb/hxs1q9gwQgnpwlgqBnyTl9PF5S1zDUy2bZjMaNmpmdztLw7dmMBE1QmyzDA1/P" } \ No newline at end of file diff --git a/move_heart.js b/move_heart.js index 21e3df1..6e9ddfb 100644 --- a/move_heart.js +++ b/move_heart.js @@ -1,29 +1,31 @@ -const jsInitCheckTimer = setInterval(jsLoaded, 1000); -const archive_message = [ - "上位のチャットのリプレイ", - "チャットのリプレイ" -]; +{ + const jsInitCheckTimer = setInterval(jsLoaded, 1000); + const archive_message = [ + "上位のチャットのリプレイ", + "チャットのリプレイ" + ]; -function jsLoaded() { - if (document.getElementById("chatframe") !== null && document.getElementById("chatframe").contentWindow.document.getElementById("reaction-control-panel") != null) { - //Stream now - clearInterval(jsInitCheckTimer); + function jsLoaded() { + if (document.getElementById("chatframe") !== null && document.getElementById("chatframe").contentWindow.document.getElementById("reaction-control-panel") != null) { + //Stream now + clearInterval(jsInitCheckTimer); - const heart = document.getElementById("chatframe").contentWindow.document.getElementById("reaction-control-panel"); - heart.style.position = "absolute"; - heart.style.top = "35px"; - heart.style.rifht = "0px"; - } - else if (document.getElementById("chatframe") !== null && document.getElementById("chatframe").contentWindow.document.getElementById('label-text') !== null && archive_message.includes(document.getElementById("chatframe").contentWindow.document.getElementById('label-text').textContent)){ - //Archive - clearInterval(jsInitCheckTimer); - } - else if (document.getElementById("message") !== null && document.getElementById("message").textContent === "この動画ではチャットのリプレイを利用できません。"){ - //Archive(edit) - clearInterval(jsInitCheckTimer); - } - else if (document.getElementById("info-container") !== null && document.getElementById("info-container").textContent.indexOf("配信") == -1 && document.getElementById("info-container").textContent.indexOf("配信開始") !== -1){ - //Movie - clearInterval(jsInitCheckTimer); + const heart = document.getElementById("chatframe").contentWindow.document.getElementById("reaction-control-panel"); + heart.style.position = "absolute"; + heart.style.top = "35px"; + heart.style.rifht = "0px"; + } + else if (document.getElementById("chatframe") !== null && document.getElementById("chatframe").contentWindow.document.getElementById('label-text') !== null && archive_message.includes(document.getElementById("chatframe").contentWindow.document.getElementById('label-text').textContent)) { + //Archive + clearInterval(jsInitCheckTimer); + } + else if (document.getElementById("message") !== null && document.getElementById("message").textContent === "この動画ではチャットのリプレイを利用できません。") { + //Archive(edit) + clearInterval(jsInitCheckTimer); + } + else if (document.getElementById("info-container") !== null && document.getElementById("info-container").textContent.indexOf("配信") == -1 && document.getElementById("info-container").textContent.indexOf("配信開始") !== -1) { + //Movie + clearInterval(jsInitCheckTimer); + }; }; -}; \ No newline at end of file +} \ No newline at end of file