mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-18 21:48:33 +03:00
Create background.js
This commit is contained in:
15
background.js
Normal file
15
background.js
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
chrome.tabs.onUpdated.addListener(
|
||||||
|
function(tabId, changeInfo, tab) {
|
||||||
|
if (youtube_parser(changeInfo.url)) {
|
||||||
|
chrome.tabs.sendMessage( tabId, {
|
||||||
|
message: 'ytvideo',
|
||||||
|
url: changeInfo.url
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
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;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user