aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorOfficial Noob <[email protected]>2019-01-18 20:00:57 +0000
committerGitHub <[email protected]>2019-01-18 20:00:57 +0000
commit527c999ed568ee5516fae5c0366b46d4feecd232 (patch)
tree09da469d303adec4018996e5f41690bae7899b95
parent4bf3cac622208dccf8f01b793290ee55accbbc65 (diff)
downloadSponsorBlock-527c999ed568ee5516fae5c0366b46d4feecd232.tar.gz
SponsorBlock-527c999ed568ee5516fae5c0366b46d4feecd232.zip
Comments
-rw-r--r--background.js6
1 files changed, 3 insertions, 3 deletions
diff --git a/background.js b/background.js
index 924b2d31..21199ed1 100644
--- a/background.js
+++ b/background.js
@@ -1,6 +1,6 @@
-chrome.tabs.onUpdated.addListener(
+chrome.tabs.onUpdated.addListener( // On tab update
function(tabId, changeInfo, tab) {
- if (changeInfo.url && id = youtube_parser(changeInfo.url)) {
+ if (changeInfo.url && id = youtube_parser(changeInfo.url)) { // If URL changed and is youtube video message ContentScript the video id
chrome.tabs.sendMessage( tabId, {
message: 'ytvideoid',
id: id
@@ -8,7 +8,7 @@ chrome.tabs.onUpdated.addListener(
}
}
);
-function youtube_parser(url) {
+function youtube_parser(url) { // Return video id or false
var regExp = /^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#\&\?]*).*/;
var match = url.match(regExp);
return (match && match[7].length == 11) ? match[7] : false;