Module:MainPageSkinSwitch: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
mNo edit summary |
||
Line 1: | Line 1: | ||
function p.detectSkin() | function p.detectSkin() | ||
local frame = mw.getCurrentFrame() | local frame = mw.getCurrentFrame() | ||
Line 20: | Line 18: | ||
return skin | return skin | ||
end | end | ||
Revision as of 15:52, 1 August 2024
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