Wikipedia - Keep style preferences in incognito

Immediately apply the user's style preferences in incognito sessions, for a seamless experience, without needing to manually set them every time.

目前為 2025-02-04 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

作者
jackiechan285
評價
0 0 0
版本
2025-02-04.2
建立日期
2025-02-04
更新日期
2025-02-04
尺寸
3.7 KB
授權條款
未知
腳本執行於

When you open Wikipedia in incognito, you have to manually set the styles to your preferences all over again, which may be annoying if done multiple times.

This script does it automatically, instantly, at first run, with no reload required.

It directly changes the cookie responsible for the style preferences and changes the style preference classes to apply them immediately because the changes to the cookie only take effect after reloading.

The cookies are necessary because the class changes alone do not get saved.

This is done only once per session, so it won't affect performance or be redundant. It also allows the user to change the preferences further on, and they won't be overwritten.

It sets a flag on localStorage to indicate the cookie has already been overwritten, to ensure it's only done once per session.

.

To-do

Currently, it defaults to dark theme, wide view, and small font. This can be changed by the numbers in the preference flags, both for cookies and classes.

In the future, I plan to make the preferences more clearly customizable in the script.

I also plan to implement syncing with user preferences outside of incognito mode, and make it possible to sync the modifications to the preferences made in the website's interface by saving them to the script's local storage.

.

Why Wikipedia in incognito?

I personally use incognito every time I want to search for random topics, and I don't want these polluting my history with one-off interests.

So, I always encounter the Wikipedia style preferences issue, and I found a quick solution, which can also be useful to anyone with the same issue.

As silly as this script might be, it's a fun way for me to train my coding and prompting skills, express my creativity, and get to publish somewhat useful stuff.

I also think publishing useless niche user scripts is a type of art, and I like the concept that anything we publish on the internet stays forever. We should want to make simple things that mean something to ourselves. This is good because it's a very refined implementation of a solid idea, even in the most niche applications. That's the fun of it.