Module:MainPageSkinSwitch

From IxWiki
Revision as of 15:52, 1 August 2024 by Heku (talk | contribs)
Jump to navigation Jump to search

Documentation for this module may be created at Module:MainPageSkinSwitch/doc

function p.detectSkin()
    local frame = mw.getCurrentFrame()
    local request = frame:getRequest()
    local cookieData = request:getHeader('Cookie')
    
    local skin = 'vector'  -- Default to vector
    if cookieData then
        for cookie in cookieData:gmatch('([^;]+)') do
            local name, value = cookie:match('(%s*)(.+)=(.+)')
            if name and name:match('userSkin') then
                skin = value
                break
            end
        end
    end
    
    mw.log('Detected skin from cookie: ' .. tostring(skin))
    return skin
end