From e38f326875752a27a2819b6b7914ffe65e848aba Mon Sep 17 00:00:00 2001 From: yo momma Date: Fri, 30 Jan 2026 01:20:07 +0000 Subject: Refactor: JS init + HTTPS-safe URLs --- static/js/src/_main.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'static/js/src/_main.js') diff --git a/static/js/src/_main.js b/static/js/src/_main.js index d97b0ac..18592d5 100755 --- a/static/js/src/_main.js +++ b/static/js/src/_main.js @@ -3,6 +3,9 @@ window.RootDomain = location.href.match(/http:\/\/(\w)+\./) ? '/' : '/'; +if (typeof window.Nick === 'undefined') { window.Nick = null; } +if (typeof window.Domain === 'undefined') { window.Domain = ''; } + window.cache = {}; window.PendingMessages = {}; window.MessageContentCache = {}; @@ -29,9 +32,17 @@ window.Anim = { "logThumbBig": {"width": "64px", "height": "64px", "marginRight": "-2px", "marginTop": "-2px"} } +function getCookieDomain() { + if (!location || !location.hostname) { return null; } + var hostname = location.hostname; + if (hostname == 'localhost' || hostname.match(/^\\d+\\.\\d+\\.\\d+\\.\\d+$/)) { return null; } + var parts = hostname.split("."); + if (parts.length < 2) { return null; } + return "." + parts.slice(-2).join("."); +} window.Preferences = { - "Domain": '.dump.fm', + "Domain": getCookieDomain(), "getProperty": function(prop, defaultValue) { var value = $.cookie(prop); @@ -46,4 +57,3 @@ window.Preferences = { $.cookie(prop, null, { domain: Preferences.Domain, path: '/' }); } }; - -- cgit v1.2.3-70-g09d2