Files
SponsorBlock/background.js
2019-01-18 19:50:09 +00:00

16 lines
472 B
JavaScript

chrome.tabs.onUpdated.addListener(
function(tabId, changeInfo, tab) {
if (changeInfo.url && id = youtube_parser(changeInfo.url)) {
chrome.tabs.sendMessage( tabId, {
message: 'ytvideoid',
id: id
})
}
}
);
function youtube_parser(url) {
var regExp = /^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#\&\?]*).*/;
var match = url.match(regExp);
return (match && match[7].length == 11) ? match[7] : false;
}