Skip to content

Commit

Permalink
Update 1.3.8
Browse files Browse the repository at this point in the history
Added a theme reset when the user closes the browser while not logged in or while logged in without remember me switch being active
  • Loading branch information
Alextimka committed Apr 24, 2024
1 parent 9e4dadb commit cec0541
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
29 changes: 19 additions & 10 deletions js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,14 @@ if (typeof browser === "undefined") {

// Cookie functions
function setCookie(name, value, days) {
const expires = `; expires=${new Date(
Date.now() + days * 864e5
).toUTCString()}`;
var expires;
if (days == 0) {
expires = "; expires=;";
} else {
expires = `; expires=${new Date(
Date.now() + days * 864e5
).toUTCString()}`;
}
document.cookie = `${name}=${value}${expires}; path=/`;
}

Expand Down Expand Up @@ -57,18 +62,21 @@ async function latest() {
function insert() {
try {
// Append theme switch
if (isLoggedIn()) {
document.querySelector(".py-2").appendChild(thswitch);
}
document.querySelector(".py-2").appendChild(thswitch);
} catch {}
}

async function insertAfter() {
try {
if (!isLoggedIn() && themeid != 0) {
themeid = 0;
setCookie("themeid", 0, 364);
location.reload();
var isLogged = isLoggedIn();
if (!isLogged) {
if (getCookie("expirationTheme") == 1) {
setCookie("expirationTheme", 0, 364);
}
setCookie("themeid", themeid, 0);
} else {
setCookie("expirationTheme", 1, 364);
setCookie("themeid", themeid, 364);
}
} catch {}
try {
Expand Down Expand Up @@ -112,6 +120,7 @@ if (
tempcookie < 0
) {
setCookie("themeid", 0, 364);
setCookie("expirationTheme", 1, 364);
themeid = 0;
} else {
themeid = parseInt(tempcookie);
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"manifest_version": 3,
"name": "Spectrum",
"version": "1.3.7",
"version": "1.3.8",
"description": "__MSG_extDesc__",
"default_locale": "en",
"icons": {
Expand Down

0 comments on commit cec0541

Please sign in to comment.