From 7c550a8052a4f9feac6815ed2d2ecc8a003e1ec1 Mon Sep 17 00:00:00 2001 From: pantyetta Date: Sat, 9 Dec 2023 13:41:57 +0900 Subject: [PATCH 1/5] ReInsert script on tab Reloaded --- background.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/background.js b/background.js index a351528..092af5e 100644 --- a/background.js +++ b/background.js @@ -39,17 +39,26 @@ const skipAds = (tabId) => { const isEmpty = (obj) => { return !Object.keys(obj).length; - } +} + +chrome.webNavigation.onCommitted.addListener((details) => { + if (details.transitionType === 'reload') { + chrome.storage.session.remove([details.tabId.toString()]); + console.log("remove script"); + } +}, {url: [{urlMatches : 'https://www.youtube.com/*'}]}); chrome.tabs.onUpdated.addListener((tabId, changeInfo, tab) => { const pattern = /^https:\/\/(www\.)?youtube\.com\/.+/ if(tab.url.match(pattern) && changeInfo.status === 'complete'){ + chrome.storage.session.get([tabId.toString()]).then((result) => { if(isEmpty(result)){ + console.log("insert script"); skipAds(tabId); } }); chrome.storage.session.set({ [tabId]: true }); } -}) \ No newline at end of file +}); \ No newline at end of file From 52df4ebd523ad462c24e1994647c92a16ad412e0 Mon Sep 17 00:00:00 2001 From: pantyetta Date: Sat, 9 Dec 2023 13:44:22 +0900 Subject: [PATCH 2/5] fix action order conditions --- background.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/background.js b/background.js index 092af5e..e4793f4 100644 --- a/background.js +++ b/background.js @@ -10,15 +10,11 @@ const skipAds = (tabId) => { }; const $player = document.getElementById('movie_player'); - const video = document.querySelector('video'); const playerObserver = new MutationObserver(() => { const $skip_container = document.getElementsByClassName("video-ads ytp-ad-module")[0] || null; - if(!$skip_container.children.length) return; - - if(video.currentTime == video.duration) return; - - video.currentTime = video.duration; + console.log("skip container"); + if($skip_container == null || !$skip_container.children.length) return; const observer = new MutationObserver(() => { const $skip_button = document.getElementsByClassName('ytp-ad-skip-button-modern ytp-button')[0] || null; @@ -28,8 +24,14 @@ const skipAds = (tabId) => { observer.disconnect(); }); - observer.observe($skip_container, config); + + const video = document.querySelector('video'); + try { + video.currentTime = video.duration; + console.log('skip ads'); + } catch (error) {} + }); playerObserver.observe($player, config); }, From d6a2ecf9d01872d5c59b66bc562622ec8f139af6 Mon Sep 17 00:00:00 2001 From: pantyetta Date: Sat, 9 Dec 2023 13:53:34 +0900 Subject: [PATCH 3/5] update manifest permissions --- manifest.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index 14f9fa9..70dccf6 100644 --- a/manifest.json +++ b/manifest.json @@ -15,7 +15,8 @@ "activeTab", "tabs", "scripting", - "storage" + "storage", + "webNavigation" ], "host_permissions": [ "https://www.youtube.com/*", From 88a8dcf4a5064fdaa5197f27e17a3a62cce9ffef Mon Sep 17 00:00:00 2001 From: pantyetta Date: Sat, 9 Dec 2023 14:08:36 +0900 Subject: [PATCH 4/5] update README --- README.md | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 42e21ca..114fa33 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,17 @@ # auto skip ads youtube広告を自動でスキップします. -機能は以上です. - 15-30程度の広告のスキップボタンを自動で押します. -- スキップ不能の広告を16倍で再生します. +- スキップ不能の広告をスキップします. **広告自体のブロックはしません** ## install -### store (推奨) -[chromewebstoreからinstall](https://chromewebstore.google.com/detail/auto-skip-ads/bladpfbfkeddfhdojdjcopkejlmgapla)からインストール. +### Store (推奨) +[Chrome Webstore](https://chromewebstore.google.com/detail/auto-skip-ads/bladpfbfkeddfhdojdjcopkejlmgapla)からインストール. ### self -1. cloneかzipをダウンロードする +1. [最新版のzip](https://github.com/pantyetta/autoskip-ads/releases)をダウンロードする 2. [拡張機能ページにアクセスする](chrome://extensions/) 3. 右上ののdeveloper modeを有効にする 4. パッケージ化されていない拡張機能を読み込む を利用する From e8e67abbdb5582869e046127dd4730c436ec4091 Mon Sep 17 00:00:00 2001 From: pantyetta Date: Sat, 9 Dec 2023 14:09:21 +0900 Subject: [PATCH 5/5] udpate manifest version --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index 70dccf6..22ea514 100644 --- a/manifest.json +++ b/manifest.json @@ -1,6 +1,6 @@ { "name": "auto skip ads", - "version": "1.0.4", + "version": "1.0.5", "description": "youtube広告をブロックせずにスキップします", "manifest_version": 3, "background": {