corollari / ankiTab

Browser extension that replaces the new tab page with Anki flashcards
https://ankitab.com
The Unlicense
187 stars 16 forks source link

Great addon but doesn't run javascript #14

Closed SRGOM closed 5 years ago

SRGOM commented 5 years ago

In case you didn't know already, custom JS isn't run.

RickCarlino commented 5 years ago

@SRGOM What do you see in your JS console when you open a card that uses Javascript?

corollari commented 5 years ago

This is a known issue, it is caused by the CSP imposed by chrome on extensions, which disables the execution of javascript code which is not in an static file (when card content is loaded all js inside the html is evaluated)[0]. I looked at ways to solve it back when I was writing the extension and the way to solve is by running the scripts in a sandbox[1]. I didn't implement it cause it takes a lot of work and that work would be better spent creating a web version of anki and embedding that into ankiTab.

[0] https://developer.chrome.com/extensions/contentSecurityPolicy [1] https://developer.chrome.com/extensions/sandboxingEval

SRGOM commented 5 years ago

@RickCarlino here is the JS console output after I hit 'show answer' (where JS should come in):

09:14:40.222 Source map error: TypeError: NetworkError when attempting to fetch resource.
Resource URL: moz-extension://eca23583-7e62-4dac-ad3f-383d38e3658b/libs/bootstrap.css
Source Map URL: bootstrap.css.map[Learn More]
09:14:52.879 Error in parsing value for ‘-webkit-text-size-adjust’.  Declaration dropped. bootstrap.css:12:29
09:14:52.880 Unknown property ‘orphans’.  Declaration dropped. bootstrap.css:292:13
09:14:52.880 Unknown property ‘widows’.  Declaration dropped. bootstrap.css:293:12
09:14:52.880 Unrecognized at-rule or error parsing at-rule ‘@-ms-viewport’. bootstrap.css:330:14
09:14:52.880 Error in parsing value for ‘outline’.  Declaration dropped. bootstrap.css:479:20
09:14:52.881 Error in parsing value for ‘display’.  Declaration dropped. bootstrap.css:860:12
09:14:52.882 Unknown pseudo-class or pseudo-element ‘-ms-expand’.  Ruleset ignored due to bad selector. bootstrap.css:2263:15
09:14:52.882 Unknown pseudo-class or pseudo-element ‘-ms-input-placeholder’.  Ruleset ignored due to bad selector. bootstrap.css:2285:15
09:14:52.883 Unknown pseudo-class or pseudo-element ‘-ms-value’.  Ruleset ignored due to bad selector. bootstrap.css:2308:27
09:14:52.883 Error in parsing value for ‘display’.  Declaration dropped. bootstrap.css:2520:12
09:14:52.883 Error in parsing value for ‘display’.  Declaration dropped. bootstrap.css:2539:14
09:14:52.883 Error in parsing value for ‘display’.  Declaration dropped. bootstrap.css:2554:14
09:14:52.883 Error in parsing value for ‘display’.  Declaration dropped. bootstrap.css:2587:14
09:14:52.883 Error in parsing value for ‘display’.  Declaration dropped. bootstrap.css:2613:14
09:14:52.883 Unknown property ‘user-select’.  Declaration dropped. bootstrap.css:2646:23
09:14:52.884 Error in parsing value for ‘display’.  Declaration dropped. bootstrap.css:3267:12
09:14:52.884 Error in parsing value for ‘display’.  Declaration dropped. bootstrap.css:3307:12
09:14:52.884 Error in parsing value for ‘display’.  Declaration dropped. bootstrap.css:3384:12
09:14:52.884 Error in parsing value for ‘display’.  Declaration dropped. bootstrap.css:3456:12
09:14:52.884 Error in parsing value for ‘display’.  Declaration dropped. bootstrap.css:3481:12
09:14:52.884 Error in parsing value for ‘display’.  Declaration dropped. bootstrap.css:3614:12
09:14:52.884 Unknown property ‘user-select’.  Declaration dropped. bootstrap.css:3664:23
09:14:52.885 Error in parsing value for ‘display’.  Declaration dropped. bootstrap.css:3696:12
09:14:52.885 Unknown pseudo-class or pseudo-element ‘-ms-value’.  Ruleset ignored due to bad selector. bootstrap.css:3735:22
09:14:52.885 Unknown pseudo-class or pseudo-element ‘-ms-expand’.  Ruleset ignored due to bad selector. bootstrap.css:3746:16
09:14:52.885 Expected ‘none’, URL, or filter function but found ‘alpha(’.  Error in parsing value for ‘filter’.  Declaration dropped. bootstrap.css:3770:11
09:14:52.885 Unknown property ‘user-select’.  Declaration dropped. bootstrap.css:3788:23
09:14:52.885 Error in parsing value for ‘display’.  Declaration dropped. bootstrap.css:3821:12
09:14:52.885 Error in parsing value for ‘display’.  Declaration dropped. bootstrap.css:3918:12
09:14:52.885 Error in parsing value for ‘display’.  Declaration dropped. bootstrap.css:3945:12
09:14:52.885 Error in parsing value for ‘display’.  Declaration dropped. bootstrap.css:4045:14
09:14:52.885 Error in parsing value for ‘display’.  Declaration dropped. bootstrap.css:4058:14
09:14:52.885 Error in parsing value for ‘display’.  Declaration dropped. bootstrap.css:4107:14
09:14:52.885 Error in parsing value for ‘display’.  Declaration dropped. bootstrap.css:4120:14
09:14:52.885 Error in parsing value for ‘display’.  Declaration dropped. bootstrap.css:4169:14
09:14:52.885 Error in parsing value for ‘display’.  Declaration dropped. bootstrap.css:4182:14
09:14:52.885 Error in parsing value for ‘display’.  Declaration dropped. bootstrap.css:4231:14
09:14:52.885 Error in parsing value for ‘display’.  Declaration dropped. bootstrap.css:4244:14
09:14:52.885 Error in parsing value for ‘display’.  Declaration dropped. bootstrap.css:4294:12
09:14:52.885 Error in parsing value for ‘display’.  Declaration dropped. bootstrap.css:4308:12
09:14:52.885 Error in parsing value for ‘display’.  Declaration dropped. bootstrap.css:4405:12
09:14:52.885 Error in parsing value for ‘display’.  Declaration dropped. bootstrap.css:4630:14
09:14:52.885 Error in parsing value for ‘display’.  Declaration dropped. bootstrap.css:4639:14
09:14:52.885 Error in parsing value for ‘display’.  Declaration dropped. bootstrap.css:4663:14
09:14:52.885 Error in parsing value for ‘display’.  Declaration dropped. bootstrap.css:4765:12
09:14:52.886 Unrecognized at-rule or error parsing at-rule ‘@-o-keyframes’. bootstrap.css:5039:14
09:14:52.886 Error in parsing value for ‘display’.  Declaration dropped. bootstrap.css:5060:12
09:14:52.886 Error in parsing value for ‘background-image’.  Declaration dropped. bootstrap.css:5078:21
09:14:52.886 Error in parsing value for ‘display’.  Declaration dropped. bootstrap.css:5093:12
09:14:52.886 Error in parsing value for ‘display’.  Declaration dropped. bootstrap.css:5111:12
09:14:52.886 Error in parsing value for ‘display’.  Declaration dropped. bootstrap.css:5147:12
09:14:52.886 Error in parsing value for ‘display’.  Declaration dropped. bootstrap.css:5454:12
09:14:52.886 Error in parsing value for ‘display’.  Declaration dropped. bootstrap.css:5490:12
09:14:52.886 Error in parsing value for ‘display’.  Declaration dropped. bootstrap.css:5521:12
09:14:52.886 Unknown property ‘line-break’.  Declaration dropped. bootstrap.css:5575:14
09:14:52.886 Unknown property ‘line-break’.  Declaration dropped. bootstrap.css:5679:14
09:14:52.887 Error in parsing value for ‘display’.  Declaration dropped. bootstrap.css:5880:12
09:14:52.887 Error in parsing value for ‘display’.  Declaration dropped. bootstrap.css:5933:12
09:14:52.887 Error in parsing value for ‘display’.  Declaration dropped. bootstrap.css:5992:12
09:14:52.887 Error in parsing value for ‘display’.  Declaration dropped. bootstrap.css:6216:12
09:14:52.887 Error in parsing value for ‘display’.  Declaration dropped. bootstrap.css:6223:12
09:14:52.887 Error in parsing value for ‘display’.  Declaration dropped. bootstrap.css:6249:14
09:14:52.887 Error in parsing value for ‘display’.  Declaration dropped. bootstrap.css:6255:14
09:14:52.887 Error in parsing value for ‘display’.  Declaration dropped. bootstrap.css:6282:14
09:14:52.887 Error in parsing value for ‘display’.  Declaration dropped. bootstrap.css:6288:14
09:14:52.887 Error in parsing value for ‘display’.  Declaration dropped. bootstrap.css:6315:14
09:14:52.887 Error in parsing value for ‘display’.  Declaration dropped. bootstrap.css:6321:14
09:14:52.887 Error in parsing value for ‘display’.  Declaration dropped. bootstrap.css:6348:14
09:14:52.887 Error in parsing value for ‘display’.  Declaration dropped. bootstrap.css:6354:14
09:14:52.888 Error in parsing value for ‘position’.  Declaration dropped. bootstrap.css:7395:13
09:14:52.894 Stylesheets without CSSOM changes reparsed to check for errors. Refresh the page to also see errors from stylesheets changed from CSSOM and from style attributes.

I am going to close this since I believe @corollari has answered both my question and @RickCarlino 's intended question but please feel free to re-open or comment if there is anything I can do to help.

Thank you both of you guys.

corollari commented 5 years ago

If anyone is willing to get this working with the sandboxing I'd happily merge it into ankiTab. @SRGOM sorry for taking so long to answer this issue, sometimes I don't notice github emails among all the others. If this happens again just ping me or send an email to me@albert.sh

SRGOM commented 5 years ago

@corollari Please don't worry about taking time- you're already being very helpful (by the way of your add-on). Your add-on is already 99% of the way there for me so all good...

corollari commented 5 years ago

@SRGOM Thanks! :smile: