blob: c34ded69f456cb4de240dc8cf8a3f2b639780af9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
chrome.tabs.onUpdated.addListener(
function(tabId, changeInfo, tab) {
if (changeInfo.url) {
chrome.tabs.sendMessage( tabId, {
message: 'ytvideoid',
id: youtube_parser(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;
}
|