Skip to content

Commit

Permalink
[iOS] - Reduce Playlist Throttle (#24481)
Browse files Browse the repository at this point in the history
  • Loading branch information
Brandon-T authored Jul 3, 2024
1 parent c85ca8f commit 8fa909e
Showing 1 changed file with 15 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ window.__firefox__.includeOnce("Playlist", function($) {
}

let sendMessage = $(function(name, node, target, type, detected) {
let post = $(function() {
$(function() {
var location = "";
var pageTitle = "";

Expand All @@ -90,16 +90,7 @@ window.__firefox__.includeOnce("Playlist", function($) {
"tagId": target.$<tagUUID>,
"invisible": !target.parentNode
});
});

if (node.$<sendMessageTimeout>) {
clearTimeout(node.$<sendMessageTimeout>);
}

node.$<sendMessageTimeout> = setTimeout(function(){
node.$<sendMessageTimeout> = null;
post();
}, 2000);
})();
});

function isVideoNode(node) {
Expand Down Expand Up @@ -237,14 +228,9 @@ window.__firefox__.includeOnce("Playlist", function($) {
// MARK: ---------------------------------------

function setupDetector() {
var readyTimeout = null;
function onReady(fn) {
if (document.readyState === "complete" || document.readyState === "ready") {
if (readyTimeout) {
clearTimeout(readyTimeout);
}

readyTimeout = setTimeout(fn, 2000);
fn();
} else {
document.addEventListener("DOMContentLoaded", fn);
}
Expand Down Expand Up @@ -331,6 +317,12 @@ window.__firefox__.includeOnce("Playlist", function($) {
setAudioAttribute.call(this, key, value);
if (key.toLowerCase() == 'src') {
notifyNode(this, 'audio', true, false);

// Instead of using an interval and polling,
// we can check the page after a short period when an audio source has been setup.
setTimeout(function() {
checkPageForVideos(false);
}, 100);
}
});
}
Expand Down Expand Up @@ -386,9 +378,12 @@ window.__firefox__.includeOnce("Playlist", function($) {
});
})();
});


fetchMedia();

// Do one last check (if the page took too long to load - DailyMotion)
setTimeout(function() {
fetchMedia();
checkPageForVideos(false);
}, 5000);
}

Expand Down Expand Up @@ -419,9 +414,7 @@ window.__firefox__.includeOnce("Playlist", function($) {
});
}

setTimeout(function() {
checkPageForVideos(false);
}, 2000);
checkPageForVideos(false);
}

observePage();
Expand Down

0 comments on commit 8fa909e

Please sign in to comment.