Topic on Project:Support desk

How to apply a document.cookie theme globally?

5
Summary by Eduemoni

Used localStorage, which is better than document.cookie

Eduemoni (talkcontribs)

I have been trying to apply darkmode to the site, however it seems that when applied on action-view it is not reflected to action-edit pages. They seem to work on separate states, is there any way to apply a global cookie to the wiki?

Bawolff (talkcontribs)

you'll need to be more specific as to what precisely you are doing to add darkmode.

Eduemoni (talkcontribs)

in WikiMedia:Common.js I have this following script

document.cookie = 'theme=darkmode'

However, this cookie is only applied to non-editor pages.

When I go to &action=edit page and type document.cookie in the console the theme attribute is not present

Bawolff (talkcontribs)

you mean MediaWiki:Common.js ?

Cookies generally get saved for all pages once you set for one, until you close the browser. Are your edit pages somehow on a different domain? Check for javascript errors in developer console.

Eduemoni (talkcontribs)

I have circumvented the issue by using localStorage instead of document.cookie