Skip to content

Commit b2ce648

Browse files
major update for youtube ads
1 parent 11f87ec commit b2ce648

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

content.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
var script = document.createElement('script');
2+
script.src = chrome.extension.getURL('inject.js');
3+
(document.head || document.documentElement).appendChild(script);

inject.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
const clear = (() => {
2+
const defined = v => v !== null && v !== undefined;
3+
const timeout = setInterval(() => {
4+
const ad = [...document.querySelectorAll('.ad-showing')][0];
5+
if (defined(ad)) {
6+
const video = document.querySelector('video');
7+
if (defined(video)) {
8+
video.currentTime = video.duration;
9+
}
10+
}
11+
}, 500);
12+
return function () {
13+
clearTimeout(timeout);
14+
}
15+
})();

manifest.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,19 @@
1414
"background.js"
1515
]
1616
},
17+
"content_scripts": [
18+
{
19+
"js": [
20+
"content.js"
21+
],
22+
"matches": [
23+
"<all_urls>"
24+
]
25+
}
26+
],
27+
"web_accessible_resources": [
28+
"inject.js"
29+
],
1730
"browser_action": {
1831
"default_icon": {
1932
"32": "icon.png"

0 commit comments

Comments
 (0)