5 ms·
Awesome! I was creating a style element and added it to the head. The CSP do not allow that. Now that I know I can alter the elements directly, I will do that
by wunderwaffe 8y ago
Awesome! I was creating a style element and added it to the head. The CSP do not allow that.
Now that I know I can alter the elements directly, I will do that instead.
Hacker News - I'm back!
- mike-cardwell 8y agoUsing a style element should have worked too. The HN CSP policy has unsafe-inline which covers both of these things. Perhaps your problem wasn't with CSP at all, but something else. Maybe a CSS specificity issue? [edit] - Yeah, I just created this bookmarklet and it worked fine: javascript:(function(){s=document.createElement('style');s.textContent='*{font-size:20px}';document.head.appendChild(s)})()
- wunderwaffe 8y agoEven better! My solution was a link element with a data: URI. Yours is much more elegant. And works! Thank you very much!
- mike-cardwell 8y agoThat would be the problem. The HN policy for styles is: style-src 'self' 'unsafe-inline' This means they can include CSS from the same origin, or inline. It would need "data:" adding to the list to allow data URI's as an accepted source.