我已经开始学习 Applescript - 并且不知道 JavaScript - 并且在让此代码工作时遇到问题。
我试图在 Safari 中打开一个网页,一旦页面完成加载,就对其执行一些 javascript。
javascript 是从书签中复制的——当我使用书签按钮时,javascript 会按预期工作。但是,在运行我的 Applescript 时,它会返回“缺失值”错误,并且对网页没有任何作用。
这是Applescript:
set makeReadable to "javascript:(function()%7B_readableOptions=%7B'text_font':'quote(Palatino Linotype), Palatino, quote(Book Antigua), Georgia, serif','text_font_monospace':'quote(Courier New), Courier, monospace','text_font_header':'quote(Times New Roman), Times, serif','text_size':'14px','text_line_height':'1.5','box_width':'30em','color_text':'%23282828','color_background':'%23F5F5F5','color_links':'%230000FF','text_align':'normal','base':'blueprint','custom_css':''%7D;if(document.getElementsByTagName('body').length>0);else%7Breturn;%7Dif(window.$readable)%7Bif(window.$readable.bookmarkletTimer)%7Breturn;%7D%7Delse%7Bwindow.$readable=%7B%7D;%7Dwindow.$readable.bookmarkletTimer=true;window.$readable.options=_readableOptions;if(window.$readable.bookmarkletClicked)%7Bwindow.$readable.bookmarkletClicked();return;%7D_readableScript=document.createElement('script');_readableScript.setAttribute('src','http://readable-static.tastefulwords.com/target.js?rand='+encodeURIComponent(Math.random()));document.getElementsByTagName('body')%5B0%5D.appendChild(_readableScript);%7D)();"
tell application "Safari"
set theURL to "http://en.wikipedia.org/wiki/Rocky"
open location theURL
delay 20
set SelectedPage to document of window 1
do JavaScript makeReadable in SelectedPage
delay 15
end tell
非常感谢任何帮助!