Edge Rewrite
// HTMLRewriter · presentation

This page was redesigned at the edge.

Cloudflare fetched the original article and streamed it through HTMLRewriter to apply an entirely new visual system without rebuilding the source page.

Jump to content

Module:Twinkle optout

From Wikipedia, the free encyclopedia

local Arguments = require('Module:Arguments')
local TableTools = require('Module:TableTools')
local p = {}

local RECOGNIZED_TYPES = TableTools.listToSet{
	'csd', 'prod', 'xfd', 'afd', 'tfd', 'ffd', 'rfd', 'mfd', 'cfd'
}

p.main = function(frame)
	local args = Arguments.getArgs(frame)
	return p.make_link(args[1])
end

p.make_link = function(types)
	if types == nil then
		return error('no notice types specified')
	end
	if mw.title.getCurrentTitle().namespace ~= 3 then
		return error('{{twinkle optout}} can only used on user talk pages')
	end
	types = types:gsub('%s+', '')
	local types_list = mw.text.split(types, ',')
	for idx, type_name in ipairs(types_list) do
		if RECOGNIZED_TYPES[type_name:lower()] == nil then
			return error('unrecognized notice type: ' .. type_name)
		end
	end
	return '<span style="display: none">https://optout.twinkle?types='..mw.uri.encode(types:lower())..'</span>'
end

return p