Skip to content

Commit

Permalink
Update transform-general.js
Browse files Browse the repository at this point in the history
  • Loading branch information
hardik-pratap-singh committed Jul 19, 2024
1 parent 1c22a94 commit 10f8776
Showing 1 changed file with 7 additions and 16 deletions.
23 changes: 7 additions & 16 deletions browser-extension/plugin/src/transform-general.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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

Expand All @@ -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 = {};

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 10f8776

Please sign in to comment.