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