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

< Rückmeldungen auf Replace Text On Webpages

Frage/Kommentar

§
Veröffentlicht: 03.02.2016

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?

§
Veröffentlicht: 24.02.2016

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");

Antwort schreiben

Anmelden um eine Antwort zu senden.