JS A Method To Set Cookie Then Load Page

情到浓时终转凉″ 提交于 2019-12-01 14:12:32

Below is a try to explain rather than an answer.

Let's assume that you are already at the target page. Do the following bookmarklets work for you? This:

javascript:(function() {
    document.getElementById('Dark').click();
})();

or this one:

javascript:(function() {
    document.cookie='theme=dark; domain=.example.org; path=/';
    window.location.reload(true);
})();

I eventually figured out a cookie's initial entry can only be set by the domain, as a measure against XSS. So the answer to my question is it's not possible.

The simplest work around is to use an Add-On followed by userContent.css.

It would of been nice to set the theme preference (cookie) before loading the page - but I can see why the rule's in place..

It takes the same amount of clicks to go to the site and click "Change To Dark Theme" as it would if JS was used (open the site [1st click], set the cookie and reload [2nd click]).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!