Skip to content

Commit

Permalink
undoing mutation handler optimization - did it increase uninstalls? /…
Browse files Browse the repository at this point in the history
…why?
  • Loading branch information
ImprovedTube committed Mar 15, 2024
1 parent 0bf8911 commit a36e575
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 13 deletions.
24 changes: 20 additions & 4 deletions js&css/web-accessible/functions.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,36 @@
/*--------------------------------------------------------------
>>> FUNCTIONS
--------------------------------------------------------------*/
const DOM_filter = /^(SCRIPT|DOM-IF|DOM-REPEAT|svg|SPAN||#text|#comment|yt-icon-shape|iron-iconset-svg)$/;
ImprovedTube.childHandler = function (node) {
//console.log(node.nodeName);
if (node.nodeName === 'SCRIPT' || node.nodeName === 'iron-iconset-svg' || node.nodeName === 'svg' || node.nodeName === 'SPAN' || node.nodeName === '#text' || node.nodeName === '#comment' || node.nodeName === 'yt-icon-shape' || node.nodeName === 'DOM-IF' || node.nodeName === 'DOM-REPEAT') {
return
}
var children = node.children;
this.ytElementsHandler(node);

if (children) {
for (var i = 0, l = children.length; i < l; i++) {
ImprovedTube.childHandler(children[i]);
}
}
}

/*
const DOM_filter = /^(SCRIPT|DOM-IF|DOM-REPEAT|svg|SPAN|#text|#comment|yt-icon-shape|iron-iconset-svg)$/;
ImprovedTube.childHandler = function (node) { //console.log(node.nodeName);
if (DOM_filter.test(node.nodeName)) { return; }
ImprovedTube.ytElementsHandler(node);
var children = node.children;
ImprovedTube.ytElementsHandler(node);
if (children) {
let i = 0;
for (const child of children) {
ImprovedTube.childHandler(children[i]);
//console.log("node.nodeName:CHILD-"+i+":"+children[i].id+",class:"+children[i].className+","+children[i]+"("+children[i].nodeName+")");
i++;
}
}
};
}
}; */

ImprovedTube.ytElementsHandler = function (node) {
var name = node.nodeName,
Expand Down
46 changes: 37 additions & 9 deletions js&css/web-accessible/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,35 @@
ImprovedTube.messages.create();
ImprovedTube.messages.listener();
if (document.body) { ImprovedTube.childHandler(document.body);}
//console.log("--- p FOR PARENT, c FOR CHILD, r FOR REMOVED :");

ImprovedTube.observer = new MutationObserver(function (mutationList) {

for (var i = 0, l = mutationList.length; i < l; i++) {
var mutation = mutationList[i];

if (mutation.type === 'childList') {
for (var j = 0, k = mutation.addedNodes.length; j < k; j++) {



ImprovedTube.childHandler(mutation.addedNodes[j]);
}

for (const node of mutation.removedNodes){
if(node.nodeName === 'BUTTON' && node.id === 'it-popup-playlist-button') ImprovedTube.playlistPopupUpdate();
}
}
if (mutation.target && mutation.target.id === 'owner-sub-count') {
// Extract and store the subscriber count
ImprovedTube.extractSubscriberCount();
}

}

/*
//console.log("--- p FOR PARENT, c FOR CHILD, r FOR REMOVED :");
let i = 0; for (const mutated of mutationList) {
if (mutated.type === 'childList') {
// if (/^(SCRIPT|DOM-IF|DOM-REPEAT|svg|SPAN|yt-icon-shape)$/.test(mutated.target.nodeName)) {i++; continue; }
// ImprovedTube.ytElementsHandler(mutated.target);
Expand All @@ -22,14 +48,16 @@ ImprovedTube.observer = new MutationObserver(function (mutationList) {
if(mutated.target.id === 'owner-sub-count')
{if (ImprovedTube.storage.ads === 'small_creators')
{ImprovedTube.extractSubscriberCount(mutated.target);}}
}
/* if (mutated.type === 'characterData') { if (/#COMMENT/.test(mutated.target.nodeName)) {i++; continue; }; ImprovedTube.ytElementsHandler(mutated.target);
console.log("changed characterData:"+mutated.target.nodeValue+"("+mutated.target.id+",class:"+mutated.target.className+","+mutated.target+"("+mutated.target.nodeName+")");
} if (mutated.type === 'attributes') {if (/^(caption-window-|ytp-progress-bar$|ytp-[a-z]*-progress$)/.test(mutated.target.nodeName)) return; ImprovedTube.ytElementsHandler(mutated.target);
console.log("mutated attribute:"+mutated.attributeName+"("+mutated.target.id+",class:"+mutated.target.className+","+mutated.target+"("+mutated.target.nodeName+"))");
} */

i++;}
}
// if (mutated.type === 'characterData') { if (/#COMMENT/.test(mutated.target.nodeName)) {i++; continue; }; ImprovedTube.ytElementsHandler(mutated.target);
//console.log("changed characterData:"+mutated.target.nodeValue+"("+mutated.target.id+",class:"+mutated.target.className+","+mutated.target+"("+mutated.target.nodeName+")");
// } if (mutated.type === 'attributes') {if (/^(caption-window-|ytp-progress-bar$|ytp-[a-z]*-progress$)/.test(mutated.target.nodeName)) return; ImprovedTube.ytElementsHandler(mutated.target);
//console.log("mutated attribute:"+mutated.attributeName+"("+mutated.target.id+",class:"+mutated.target.className+","+mutated.target+"("+mutated.target.nodeName+"))");
}
i++;}
*/


}).observe(document.documentElement, {
// attributes: true,
// attributeOldValue: true,
Expand Down

0 comments on commit a36e575

Please sign in to comment.