javascriptublock-origin

Ublock Origin replace-node-text


I'm on a website with an overly sensitive profanity filter that sticks periods in the middle of words like doc.u.ments or as.sas.sin. There is no option to turn off the profanity filter. I wanted to use something like Ublock Origin to remove the periods in the middle of words. I am not sure what the best approach is.

I tried this first: ##+js(replace-node-text, #text, ".", "")

Which cleaned up the periods in the middle of words, but it also removed all of the regular end of sentence periods as well.

So then I tried this: ##+js(replace-node-text, #text, /[.][a-z]+/, "")

but this just turned doc.u.ments into: doc.ments, not what I wanted. I was wondering if anyone had any ideas.


Solution

  • Maybe you could make the regular expression global and also use capture groups and put them back in

    ##+js(replace-node-text, #text, /[.]([a-z]+)/g, "$1")