AppleScript & Javascript change text colour on safari
You can use the window.find('someString', false or true) command to search some string in the text of the document.

The second parameter of the command, if true, specifies a case-sensitive search.

Use the document.execCommand('HiliteColor', false, someColor) command to change the background color of the founded text.



Here's the sample script, tested on Sierra.

set myList to {"text1", "2018", "demo@apple.com"}

tell application "Safari"
    -- to change the color,  set the 'document.designMode' to on
    -- get the scroll position of the document, because the 'window.find()' command change the scroll position when it select the founded string
    set scrollPos to do JavaScript "document.designMode = 'on'; [window.pageXOffset.toString(),window.pageYOffset.toString()]" in document 1

    repeat with thisText in myList
        do JavaScript "var sel = window.getSelection();
                sel.collapse(document.body, 0);//------    To start at the beginning of the document, not after the selectioned text
                while (window.find('" &amp; thisText &amp; "', true)) {document.execCommand('HiliteColor', false, '#ff0000');}
                sel.collapseToEnd()" in document 1
    end repeat

    -- restore the scroll position
    do JavaScript "document.designMode = 'off';  window.scrollTo(" &amp; (item 1 of scrollPos) &amp; ", " &amp; (item 2 of scrollPos) &amp; ")" in document 1
end tell