mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-06 19:47:04 +03:00
Comments
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user