From 10f8776dc2cca6de883cfc0f7a776c76dfa6f20b Mon Sep 17 00:00:00 2001 From: Hardik Pratap Singh <97048877+hardik-pratap-singh@users.noreply.github.com> Date: Fri, 19 Jul 2024 08:02:47 +0100 Subject: [PATCH] Update transform-general.js --- .../plugin/src/transform-general.js | 23 ++++++------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/browser-extension/plugin/src/transform-general.js b/browser-extension/plugin/src/transform-general.js index 8a146221..9f8ac455 100644 --- a/browser-extension/plugin/src/transform-general.js +++ b/browser-extension/plugin/src/transform-general.js @@ -75,12 +75,8 @@ const processNewlyAddedNodesGeneral = function (firstBody) { // Code inserted below is for uliStore -let uliStore = [] -let body = document.querySelector("body"); -const targetWords = ['crazy', 'stupid', 'mad', 'insane']; // Replace with your list of target words - -/* indexTree()/getAllTextNodes() STARTS HERE */ +/* getAllTextNodes() STARTS HERE */ function checkFalseTextNode(text, actualLengthOfText) { let n = text.length; @@ -107,6 +103,7 @@ function checkFalseTextNode(text, actualLengthOfText) { function getAllTextNodes(node) { + let uliStore = [] if (node.nodeType === 3) { //If node.data contains just whitespaces and \n, then its a false text node @@ -123,21 +120,16 @@ function getAllTextNodes(node) { for (let i = 0; i < children.length; i++) { getAllTextNodes(children[i]); } -} - - -/* indexTree()/getAllTextNodes() ENDS HERE */ -// getAllTextNodes(body); - - + return uliStore ; +} +/* getAllTextNodes() ENDS HERE */ -/* locateSlur() STARTS HERE */ +/* locateSlur() STARTS HERE */ -// locateSlur(uliStore) function findPositions(word, text) { let positions = {}; @@ -178,14 +170,13 @@ function locateSlur(uliStore){ }) uliStore[i].slurs = slurs ; } + return uliStore ; //This will return the final uliStore (after appending slurs) } /* locateSlur() ENDS HERE */ -// console.log("uliStore" , uliStore) - export default { processNewlyAddedNodesGeneral