Guest User

Untitled

a guest
May 27th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.81 KB | None | 0 0
  1. tell application "Safari"
  2. 'window.find()' command change the scroll position when it select the founded string
  3. set scrollPos to do JavaScript "document.designMode = 'on'; [window.pageXOffset.toString(),window.pageYOffset.toString()]" in document 1
  4. repeat with thisText in myList
  5. 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
  6. end repeat
  7.  
  8. -- restore the scroll position
  9. do JavaScript "document.designMode = 'off'; window.scrollTo(" & (item 1 of scrollPos) & ", " & (item 2 of scrollPos) & ")" in document 1
  10. end tell
  11.  
  12. repeat with thisText in myList
  13. 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()"
  14. end repeat
  15. execute javascript "document.designMode = 'off'; window.scrollTo(" & (item 1 of scrollPos) & ", " & (item 2 of scrollPos) & ")"
  16.  
  17. tell application "Google Chrome"
  18. execute tab 3 of window 1 javascript "document.designMode = 'on'; [window.pageXOffset.toString(),window.pageYOffset.toString()]"
  19. --> {"0", "0"}
  20. 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()"
  21. --> missing value
  22. 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()"
  23. --> missing value
  24. 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()"
  25. --> missing value
  26. execute current application javascript "document.designMode = 'off'; window.scrollTo(0, 0)"
  27. --> missing value
  28. end tell
  29. Result:
  30. missing value
Add Comment
Please, Sign In to add comment