Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'Run JavaScript' does not work on some sites #621

Closed
hababr opened this issue May 8, 2024 · 11 comments
Closed

'Run JavaScript' does not work on some sites #621

hababr opened this issue May 8, 2024 · 11 comments

Comments

@hababr
Copy link
Contributor

hababr commented May 8, 2024

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:
@hababr hababr changed the title Does not work on some sites 'Run JavaScript' does not work on some sites May 8, 2024
@vtexperts
Copy link

vtexperts commented May 8, 2024

Same on mail.google.com

@tjhorner
Copy link
Contributor

tjhorner commented May 9, 2024

Duplicate of #599

@piotr-dobrogost
Copy link

Duplicate of #599

Too bad TrustedScript is not mentioned there.

@oniatsu
Copy link
Contributor

oniatsu commented Aug 8, 2024

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

@hababr
Copy link
Contributor Author

hababr commented Aug 10, 2024

@oniatsu Works on the latest commit.

@oniatsu
Copy link
Contributor

oniatsu commented Aug 10, 2024

@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.

@crittermike
Copy link
Owner

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?

@hababr
Copy link
Contributor Author

hababr commented Aug 14, 2024

@crittermike Will do.

@hababr
Copy link
Contributor Author

hababr commented Aug 14, 2024

@crittermike Created - PR

@crittermike
Copy link
Owner

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.

@crittermike
Copy link
Owner

Upcoming release is posted here for anyone who has capacity to test before I publish to the webstore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants