From 6745b375a02c36aa0696478e78fa8d74ef38a471 Mon Sep 17 00:00:00 2001 From: Michael Campagnaro Date: Wed, 15 Feb 2023 15:50:14 -0500 Subject: [PATCH] Speed things up --- README.md | 25 ++- build/Firefox_youtube_herp_derp-1.0.4.2.xpi | Bin 0 -> 16664 bytes index.js | 171 +++++++++++--------- manifest.json | 11 +- 4 files changed, 116 insertions(+), 91 deletions(-) create mode 100644 build/Firefox_youtube_herp_derp-1.0.4.2.xpi diff --git a/README.md b/README.md index 8ec342a..c5325e4 100644 --- a/README.md +++ b/README.md @@ -13,11 +13,11 @@ Note: Ignores iframe embedded videos, including the chat replay iframe on YouTub **Firefox** * I have a signed xpi that you can immediately install. Open `build/` and drag the xpi into Firefox. It may take a few seconds for the browser to display the extension installation dialog box. -* You can also find the signed Firefox files in the project's [Releases page](https://github.com/sir-pinecone/youtube-herp-derp-browser-extension/releases). +* You can also find the signed Firefox files in the project's [Releases page](https://git.michael.is/michael/youtube-herp-derp-browser-extension/releases). **Chrome** * Go to Chrome extensions page. -* Toggle the developer mode (top-right of page). +* Toggle the developer mode (top-right of page). * Click `Load unpacked`. * Select this project's root folder. @@ -31,10 +31,19 @@ Note: Ignores iframe embedded videos, including the chat replay iframe on YouTub ## Signing and Building ### Firefox -* Install web-ext with `$ npm install --global web-ext` -* Generate an unlisted xpi with: - `web-ext sign --api-key --api-secret ` - * You can obtain these keys from https://addons.mozilla.org/en-US/developers/addon/api/key/ -* The signed xpi will be in `web-ext-artifacts/`. Drag this into Firefox to install it. -* Alternatively use the private sign-firefox-extension.sh script (not included in the repo) which places the xpi in `build/`. + +* Can either sign and upload from the CLI or manually upload. The former is easy but it triggers a human review? + +* CLI Upload + * Install web-ext with `$ npm install --global web-ext` + * Generate an unlisted xpi with: + `web-ext sign --api-key --api-secret ` + * You can obtain these keys from https://addons.mozilla.org/en-US/developers/addon/api/key/ + * The signed xpi will be in `web-ext-artifacts/`. Drag this into Firefox to install it. + * Alternatively use the private sign-firefox-extension.sh script (not included in the repo) which places the xpi in `build/`. + +* Manual Upload + * Go to https://addons.mozilla.org/en-US/developers, open the extension and then click on `Upload new version`. + * Pack the manifest, js script and icons directory into a zip and upload this file. + * To download the signed xpi, click on `view all` (versions), then the name of the new version, then the xpi filename. diff --git a/build/Firefox_youtube_herp_derp-1.0.4.2.xpi b/build/Firefox_youtube_herp_derp-1.0.4.2.xpi new file mode 100644 index 0000000000000000000000000000000000000000..6e25535fbdca06d226d6297d0a8b8e214474ff26 GIT binary patch literal 16664 zcmajG1C%Yxwk=xLD%-ZP%C>FWwryLhY}>YNTdTCn)~o%_yYK9?|GW2(Y|*mioO49W zoFg(~jNYTmNdki)13-Kq|Fpk8F}E=?cB8d$Y*e+DrRqTVj2ZMzOH@gf#$wrP%*ow2 zgDQ=1@~7fUt}d5YQI}QAIan>@mQ2Whf3mpnz6t4NS8#q3Tx~MNjWx}7&ubh;;({Q$ zyd8!|u0_To|AcA@DEG>%a#nY9<|oD)z*95u0$iYYKey_~`{Lo@;ECW<{jCyvnB*P; z#29^?PD#FdXEm8tGa?EAaGGA(n}5o~iwOyh+-1C$GlDi?9ooHYbz_!vQ3`4V76D{( zfE=5nqhBqYOnLdLx`^u;*8s<7bh+v3@AU~#DA4js8^`NyH1>uMTjo+6Z!P39wPSK6 zdNRnO%hoZeLlAO-UB7)}Zw~EiWP3p>UHN)#d|>}MM41?^H^^Y{d{A(T{MlD$yuk$l zT%=7qCzq{o#8}M$`0J9B${r{v zY7i@XkZ5kl2xiv6A-u9R8R)50MD~t7qlmz~D4?0J74uF|tfcF!YJ*o`D_IpMqoC@Q zDrUqI@IM4rLg&C8q`>@iEo84R2CqGbns6j?Ib3dNulBTlpGQr$YPlf z4R{S%4~9Gp#nBogia|(z@;S;?sB-$DZjhyG}8PMdGi{xpwgPRB2Yf$1a(Wn>dttB2lxks1g_Jode+kX>}m$extS@KRCfXWIki z9bdpaNll|8A9?O>N}J8bpf#J+>sId++rGAqPhzq+<7*r7yw(if z6P_gsMg=ru3x7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qiAQ({N>tMm{NvhNL_fA!F$F5QUNF_P zws%*nF02#VU)Xt9cErGz%nXD+Jx|lF^^3=YtsX9BlC2a^0usl7VSj!Tloqm99z&@{-?>3LN9qX8?xo}wN^GTK3lG&_%mq>`Yw zd+(+R{_WN|z2)O%2078rUi!#n>fsc^+PqH<3oNNne3&jbTDgukgQdWej-9_n@RijV zo897N?-1(`U76zLCF*s!pHCUsQ=DG2L`Wr`8Dt1P_&zHXp?wC5m;M7L`MV6b*nG^~ z=qlSCz)9DLSXQCG!=!IN0`h({<9=KQs zE{naiD&|^?f_&!Q*Gp8X$$MAE2#MSp)cSkrigbjiv3vv@P^6*w<mCMr*_(KX_bI5n3=DpSW7jqu9F%v3*!qjQ%kPvN~!1>1GV$|o}O_n=u z{DCA`&{}`12h)&7_E!6q;Lw6>5qNTR1uUERh(lB-qv6A_^kPsR_D(Xeo!wQ zn{kN63?|^mRP}=DGDm&2-lULAZCImyLk~PmbwbT=?oiNv#Z;=I88u7JdbA1=OGnip zaRWWtK49)?0<>V>H8wW6}Naw9tMR$g$jE?~1ds+?#J zdIS_~bLp>9W?lc-v+ORsNr})w*h$2}l6!HwuvlObjIp2J8OLS8p0D$eCcqNmzSlN? zA4=H z;M~nXa1ULVch&Fm?Oz35$Hl^W?6>X^^nVKz0fCSK{;g*JyJ+$Mt8f1=ZM&T0e|r60 zA@`S{@!!S-_78dEKVAR6o#rnI-M{S}{Qn`S`=|TgDb>IB-2B_1u>bDNUQQD9JFWl#klzQ(H!C{H^Vik? E0w Math.floor(Math.random() * max); +const RandomInt = max => Math.floor(Math.random() * max); // [1, max] const DerpString = (length = 20) => { - const RandomDerp = () => { - let n = RandomInt(4); - let result = ""; - if (n == 0) - result = "blah"; - else if (n == 1) - result = "durr"; - else if (n == 2) - result = "herp"; - else if (n == 3) - result = "derp"; - return result; - }; - return Array.from({ length: (RandomInt(length) + 1) }, () => RandomDerp()).join(" "); + const RandomDerp = () => { + let n = RandomInt(4); + let result = ""; + if (n == 0) { + result = "blah"; + } + else if (n == 1) { + result = "durr"; + } + else if (n == 2) { + result = "herp"; + } + else if (n == 3) { + result = "derp"; + } + return result; + }; + return Array.from({ length: (RandomInt(length) + 1) }, () => RandomDerp()).join(" "); }; -// Herp derps an element. -const DerpElement = element => { - const c = element; - c.derpOriginal = c.textContent; // Preserve the original contents. - c.onclick = () => { - c.clicked = !c.clicked; - c.textContent = c.clicked ? c.derpOriginal : c.derp_str; - }; - c.classList.add("derped"); - c.derp_str = DerpString(); - c.textContent = c.derp_str; - c.clicked = false; +// Herp derps an comment. +const DerpComment = (commentNode, textNode) => { + commentNode.isDerped = true; + const c = textNode; + c.derpOrig = c.textContent; // Preserve the original contents. + c.onclick = () => { + c.derpClicked = !c.derpClicked; + c.textContent = c.derpClicked ? c.derpOrig : c.derpStr; + }; + c.classList.add("isDerped"); + c.derpStr = DerpString(); + c.derpClicked = false; + c.textContent = c.derpStr; // Set the derp text. }; const ValidatePreviouslyDerpedComments = comment => { - const c = comment; - if (c.clicked && c.textContent === c.derpOriginal) return; - if (!c.clicked && c.textContent === c.derp_str) return; + const c = comment; + if (c.derpClicked && c.textContent === c.derpOrig) return; + if (!c.derpClicked && c.textContent === c.derpStr) return; - // Fix the comment. The only case of malformed comments encountered so far - // are these two cases: - if (c.textContent.indexOf(c.derp_str) !== -1) { - // In the case of the new comment being appended after the derp string, - // just grab it and put it in the derpOriginal variable - const idx = c.derp_str.length; - c.derpOriginal = c.textContent.substring(idx); - c.textContent = c.textContent.substring(0, idx); - c.clicked = false; - return; - } + // Fix the comment. The only case of malformed comments encountered so far + // are these two cases: + if (c.textContent.indexOf(c.derpStr) !== -1) { + // In the case of the new comment being appended after the derp string, + // just grab it and put it in the derpOrig variable + const idx = c.derpStr.length; + c.derpOrig = c.textContent.substring(idx); + c.textContent = c.textContent.substring(0, idx); + c.derpClicked = false; + return; + } - if (c.textContent.indexOf(c.derpOriginal) !== -1) { - // Same issue, but the comment was appended after derpOriginal. - const idx = c.derpOriginal.length; - c.derpOriginal = c.textContent.substring(idx); - c.textContent = c.derp_str; - c.clicked = false; - } + if (c.textContent.indexOf(c.derpOrig) !== -1) { + // Same issue, but the comment was appended after derpOrig. + const idx = c.derpOrig.length; + c.derpOrig = c.textContent.substring(idx); + c.textContent = c.derpStr; + c.derpClicked = false; + } }; const Init = commentsSection => { - const commentContentSelector = ["#content-text"]; // Comment text content. + const commentTextId = "#content-text"; + const derpedSelector = `${commentTextId}.isDerped`; + const commentRendererName = "YTD-COMMENT-RENDERER"; - const notDerpedSelector = commentContentSelector - .map(sel => `${sel}:not(.derped)`) - .join(", "); + // Need to convert comments that were inserted before the mutation observer below runs. + commentsSection.querySelectorAll(commentRendererName).forEach(node => { + DerpComment(node, node.querySelector(commentTextId)); + }); - const derpedSelector = commentContentSelector.map(sel => `${sel}.derped`).join(", "); + // Detect when comments are added to the DOM. + const observer = new MutationObserver(mutations => { + // Check that everything's fine with the already derped comments. + // This is necessary because youtube does a lot of wizardry with comments in-between videos. + document.querySelectorAll(derpedSelector).forEach(ValidatePreviouslyDerpedComments); - // Only watch for child list changes, as we're watching the comments - // container. - const mutationConfig = { attributes: false, childList: true, subtree: true }; + mutations.forEach((change, index) => { + console.assert(change.type === "childList"); + change.addedNodes.forEach(node => { + if (node.nodeName === commentRendererName) { + if (!node.isDerped) { + DerpComment(node, node.querySelector(commentTextId)); + } + } + }); + }); + }); - // Detect when comments are added to the DOM. - const observer = new MutationObserver(() => { - // Check that everything's fine with the already derped comments. - // This is necessary because youtube does a lot of wizardry with comments - // in-between videos. - document.querySelectorAll(derpedSelector).forEach(ValidatePreviouslyDerpedComments); - - // Derp all un-derped comments. - document.querySelectorAll(notDerpedSelector).forEach(DerpElement); - }); - - observer.observe(commentsSection, mutationConfig); + // Only watch for child list changes, as we're watching the comments container. + observer.observe(commentsSection, { attributes: false, childList: true, subtree: true }); }; // Check every so often if comments are loaded or not. Once they are, the @@ -90,18 +99,20 @@ const Init = commentsSection => { // to be done since comments are added in the DOM through js at an undetermined // point through Youtube's execution. const CheckIfCommentsLoaded = () => { - const commentSectionSelector = "html body ytd-app ytd-comments ytd-item-section-renderer #contents"; + setTimeout(() => { + const commentsSection = document.querySelector("ytd-comments #contents"); - setTimeout(() => { - // This selector is awful, but Youtube re-uses a lot of the DOM (the - // selector for the comments is re-used across a bunch of pages) so we need - // the exact path to the comments to match - const commentsSection = document.querySelector(commentSectionSelector); - if (commentsSection !== null) - Init(commentsSection); - else - CheckIfCommentsLoaded(); - }, 500); + if (commentsSection !== null) { + Init(commentsSection); + } + else { + CheckIfCommentsLoaded(); + } + // If the timeout is <= 1000 then Chrome sometimes fails to run the mutation observer. + // It'll create it and active it, but it doesn't run the callback on DOM changes... + // I'm seeing this in Chrome 110. + }, 2000); }; CheckIfCommentsLoaded(); + diff --git a/manifest.json b/manifest.json index 64b23ef..0276015 100644 --- a/manifest.json +++ b/manifest.json @@ -1,13 +1,18 @@ { - "manifest_version": 2, + "manifest_version": 3, "name": "YouTube Herp Derp", "description": "Replaces YouTube comments with herp derps. Forked from github.com/twstokes/herpderp", - "homepage_url": "https://github.com/sir-pinecone/youtube-herp-derp-browser-extension", - "version": "1.0.3", + "homepage_url": "https://git.michael.is/michael/youtube-herp-derp-browser-extension", + "version": "1.0.4.2", "icons": { "48": "icons/herp48.png", "128": "icons/herp128.png" }, + "browser_specific_settings": { + "gecko": { + "id": "{8460883e-a350-4e55-8c07-eed5eefdc2b5}" + } + }, "content_scripts": [ { "run_at": "document_idle",