For example, this bookmarklet
It works when I click it from the bookmark bar.
But when I use the b, variable is still undefined.
Stange (and minor), but our implementation should agree with Chrome's. Thanks for filing it!
Hmm, I think I know the reason why... Coffeescript automatically compiles everything in strict mode, and strict mode ensures that variables created in eval() do not escape into the surrounding scope.
Apparently the instapaper bookmarklet does not work via the "b" dialog anymore, and I suspect this might be related. If not we should file it as a separate issue, since that's a major bookmarklet that people use.
The reason variables don't bleed into the page scope is the js sandbox Chrome provides for extension content scripts. It's unrelated to coffeescript.
To match chrome's behavior of scoping bookmarklet variables to the page, we have two options:
FWIW, instapaper seems to work for me now. I think doing eval fixed it, actually. Unless we can find a specific bookmarklet that is failing because of this behavior, I don't think we need to fix it.
Yep, I followed up on that instapaper bug report and the bookmarklet works for me as well, he was mistaken.
Nah I don't think he was mistaken -- it wasn't working till we started using eval in our last release.
Inject bookmarklets by appending them as scripts.
This *should* fix the permission problems that `eval` faced.
Closes #575, #710.