aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorOfficial Noob <[email protected]>2019-01-15 18:24:44 +0000
committerGitHub <[email protected]>2019-01-15 18:24:44 +0000
commitec470408441d64b99a46b5e4af5d6151cfe74690 (patch)
treed00abd8f7affb8a0bd742c8ba15f3630bbacfca4
parent27226b11688d48e02815ad1e61fad87bfa6ded64 (diff)
downloadSponsorBlock-ec470408441d64b99a46b5e4af5d6151cfe74690.tar.gz
SponsorBlock-ec470408441d64b99a46b5e4af5d6151cfe74690.zip
Create background.js
-rw-r--r--background.js15
1 files changed, 15 insertions, 0 deletions
diff --git a/background.js b/background.js
new file mode 100644
index 00000000..3c0a0222
--- /dev/null
+++ b/background.js
@@ -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;
+}