mirror of
https://github.com/krateng/maloja.git
synced 2023-08-10 21:12:55 +03:00
Chrome extension now shows number of handled tabs
This commit is contained in:
parent
2944830df6
commit
29171bda0b
@ -105,6 +105,11 @@ countas Hwasa Mamamoo
|
|||||||
replaceartist Hwa Sa Hwasa
|
replaceartist Hwa Sa Hwasa
|
||||||
replaceartist MAMAMOO Mamamoo
|
replaceartist MAMAMOO Mamamoo
|
||||||
replacetitle Egotistic(너나 해) Egotistic
|
replacetitle Egotistic(너나 해) Egotistic
|
||||||
|
replacetitle Mr.Ambiguous Mr. Ambiguous
|
||||||
|
replacetitle Mr.애매모호 (Mr. Ambiguous) Mr. Ambiguous
|
||||||
|
replacetitle AHH OOP! (아훕!) (AHH OOP!) AHH OOP!
|
||||||
|
replacetitle 음오아예 (Um Oh Ah Yeh) (Um Oh Ah Yeh) Um Oh Ah Yeh
|
||||||
|
replacetitle 따끔 (a little bit) A Little Bit
|
||||||
|
|
||||||
# Hello Venus
|
# Hello Venus
|
||||||
replaceartist Hello/Venus Hello Venus
|
replaceartist Hello/Venus Hello Venus
|
||||||
|
Can't render this file because it has a wrong number of fields in line 5.
|
@ -32,6 +32,13 @@ pages = {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function updateTabNum() {
|
||||||
|
|
||||||
|
var amount = Object.keys(tabManagers).length;
|
||||||
|
chrome.browserAction.setBadgeText({"text":amount.toString()});
|
||||||
|
chrome.browserAction.setBadgeBackgroundColor({"color":"#440000"});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function onTabUpdated(tabId, changeInfo, tab) {
|
function onTabUpdated(tabId, changeInfo, tab) {
|
||||||
|
|
||||||
@ -40,29 +47,30 @@ function onTabUpdated(tabId, changeInfo, tab) {
|
|||||||
//console.log("Update to tab " + tabId + "!")
|
//console.log("Update to tab " + tabId + "!")
|
||||||
if (tabManagers.hasOwnProperty(tabId)) {
|
if (tabManagers.hasOwnProperty(tabId)) {
|
||||||
//console.log("Yes!")
|
//console.log("Yes!")
|
||||||
page = tabManagers[tabId].page
|
page = tabManagers[tabId].page;
|
||||||
patterns = pages[page]["patterns"]
|
patterns = pages[page]["patterns"];
|
||||||
//console.log("Page was managed by a " + page + " manager")
|
//console.log("Page was managed by a " + page + " manager")
|
||||||
for (var i=0;i<patterns.length;i++) {
|
for (var i=0;i<patterns.length;i++) {
|
||||||
if (tab.url.startsWith(patterns[i])) {
|
if (tab.url.startsWith(patterns[i])) {
|
||||||
//console.log("Still on same page!")
|
//console.log("Still on same page!")
|
||||||
tabManagers[tabId].update()
|
tabManagers[tabId].update();
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.log("Page on tab " + tabId + " changed, removing old " + page + " manager!")
|
console.log("Page on tab " + tabId + " changed, removing old " + page + " manager!");
|
||||||
delete tabManagers[tabId]
|
delete tabManagers[tabId];
|
||||||
}
|
}
|
||||||
|
|
||||||
//check if pattern matches
|
//check if pattern matches
|
||||||
for (var key in pages) {
|
for (var key in pages) {
|
||||||
if (pages.hasOwnProperty(key)) {
|
if (pages.hasOwnProperty(key)) {
|
||||||
patterns = pages[key]["patterns"]
|
patterns = pages[key]["patterns"];
|
||||||
for (var i=0;i<patterns.length;i++) {
|
for (var i=0;i<patterns.length;i++) {
|
||||||
if (tab.url.startsWith(patterns[i])) {
|
if (tab.url.startsWith(patterns[i])) {
|
||||||
console.log("New page on tab " + tabId + " will be handled by new " + key + " manager!")
|
console.log("New page on tab " + tabId + " will be handled by new " + key + " manager!");
|
||||||
tabManagers[tabId] = new Controller(tabId,key)
|
tabManagers[tabId] = new Controller(tabId,key);
|
||||||
|
updateTabNum();
|
||||||
return
|
return
|
||||||
//chrome.tabs.executeScript(tab.id,{"file":"sitescripts/" + pages[key]["script"]})
|
//chrome.tabs.executeScript(tab.id,{"file":"sitescripts/" + pages[key]["script"]})
|
||||||
|
|
||||||
@ -78,10 +86,11 @@ function onTabUpdated(tabId, changeInfo, tab) {
|
|||||||
function onTabRemoved(tabId,removeInfo) {
|
function onTabRemoved(tabId,removeInfo) {
|
||||||
|
|
||||||
if (tabManagers.hasOwnProperty(tabId)) {
|
if (tabManagers.hasOwnProperty(tabId)) {
|
||||||
page = tabManagers[tabId].page
|
page = tabManagers[tabId].page;
|
||||||
console.log("closed tab was " + page + ", now removing manager")
|
console.log("closed tab was " + page + ", now removing manager");
|
||||||
tabManagers[tabId].stopPlayback("","") //in case we want to scrobble the playing track
|
tabManagers[tabId].stopPlayback("",""); //in case we want to scrobble the playing track
|
||||||
delete tabManagers[tabId]
|
delete tabManagers[tabId];
|
||||||
|
updateTabNum();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -96,10 +105,10 @@ function onInternalMessage(request,sender) {
|
|||||||
for (tabId in tabManagers) {
|
for (tabId in tabManagers) {
|
||||||
manager = tabManagers[tabId]
|
manager = tabManagers[tabId]
|
||||||
if (manager.currentlyPlaying) {
|
if (manager.currentlyPlaying) {
|
||||||
answer.push([manager.page,manager.currentArtist,manager.currentTitle])
|
answer.push([manager.page,manager.currentArtist,manager.currentTitle]);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
answer.push([manager.page,null])
|
answer.push([manager.page,null]);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -112,7 +121,7 @@ function onInternalMessage(request,sender) {
|
|||||||
//console.log("Message was sent from tab id " + tabId)
|
//console.log("Message was sent from tab id " + tabId)
|
||||||
if (tabManagers.hasOwnProperty(tabId)) {
|
if (tabManagers.hasOwnProperty(tabId)) {
|
||||||
//console.log("This is managed! Seems to be " + tabManagers[tabId].page)
|
//console.log("This is managed! Seems to be " + tabManagers[tabId].page)
|
||||||
tabManagers[tabId].playbackUpdate(request)
|
tabManagers[tabId].playbackUpdate(request);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user