Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

merging remote changes on youtube branch

  • Loading branch information...
commit b987a5fcda6a8d2f2c5d0c4cec140783ab56b98f 2 parents 392d9a6 + e71e107
@jgv authored
Showing with 28 additions and 24 deletions.
  1. +9 −2 manifest.json
  2. +8 −17 tabby.js
  3. +11 −5 youtube.js
View
11 manifest.json
@@ -3,11 +3,18 @@
"version" : "0.0.1",
"description" : "Closes unattented tabs",
"background_page" : "background.html",
- "permissions" : [ "tabs" ],
+ "permissions" : [
+ "tabs",
+ "http://*/*",
+ "https://*/*"
+ ],
"options_page" : "options.html",
"content_scripts" : [
{
- "matches" : ["http://*/*"],
+ "matches" : [
+ "http://*/*",
+ "https://*/*"
+ ],
"js" : ["youtube.js"]
}
]
View
25 tabby.js
@@ -32,17 +32,6 @@ function checkTabs () {
if (tabs[i].counter >= timeout) {
if (!tabs[i].video) {
killTab(tabs[i], timerId);
- } else {
- chrome.tabs.executeScript(tabs[i].id,
- {file: "youtube.js"},
- function callback (state) {
- if (state === 1) {
- console.log('prevent');
- return false;
- } else {
- killTab(tabs[i], timerId);
- }
- });
}
// console.log(tabs[i].id + ': ' + tabs[i].counter);
}
@@ -58,12 +47,14 @@ chrome.tabs.onRemoved.addListener(function (tab) {
tabs.splice(tabs.indexOf(tab), 1);
});
-chrome.tabs.onUpdated.addListener(function (tabId, changeInfo, tab) {
- for (n = 0; n < tabs.length; n++) {
- if (tabs[n].id === tabId) {
- tabs[n].counter = 0;
- if (changeInfo.status === "loading" || "complete") {
- tabs[n].video = /youtube.com\/watch/.test(tab.url) ? true : false;
+chrome.tabs.onUpdated.addListener(function (youtube, sender, sendResponse) {
+ if (youtube) {
+ for (n = 0; n < tabs.length; n++) {
+ if (tabs[n].id === tabId) {
+ tabs[n].counter = 0;
+ if (changeInfo.status === "loading" || "complete") {
+ tabs[n].video = /youtube.com\/watch/.test(tab.url) ? true : false;
+ }
}
}
}
View
16 youtube.js
@@ -1,6 +1,12 @@
-var port = chrome.extension.connect();
+(function () {
+ var port = chrome.extension.connect();
-function onYouTubePlayerReady (tab) {
- ytplayer = document.getElementById("movie_player");
- return ytplayer.getPlayerState();
-}
+ var youtubeCheck = onYouTubePlayerReady();
+ chrome.extension.sendRequest(youTubeCheck);
+
+ function onYouTubePlayerReady (tab) {
+ ytplayer = document.getElementById("movie_player");
+ state = ytplayer.getPlayerState();
+ return state;
+ }
+}();

0 comments on commit b987a5f

Please sign in to comment.
Something went wrong with that request. Please try again.