Skip to content

Commit

Permalink
ページ移動の時もハートを動かせるように
Browse files Browse the repository at this point in the history
  • Loading branch information
donokoanoko committed Nov 16, 2023
1 parent 5c0d363 commit ee63bbe
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 28 deletions.
11 changes: 11 additions & 0 deletions background.js
Original file line number Diff line number Diff line change
@@ -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"],
});
};
});
13 changes: 11 additions & 2 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@
"128": "img/icon_128.png"
},
"permissions": [
"tabs"
"tabs",
"scripting"
],
"host_permissions": [
"https://www.youtube.com/watch?v=*"
],
"content_scripts": [
{
Expand All @@ -29,8 +33,13 @@
],
"js": [
"move_heart.js"
]
],
"run_at": "document_start"
}
],
"background": {
"service_worker": "background.js"
},
"action": {},
"key": "MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCV5mvNShSrZg+ZkF/rTWR8HhS7TgwNIu+zPO7yCfYA6tQRAeoTb7thtyqP4/pDHSAxXjqHwhViBGIptPdfBucqbUXxzvPBsoAz91SS3lY2lVMs9juFNgiWt+t938OG2Ol8vfhDtAelXeVm9ac9DOaeaE+icqAu2IOlJy4PJwbKuc328sr4Mt1vcy/r5XAqoGuR2OXBK6KlS6ciUf9D0yU13NqFRvXhklCAfXUUCVlG/I+ilIhWR+NUttHPzIguyreBTJHwPLv7Czgda8V1UN+CDk8k7QRXuuZxIOx3V5y4GVyYBgifIbPCRQ2fybrNoKdBBZtmnmGBPMC8ceuc49txAgMBAAECggEAGxJuTbkfWoUoNBe6+wgTKcdU/y7tRkIVAE306YmbADdo7VlnKPN46ADokuwdepl8Au59q58FtZoNEHM6adMZVLQ/eZhitYzDUp9M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gnpwlgqBnyTl9PF5S1zDUy2bZjMaNmpmdztLw7dmMBE1QmyzDA1/P"
}
54 changes: 28 additions & 26 deletions move_heart.js
Original file line number Diff line number Diff line change
@@ -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);
};
};
};
}

0 comments on commit ee63bbe

Please sign in to comment.