0
我想借用http://readable.tastefulwords.com/的JavaScript。簡單的JavaScript執行Chrome擴展
而不是使它成爲一個書籤,我想把腳本變成一個擴展名。我不知道很多Java,只是足以執行某些事情。我認爲這很容易,只需借用一個教程Chrome擴展模板並將腳本放在某處即可。那麼,大約3個小時的研究和測試,我卡住了。我可以使用其他簡單的腳本運行,除了那個站點的腳本。
我做了一些摸索,我甚至從這個職位(該帖子最後的答案)中使用的腳本設計:Run javascript with click on popup.html icon in Chrome extension
我設法建立prompt.js,代碼如下所示:
function promptBox()
{
_readableOptions=
{
'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':'18px','text_line_height':'1.5','box_width':'30em','color_text':'#282828','color_background':'#F5F5F5','color_links':'#0000FF','text_align':'normal','base':'blueprint','custom_css':''
};
if(document.getElementsByTagName('body').length>0);
else
{
return;
}
if(window.$readable)
{
if(window.$readable.bookmarkletTimer)
{
return;
}
}
else
{
window.$readable={};
}
window.$readable.bookmarkletTimer=true;
window.$readable.options=_readableOptions;
if(window.$readable.bookmarkletClicked)
{
window.$readable.bookmarkletClicked();
return;
}
_readableScript=document.createElement('script');
_readableScript.setAttribute
(
'src','http://readable-static.tastefulwords.com/target.js?rand='+encodeURIComponent(Math.random())
);
document.getElementsByTagName('body')[0].appendChild(_readableScript);
}
chrome.extension.onClicked.addListener(promptBox());
我只是需要最後一個腳本來工作,我相信它可以使我想閱讀的文章「可讀」。
你的問題到底是什麼?你有錯誤嗎?如果是這樣,請在這裏複製錯誤消息,以便其他人可以看到發生了什麼。另外,您可能希望編輯您的問題以獨佔方式引用JavaScript,而不是Java--這兩種語言無關。 – sowbug 2013-04-23 16:28:26