Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- tell application "Safari"
- '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();n sel.collapse(document.body, 0);//------ To start at the beginning of the document, not after the selectioned textn while (window.find('" & thisText & "', true)) {document.execCommand('HiliteColor', false, '#5cdf64');}n sel.collapseToEnd()" in document 1
- end repeat
- -- restore the scroll position
- do JavaScript "document.designMode = 'off'; window.scrollTo(" & (item 1 of scrollPos) & ", " & (item 2 of scrollPos) & ")" in document 1
- end tell
- repeat with thisText in myList
- execute javascript "var sel = window.getSelection();n sel.collapse(document.body, 0);//------ To start at the beginning of the document, not after the selectioned textn while (window.find('" & thisText & "', true)) {document.execCommand('HiliteColor', false, '#5cdf64');}n sel.collapseToEnd()"
- end repeat
- execute javascript "document.designMode = 'off'; window.scrollTo(" & (item 1 of scrollPos) & ", " & (item 2 of scrollPos) & ")"
- tell application "Google Chrome"
- execute tab 3 of window 1 javascript "document.designMode = 'on'; [window.pageXOffset.toString(),window.pageYOffset.toString()]"
- --> {"0", "0"}
- execute current application javascript "var sel = window.getSelection();n sel.collapse(document.body, 0);//------ To start at the beginning of the document, not after the selectioned textn while (window.find('AppleScript', true)) {document.execCommand('HiliteColor', false, '#5cdf64');}n sel.collapseToEnd()"
- --> missing value
- execute current application javascript "var sel = window.getSelection();n sel.collapse(document.body, 0);//------ To start at the beginning of the document, not after the selectioned textn while (window.find('2018', true)) {document.execCommand('HiliteColor', false, '#5cdf64');}n sel.collapseToEnd()"
- --> missing value
- execute current application javascript "var sel = window.getSelection();n sel.collapse(document.body, 0);//------ To start at the beginning of the document, not after the selectioned textn while (window.find('CLOSED', true)) {document.execCommand('HiliteColor', false, '#5cdf64');}n sel.collapseToEnd()"
- --> missing value
- execute current application javascript "document.designMode = 'off'; window.scrollTo(0, 0)"
- --> missing value
- end tell
- Result:
- missing value
Add Comment
Please, Sign In to add comment