From 27cadb73e0d0b4acb81eb352a65ae12bef707988 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 20 Sep 2024 23:45:38 +0900 Subject: [PATCH 1/4] niconico first support beta --- background.js | 70 +++++++++++++++++++++++++++++++++++++++++++++++---- manifest.json | 4 ++- 2 files changed, 68 insertions(+), 6 deletions(-) diff --git a/background.js b/background.js index dfb8f65..8939906 100644 --- a/background.js +++ b/background.js @@ -1,4 +1,4 @@ -const skipAds = (tabId) => { +const y_skipAds = (tabId) => { chrome.scripting.executeScript({ target : {tabId: tabId }, func: () => { @@ -35,6 +35,53 @@ const skipAds = (tabId) => { }); } +const n_skipAds = (tabId) => { + chrome.scripting.executeScript({ + target : {tabId: tabId }, + func: () => { + const config = { + attributes: true, + childList: true, + characterData: true, + subtree: true, + }; + + const $root = document.getElementById('root'); + let skip_enable = true; + + const rootObserver = new MutationObserver(() => { + const video = document.querySelector("#nv_watch_VideoAdContainer > div > div:nth-child(1) > video") || null; + + if(!video) return; + + if(!video.duration) { + skip_enable = true; + return; + } + + if(video.currentTime == video.duration){ + const skipButton = document.querySelector("#nv_watch_VideoAdContainer > button") || null; + if(!skipButton) return; + skipButton.click(); + console.log("click") + return; + } + + if(!skip_enable) return; + + + try { + video.currentTime = video.duration; + console.log(video.currentTime) + skip_enable = false; + } catch (error) {} + + }); + rootObserver.observe($root, config); + }, + }); +} + const isEmpty = (obj) => { return !Object.keys(obj).length; @@ -44,15 +91,28 @@ chrome.webNavigation.onCommitted.addListener((details) => { if (details.transitionType === 'reload') { chrome.storage.session.remove([details.tabId.toString()]); } -}, {url: [{urlMatches : 'https://www.youtube.com/*'}]}); +}, {url: [{urlMatches : 'https://www.youtube.com/*'}, {urlMatches : 'https://www.nicovideo.jp/watch/*'}]}); chrome.tabs.onUpdated.addListener((tabId, changeInfo, tab) => { - const pattern = /^https:\/\/(www\.)?youtube\.com\/.+/ - if(tab.url.match(pattern) && changeInfo.status === 'complete'){ + const y_pattern = /^https:\/\/(www\.)?youtube\.com\/.+/ + const n_pattern = /^https:\/\/(www\.)?nicovideo\.jp\/watch\/.+/ + + if(tab.url.match(y_pattern) && changeInfo.status === 'complete'){ + + chrome.storage.session.get([tabId.toString()]).then((result) => { + if(isEmpty(result)){ + y_skipAds(tabId); + } + }); + + chrome.storage.session.set({ [tabId]: true }); + } + + if(tab.url.match(n_pattern) && changeInfo.status === 'complete'){ chrome.storage.session.get([tabId.toString()]).then((result) => { if(isEmpty(result)){ - skipAds(tabId); + n_skipAds(tabId); } }); diff --git a/manifest.json b/manifest.json index 22ea514..1373aa4 100644 --- a/manifest.json +++ b/manifest.json @@ -20,6 +20,8 @@ ], "host_permissions": [ "https://www.youtube.com/*", - "https://youtube.com/*" + "https://youtube.com/*", + "https://nicovideo.jp/watch/*", + "https://www.nicovideo.jp/watch/*" ] } \ No newline at end of file From 3404ec8e21bde3b81e96a1afab22e81b7cf5f9b2 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 23 Sep 2024 13:57:54 +0900 Subject: [PATCH 2/4] nico skip forced --- background.js | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/background.js b/background.js index 8939906..b1e216f 100644 --- a/background.js +++ b/background.js @@ -63,7 +63,6 @@ const n_skipAds = (tabId) => { const skipButton = document.querySelector("#nv_watch_VideoAdContainer > button") || null; if(!skipButton) return; skipButton.click(); - console.log("click") return; } @@ -72,7 +71,6 @@ const n_skipAds = (tabId) => { try { video.currentTime = video.duration; - console.log(video.currentTime) skip_enable = false; } catch (error) {} @@ -109,13 +107,6 @@ chrome.tabs.onUpdated.addListener((tabId, changeInfo, tab) => { } if(tab.url.match(n_pattern) && changeInfo.status === 'complete'){ - - chrome.storage.session.get([tabId.toString()]).then((result) => { - if(isEmpty(result)){ - n_skipAds(tabId); - } - }); - - chrome.storage.session.set({ [tabId]: true }); + n_skipAds(tabId); } }); \ No newline at end of file From 20fe5789f74301053f19886172f8e5bfa8c67219 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 23 Sep 2024 14:15:38 +0900 Subject: [PATCH 3/4] update README --- README.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 114fa33..669f723 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,13 @@ # auto skip ads youtube広告を自動でスキップします. -- 15-30程度の広告のスキップボタンを自動で押します. -- スキップ不能の広告をスキップします. +`v1.0.6`からニコニコをサポート! **広告自体のブロックはしません** +## suport site +- youtube +- niconico + ## install ### Store (推奨) From 5cd472a49d9a372d2610049934e62f2293ea298b Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 23 Sep 2024 14:15:49 +0900 Subject: [PATCH 4/4] update version tag --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index 1373aa4..738e4f2 100644 --- a/manifest.json +++ b/manifest.json @@ -1,6 +1,6 @@ { "name": "auto skip ads", - "version": "1.0.5", + "version": "1.0.6", "description": "youtube広告をブロックせずにスキップします", "manifest_version": 3, "background": {