0

I'm trying to borrow the JavaScript from http://readable.tastefulwords.com/.

Instead of making it a bookmarklet, I wanted to turn the script into an extension. I DO NOT know a lot of Java, only enough to execute certain things. I figure it'll be easy, just borrow a tutorial Chrome extension template and put the script in somewhere.

Well, about 3 hours of researching and testing, I'm stuck. I can get other simple scripts to run EXCEPT the one from that site.

I have done some searching around and I even used the script design from this one post (last answer on that post): Run javascript with click on popup.html icon in Chrome extension

I managed to set up the prompt.js, and the code looks like this:

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());

I just need that last script to work and I am sure it can make the article I want to read "readable".

1
  • What exactly is your question? Are you getting an error? If so, please copy the error message here so that others can see what's going on. Also, you might want to edit your question to refer to JavaScript exclusively rather than Java -- the two languages are unrelated. Commented Apr 23, 2013 at 16:28

1 Answer 1

0

Note that your if (document...) statement is guaranteed to do nothing, meaning the rest of the promptBox() function is dead code.

if (something)
  ;
else {
  return;
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.