http://readable.tastefulwords.com/에서 자바 스크립트를 빌려는 중입니다.Chrome 확장 프로그램에 대한 간단한 자바 스크립트 실행
북마크릿으로 만드는 대신 스크립트를 확장 프로그램으로 바꾸고 싶습니다. 나는 많은 것을 알지 못한다. 단지 어떤 것을 실행하기에 충분하다. 간단 할 것입니다. 튜토리얼 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를 독점적으로 참조하도록 질문을 편집 할 수도 있습니다. 두 언어는 서로 관련이 없습니다. – sowbug