'Run JavaScript' does not work on some sites
mail.google.com:
TypeError: Failed to set the 'textContent' property on 'Node': This document requires 'TrustedScript' assignment.
at HTMLDocument.<anonymous> (script-to-inject.js:1:111)
linkedin.com:
Refused to execute inline script because it violates the following Content Security Policy directive:
Same on mail.google.com
Duplicate of #599
Duplicate of #599
Too bad TrustedScript is not mentioned there.
This symptom has not been resolved in the latest version of Shortkeys, 4.1.3.
Currently it also occurs on youtube.com.
TrustedScript will not work without modifying the way the script is injected.
script-to-inject.js:1
Uncaught TypeError: Failed to set the 'textContent' property on 'Node': This document requires 'TrustedScript' assignment.
at HTMLDocument.<anonymous> (script-to-inject.js:1:111)
document.addEventListener("shortkeys_js_run", (function(e) {
let t = document.createElement("script");
t.textContent = e.detail,
document.body.appendChild(t),
document.body.removeChild(t)
}
));
@oniatsu Works on the latest commit.
@hababr Thank you! I haven't checked it works yet, but looking at the commit log, it seems to have been fixed in the latest commit.
However, I would install the latest version from the Chrome Web Store if possible. I don't know why the latest version of the merged commit from a month ago is not up on the Chrome Web Store.
The Web Store hasn't been updated yet because the PR that fixed it (thanks to @tjhorner) mentioned
Shortcuts with missing IDs will be added on next save. This means users will need to go to the config page at least once before their JS shortcuts will work.
I was hoping to fix that so that the upgrade itself would add missing IDs instead of forcing users to do a manual action, before updating the web store. I haven't been able to find time to mess with it, so if anyone wants to PR that, feel free!
Also @hababr you mentioned this:
@tjhorner Nice fix, thank you. After building a release for Chrome I had to fix service_worker.js, a function name was missing (registerHandlers).
Any chance you could PR that fix?
@crittermike Will do.
@crittermike Created - PR
Thanks @hababr! Really appreciate it. I'll ship a webstore release as soon as I'm able to do a bit more testing. In the meantime, if anyone else is available to take a swing at testing and report any issues you find, please have at it.
Upcoming release is posted here for anyone who has capacity to test before I publish to the webstore.
Upcoming release is posted here for anyone who has capacity to test before I publish to the webstore.
I can confirm that it fixed the issue in chrome
@crittermike When do you plan to publish it?
Oof, thanks for the nudge. Just submitted it for webstore review.