-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
5,256 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/web-ext-artifacts | ||
/.phpunit.cache | ||
/node_modules | ||
npm-debug.log | ||
yarn-error.log | ||
/.idea | ||
/.vscode | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
## Video Ad Monitor | ||
|
||
Firefox browser extension |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
"use strict"; | ||
|
||
let currentState = false; | ||
|
||
/** | ||
* @param {boolean} state | ||
* @return {Promise} | ||
*/ | ||
function setTabState(state) { | ||
return browser.tabs.query({ | ||
url: 'https://www.youtube.com/watch?v=*' | ||
}) | ||
.then((tabs) => { | ||
tabs.forEach((t) => { | ||
browser.tabs.sendMessage(t.id, { | ||
tabID: t.id, | ||
active: t.active, | ||
state | ||
}) | ||
.catch((err) => { | ||
throw err; | ||
}); | ||
}); | ||
|
||
return true; | ||
}) | ||
.catch((err) => { | ||
console.error(err); | ||
|
||
return false; | ||
}); | ||
} | ||
|
||
async function buttonClick() { | ||
currentState = !currentState; | ||
|
||
let result = await setTabState(currentState); | ||
|
||
if (result === false) { return; } | ||
|
||
const icon = (currentState === true) ? 'on.png' : 'off.png'; | ||
|
||
result = browser.browserAction.setIcon({ | ||
path: { | ||
48: icon | ||
} | ||
}) | ||
.then(() => { | ||
browser.browserAction.setTitle({ | ||
title: currentState ? 'on' : 'off' | ||
}); | ||
}) | ||
.catch((err) => { | ||
console.error(err); | ||
}); | ||
} | ||
|
||
browser.browserAction.onClicked.addListener(buttonClick); | ||
|
||
browser.tabs.onUpdated.addListener((tabID, changeInfo, tab) => { | ||
if (currentState === true && changeInfo.status === 'complete') { | ||
setTimeout(() => { | ||
setTabState(true); | ||
}, 500); | ||
} | ||
}, { | ||
urls: ['*://www.youtube.com/watch?v=*'], | ||
properties: ['status', 'url'] | ||
}); | ||
|
||
browser.runtime.onMessage.addListener((observer) => { | ||
console.log(observer); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"manifest_version": 2, | ||
"name": "Video Ad Monitor", | ||
"version": "2.0", | ||
"description": "Mutes the sound during non-skippable ads, closes banners, and clicks the skip now button when present.", | ||
"icons": { | ||
"48": "off.png", | ||
"48": "on.png" | ||
}, | ||
"browser_action": { | ||
"default_icon": "off.png", | ||
"default_title": "off" | ||
}, | ||
"permissions": [ | ||
"tabs" | ||
], | ||
"incognito": "spanning", | ||
"background": { | ||
"scripts": ["background.js"] | ||
}, | ||
"content_scripts": [ | ||
{ | ||
"matches": ["*://www.youtube.com/*"], | ||
"js": ["video.js"] | ||
} | ||
] | ||
} |
Oops, something went wrong.