Greasy Fork is available in English.

Replace Text On Webpages

Replaces text on websites. Now supports wildcards in search queries. Won't replace text in certain tags like links and code blocks

< Feedback on Replace Text On Webpages

Question/comment

§
Posted: 2016-02-03

Replace text with formatted text?

I modified this script to only run on archiveofourown.org so I could use these replacements:

    '/' : '<b>/</b>',
    '|' : '<span style="color:#ccc;">|</span>',

But it didn't work as expected; it showed the code inline instead of making the / bold and the | light grey. I wanted to do this to make pairing tags on Ao3 more easy to parse. Is there any way I make this thing happen?

§
Posted: 2016-02-24

Hello phidari, I came here by chance and stumbled across your very tricky request.

It's not possible to inject literal html-code into a page as the control characters (like <>) will alway be converted to it's desciptive character-form (e.g.: < will become <). And characters like / and | are even more delicate to handle.

You need a script that creates valid html-elements into which your replace-text get's inserted. This local script can't achive it and you'd need one that can style single words like highlighter-scripts.

I have found one: Highlight BadWords ... and could alter the top sequence to fit your special needs.
If you give it a try please exchange the according script-part by the below one.

good success ~ Vivre :smile:

    //	Colors for the word lists
    addGlobalStyle('span.bad1 { font-weight: bold;  background-color: red; } ' +
		   'span.bad2 { color:#cccccc;  background-color: green; } ' +
		   'span.bad3 { background-color: #FFE681; } ');

    //	Very bad words = bad1
    defwords([
		"\/",
	     ],
	"bad1");

    //	kind of bad words = bad2
    defwords([
		"\\|",
	     ],
	"bad2");

    //	not really bad words = bad3
    defwords([
		"to",
	     ],
	"bad3");

Post reply

Sign in to post a reply.