Nazdar, mal by som jednu prosbu. Na internete som našiel tento userscript pre Greasemonkey, ktorý slúži na zmenu textu, napr. miesto lol napise lot of laughts a podobne. Funguje perfektne, ja by som však potreboval, aby na stránke zmenil len prvé slovo. napr. v clanku je 4x spomenuté slovo depresia a ja by som chcel aby to prvé slovo premenoval na depka a ostatné tri nechal napokoj. Dalo by sa to nejako urobiť? Toto je zdroják skriptu
// ==UserScript==
// @name Replace Text On Webpages
// @namespace http://userscripts.org/users/23652
// @description Replaces text on websites. Now supports wildcards in search queries
// @include http://*
// @include https://*
// @include file://*
// @exclude http://userscripts.org/scripts/review/*
// @copyright JoeSimmons
// ==/UserScript==
var words = {
///////////////////////////////////////////////////////
// Syntax: 'Search word' : 'Replace word',
'im*o' : 'in my opinion', // Will get imo and any characters between m and o
///////////////////////////////////////////////////////
'4.5' : '12','6' : '71'};
// This is where the real code is
// Don't edit below this
// Grab the text nodes
var this_text, text = document.evaluate("//text()[normalize-space(.)!='']",document,null,6,null);
for(var i=text.snapshotLength-1; i>=0; i--) {
// Create a shortcut for the text node
this_text = text.snapshotItem(i);
// Iterate the words array
for(word in words) {
// Turn the search term into a regular expression
// allowing wildcards (*) to be used for any character
var search_regexp = new RegExp(word.replace(/\*/g,'.*'), 'gi');
// Exclude the blank option at the bottom of the array words
// so every entry can have a comma after it for easy entry of blacklisted words
// And if the text node contains the blacklisted word
// And if the text isn't inside a link
if(word!='' && search_regexp.test (this_text.textContent) && this_text.parentNode.tagName!='A') {
// Replace the blacklisted word with the appropriate word
this_text.textContent = this_text.textContent.replace(search_regexp, words[word]);
}
}
}