소스 검색

Added workaround for Firefox performance bug

master
saturn 5 년 전
부모
커밋
36951432cf
1개의 변경된 파일19개의 추가작업 그리고 9개의 파일을 삭제
  1. 19
    9
      src/contentScript.js

+ 19
- 9
src/contentScript.js 파일 보기

@@ -166,20 +166,30 @@ function restoreScrollability() {
*/
function startConstantVigilance() {
// console.log("startConstantVigilance");
var observer = new MutationObserver((mutationsList, observer) => {
var observer;
var starter = function() {
observer.observe(document.querySelector("html"), {
attributes: true,
childList: true,
subtree: true
});
};

observer = new MutationObserver((mutationsList, observer) => {
// Workaround for Firefox performance bug. Firefox does not properly
// coalesce mutations into the mutationsList, instead calling the
// callback potentially thousands of times. Therefore we must
// disconnect the observer, wait for the main thread to become idle,
// and then restart it.
observer.disconnect();
window.requestIdleCallback(() => {
for (var mutation of mutationsList) {
killSticky(mutation.target);
}
killSticky();
starter();
});
});

console.log("Commencing vigilance for stickies!");
observer.observe(document.querySelector("html"), {
attributes: true,
childList: true,
subtree: true
});
starter();
}

/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/

Loading…
취소
저장