Do old frame cleanup with polling
This commit is contained in:
parent
9019963597
commit
7d8758d1ee
@ -237,12 +237,28 @@ class PageInfo {
|
|||||||
// if we're left without videos on the current page, we unregister the page.
|
// if we're left without videos on the current page, we unregister the page.
|
||||||
// if we have videos, we call register.
|
// if we have videos, we call register.
|
||||||
if (this.comms) {
|
if (this.comms) {
|
||||||
if (this.videos.length != oldVideoCount) { // only if number of videos changed, tho
|
// We used to send "register video" requests only on the first load, or if the number of
|
||||||
if (this.videos.length > 0) {
|
// videos on the page has changed. However, since Chrome Web Store started to require every
|
||||||
this.comms.registerVideo({host: window.location.host, location: window.location});
|
// extension requiring "broad permissions" to undergo manual review
|
||||||
} else {
|
// ... and since Chrome Web Store is known for taking their sweet ass time reviewing extensions,
|
||||||
this.comms.unregisterVideo({host: window.location.host, location: window.location});
|
// with review times north of an entire fucking month
|
||||||
}
|
// ... and since the legacy way of checking whether our frames-with-videos cache in background
|
||||||
|
// script contains any frames that no longer exist required us to use webNavigation.getFrame()/
|
||||||
|
// webNavigation.getAllFrames(), which requires a permission that triggers a review.
|
||||||
|
//
|
||||||
|
// While the extension uses some other permissions that trigger manual review, it's said that
|
||||||
|
// less is better / has a positive effect on your manual review times ... So I guess we'll do
|
||||||
|
// things in the less-than-optimal. more-than-retarded way.
|
||||||
|
//
|
||||||
|
// no but honestly fuck Chrome.
|
||||||
|
|
||||||
|
// if (this.videos.length != oldVideoCount) {
|
||||||
|
// }
|
||||||
|
|
||||||
|
if (this.videos.length > 0) {
|
||||||
|
this.comms.registerVideo({host: window.location.host, location: window.location});
|
||||||
|
} else {
|
||||||
|
this.comms.unregisterVideo({host: window.location.host, location: window.location});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,14 +173,11 @@ class UWServer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this.videoTabs[sender.tab.id]) {
|
if (this.videoTabs[sender.tab.id]) {
|
||||||
if (this.videoTabs[sender.tab.id].frames[sender.frameId]) {
|
this.videoTabs[sender.tab.id].frames[sender.frameId] = {
|
||||||
return; // existing value is fine, no need to act
|
id: sender.frameId,
|
||||||
} else {
|
host: frameHostname,
|
||||||
this.videoTabs[sender.tab.id].frames[sender.frameId] = {
|
url: sender.url,
|
||||||
id: sender.frameId,
|
registerTime: Date.now(),
|
||||||
host: frameHostname,
|
|
||||||
url: sender.url
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.videoTabs[sender.tab.id] = {
|
this.videoTabs[sender.tab.id] = {
|
||||||
@ -192,7 +189,8 @@ class UWServer {
|
|||||||
this.videoTabs[sender.tab.id].frames[sender.frameId] = {
|
this.videoTabs[sender.tab.id].frames[sender.frameId] = {
|
||||||
id: sender.frameId,
|
id: sender.frameId,
|
||||||
host: frameHostname,
|
host: frameHostname,
|
||||||
url: sender.url
|
url: sender.url,
|
||||||
|
registerTime: Date.now(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -290,6 +288,25 @@ class UWServer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this.videoTabs[ctab.id]) {
|
if (this.videoTabs[ctab.id]) {
|
||||||
|
// if video is older than PageInfo's video rescan period (+ 4000ms of grace),
|
||||||
|
// we clean it up from videoTabs[tabId].frames array.
|
||||||
|
const ageLimit = Date.now() - this.settings.active.pageInfo.timeouts.rescan - 4000;
|
||||||
|
console.log("videoTabs[tabId]:", this.videoTabs[ctab.id])
|
||||||
|
try {
|
||||||
|
for (const key in this.videoTabs[ctab.id].frames) {
|
||||||
|
if (this.videoTabs[ctab.id].frames[key].registerTime < ageLimit) {
|
||||||
|
delete this.videoTabs[ctab.id].frames[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
// something went wrong. There's prolly no frames.
|
||||||
|
return {
|
||||||
|
host: this.extractHostname(ctab.url),
|
||||||
|
frames: [],
|
||||||
|
selected: this.selectedSubitem
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...this.videoTabs[ctab.id],
|
...this.videoTabs[ctab.id],
|
||||||
host: this.extractHostname(ctab.url),
|
host: this.extractHostname(ctab.url),
|
||||||
|
Loading…
Reference in New Issue
Block a user