1
0
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:
Krateng 2019-05-19 11:09:35 +02:00
parent 2944830df6
commit 29171bda0b
2 changed files with 33 additions and 19 deletions

View File

@ -62,7 +62,7 @@ replacetitle 빨간 맛 Red Flavor Red Flavor
replacetitle 행복 (Happiness) Happiness
replacetitle 봐 Look Look
replacetitle RBB (Really Bad Boy) Really Bad Boy
replacetitle 7월 7일 One Of These Nights One Of These Nights
replacetitle 7월 7일 One Of These Nights One Of These Nights
# EXID
countas Dasoni EXID
@ -98,13 +98,18 @@ replacetitle Expect(기대해) Expect
replacetitle EXPECT Expect
replacetitle I'll be yours I'll Be Yours
replacetitle FEMALE PRESIDENT(여자 대통령) Female President
replacetitle 여자 대통령 Female President
replacetitle 여자 대통령 Female President
# Mamamoo
countas Hwasa Mamamoo
replaceartist Hwa Sa Hwasa
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
replaceartist Hello/Venus Hello Venus
@ -138,4 +143,4 @@ replaceartist A pink Apink
replaceartist CHUNG HA Chungha
replaceartist 청하 CHUNGHA Chungha
countas Chungha I.O.I
replacetitle 벌써 12시 Gotta Go Gotta Go
replacetitle 벌써 12시 Gotta Go Gotta Go

Can't render this file because it has a wrong number of fields in line 5.

View File

@ -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) {
@ -40,29 +47,30 @@ function onTabUpdated(tabId, changeInfo, tab) {
//console.log("Update to tab " + tabId + "!")
if (tabManagers.hasOwnProperty(tabId)) {
//console.log("Yes!")
page = tabManagers[tabId].page
patterns = pages[page]["patterns"]
page = tabManagers[tabId].page;
patterns = pages[page]["patterns"];
//console.log("Page was managed by a " + page + " manager")
for (var i=0;i<patterns.length;i++) {
if (tab.url.startsWith(patterns[i])) {
//console.log("Still on same page!")
tabManagers[tabId].update()
tabManagers[tabId].update();
return
}
}
console.log("Page on tab " + tabId + " changed, removing old " + page + " manager!")
delete tabManagers[tabId]
console.log("Page on tab " + tabId + " changed, removing old " + page + " manager!");
delete tabManagers[tabId];
}
//check if pattern matches
for (var key in pages) {
if (pages.hasOwnProperty(key)) {
patterns = pages[key]["patterns"]
patterns = pages[key]["patterns"];
for (var i=0;i<patterns.length;i++) {
if (tab.url.startsWith(patterns[i])) {
console.log("New page on tab " + tabId + " will be handled by new " + key + " manager!")
tabManagers[tabId] = new Controller(tabId,key)
console.log("New page on tab " + tabId + " will be handled by new " + key + " manager!");
tabManagers[tabId] = new Controller(tabId,key);
updateTabNum();
return
//chrome.tabs.executeScript(tab.id,{"file":"sitescripts/" + pages[key]["script"]})
@ -78,10 +86,11 @@ function onTabUpdated(tabId, changeInfo, tab) {
function onTabRemoved(tabId,removeInfo) {
if (tabManagers.hasOwnProperty(tabId)) {
page = tabManagers[tabId].page
console.log("closed tab was " + page + ", now removing manager")
tabManagers[tabId].stopPlayback("","") //in case we want to scrobble the playing track
delete tabManagers[tabId]
page = tabManagers[tabId].page;
console.log("closed tab was " + page + ", now removing manager");
tabManagers[tabId].stopPlayback("",""); //in case we want to scrobble the playing track
delete tabManagers[tabId];
updateTabNum();
}
}
@ -96,10 +105,10 @@ function onInternalMessage(request,sender) {
for (tabId in tabManagers) {
manager = tabManagers[tabId]
if (manager.currentlyPlaying) {
answer.push([manager.page,manager.currentArtist,manager.currentTitle])
answer.push([manager.page,manager.currentArtist,manager.currentTitle]);
}
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)
if (tabManagers.hasOwnProperty(tabId)) {
//console.log("This is managed! Seems to be " + tabManagers[tabId].page)
tabManagers[tabId].playbackUpdate(request)
tabManagers[tabId].playbackUpdate(request);
}
}