Added UI to support picking out sponsors and submitting

This commit is contained in:
Ajay Ramachandran
2019-07-08 23:43:06 -04:00
parent f81365414c
commit 2f32ead924
6 changed files with 162 additions and 9 deletions

View File

@@ -1,15 +1,20 @@
chrome.tabs.onUpdated.addListener( // On tab update
function(tabId, changeInfo, tab) {
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
})
if (changeInfo != undefined && changeInfo.url != undefined) {
console.log(changeInfo)
let id = youtube_parser(changeInfo.url);
if (changeInfo.url && id) { // If URL changed and is youtube video message contentScript the video id
chrome.tabs.sendMessage( tabId, {
message: 'ytvideoid',
id: id
})
}
}
}
);
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;
}
}