<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://stockhub.co/index.php?action=history&amp;feed=atom&amp;title=Module%3AUser_scripts_table%2Fsandbox</id>
	<title>Module:User scripts table/sandbox - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://stockhub.co/index.php?action=history&amp;feed=atom&amp;title=Module%3AUser_scripts_table%2Fsandbox"/>
	<link rel="alternate" type="text/html" href="https://stockhub.co/index.php?title=Module:User_scripts_table/sandbox&amp;action=history"/>
	<updated>2026-04-22T11:29:26Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.5</generator>
	<entry>
		<id>https://stockhub.co/index.php?title=Module:User_scripts_table/sandbox&amp;diff=147533&amp;oldid=prev</id>
		<title>imported&gt;Guarapiranga: /*  */</title>
		<link rel="alternate" type="text/html" href="https://stockhub.co/index.php?title=Module:User_scripts_table/sandbox&amp;diff=147533&amp;oldid=prev"/>
		<updated>2022-06-16T05:27:45Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;local p = {}&lt;br /&gt;
&lt;br /&gt;
local function allcases(s)&lt;br /&gt;
	return s:gsub(&amp;#039;([%^%$%(%)%%%.%[%]%*%+%-])&amp;#039;, &amp;#039;%%%1&amp;#039;)&lt;br /&gt;
		:gsub(&amp;#039;%a&amp;#039;, function(letter) return &amp;#039;[&amp;#039;..letter:upper()..letter:lower()..&amp;#039;]&amp;#039; end)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function getParam(content, template, parameter)&lt;br /&gt;
	if content == nil then return &amp;#039;&amp;#039;&lt;br /&gt;
	else return content:gsub(&amp;#039;%b{}&amp;#039;,&lt;br /&gt;
		function(templated)&lt;br /&gt;
			return templated:gsub(&amp;#039;^{{%s*&amp;#039;..template..&amp;#039;%s*(|.-})}$&amp;#039;,&lt;br /&gt;
				function(parameters)&lt;br /&gt;
					return parameters:gsub(&amp;#039;|%s*&amp;#039;..allcases(parameter)..&amp;#039;%s*=%s*([^|}]+)&amp;#039;, &amp;#039;%1&amp;#039;)&lt;br /&gt;
				end)&lt;br /&gt;
		end)&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.main(frame)&lt;br /&gt;
    local rowsToGet = tonumber(frame.args[1]) or 200  -- use this to determine number of rows to get (default 200)&lt;br /&gt;
    local rowOffset = tonumber(frame.args[2]) or 0   -- use this offset to allow multiple calls to build larger table   &lt;br /&gt;
    local source = mw.title.new(&amp;#039;Wikipedia:User scripts/Most imported scripts&amp;#039;):getContent()&lt;br /&gt;
    local data = {}&lt;br /&gt;
	local rows = mw.html.create()&lt;br /&gt;
    local count = 0&lt;br /&gt;
    for scriptTitle, total, active in source:gmatch(&amp;#039;\n| %[%[([^%]]+)%]%] -\n| (%d+) -\n| (%d+)&amp;#039;) do&lt;br /&gt;
		count = count + 1&lt;br /&gt;
		if count &amp;gt; rowOffset then&lt;br /&gt;
			local redirectTarget = mw.title.new(scriptTitle).redirectTarget&lt;br /&gt;
			if redirectTarget then local scriptTitle = redirectTarget.prefixedText end&lt;br /&gt;
			local scriptText = mw.title.new(scriptTitle):getContent()&lt;br /&gt;
			-- don&amp;#039;t include scripts that have been blanked or redirected as non-functional&lt;br /&gt;
			if not scriptText:find(&amp;quot;mw.log.warn( &amp;#039;You installed the userscript&amp;quot;, 1, true) then&lt;br /&gt;
				data[scriptTitle] = { total = total, active = active }&lt;br /&gt;
				local docTitle = scriptTitle:match(&amp;#039;(.-)%.[CJcj][Ss][Ss]?$&amp;#039;)&lt;br /&gt;
				local redirectTarget = mw.title.new(docTitle).redirectTarget&lt;br /&gt;
				if redirectTarget then local docTitle = redirectTarget.prefixedText end&lt;br /&gt;
				local name = docTitle:match(&amp;#039;([^/:]-)$&amp;#039;)&lt;br /&gt;
				local author = scriptTitle:match(&amp;#039;User:([^%/]+)&amp;#039;)&lt;br /&gt;
				local desc = &amp;#039;&amp;#039;&lt;br /&gt;
				local status = &amp;#039;&amp;#039;&lt;br /&gt;
				local browsers = &amp;#039;&amp;#039;&lt;br /&gt;
				local skins = &amp;#039;&amp;#039;&lt;br /&gt;
				local docText = mw.title.new(docTitle):getContent() or &amp;#039;&amp;#039;&lt;br /&gt;
				if docText ~= &amp;#039;&amp;#039; then&lt;br /&gt;
					name = getParam(docText, &amp;#039;[Ii]nfobox user script&amp;#039;, &amp;#039;name&amp;#039;) or getParam(docText, &amp;#039;[Ii]nfobox wikipedia user script&amp;#039;, &amp;#039;name&amp;#039;) or docTitle:match(&amp;#039;([^/:]-)$&amp;#039;)&lt;br /&gt;
					author = getParam(docText, &amp;#039;[Ii]nfobox user script&amp;#039;, &amp;#039;author&amp;#039;) or getParam(docText, &amp;#039;[Ii]nfobox wikipedia user script&amp;#039;, &amp;#039;author&amp;#039;) or script:match(&amp;#039;User:([^%/]+)&amp;#039;)&lt;br /&gt;
					status = getParam(docText, &amp;#039;[Ii]nfobox user script&amp;#039;, &amp;#039;status&amp;#039;) or getParam(docText, &amp;#039;[Ii]nfobox wikipedia user script&amp;#039;, &amp;#039;status&amp;#039;) or &amp;#039;&amp;#039;&lt;br /&gt;
					browsers = getParam(docText, &amp;#039;[Ii]nfobox user script&amp;#039;, &amp;#039;browsers&amp;#039;) or getParam(docText, &amp;#039;[Ii]nfobox wikipedia user script&amp;#039;, &amp;#039;browsers&amp;#039;) or &amp;#039;&amp;#039;&lt;br /&gt;
					skins = getParam(docText, &amp;#039;[Ii]nfobox user script&amp;#039;, &amp;#039;skins&amp;#039;) or getParam(docText, &amp;#039;[Ii]nfobox wikipedia user script&amp;#039;, &amp;#039;skins&amp;#039;) or &amp;#039;&amp;#039;&lt;br /&gt;
					desc = getParam(docText, &amp;#039;[Ii]nfobox user script&amp;#039;, &amp;#039;desc&amp;#039;) or getParam(docText, &amp;#039;[Ii]nfobox wikipedia user script&amp;#039;, &amp;#039;desc&amp;#039;) or mw.text.truncate(docText&lt;br /&gt;
						--keep descriptions from template params						&lt;br /&gt;
						:gsub(&amp;#039;^{{[Uu]|([^}]+)&amp;#039;, &amp;#039;[[User:%1|%1]]&amp;#039;) --expand {{u}} at top level&lt;br /&gt;
						:gsub(&amp;quot;%b{}&amp;quot;, &amp;#039;&amp;#039;) --remove other templates&lt;br /&gt;
						--strip out images, files, media, categories&lt;br /&gt;
						:gsub(&amp;#039;%b[]&amp;#039;,&lt;br /&gt;
							function(bracketed)&lt;br /&gt;
								return bracketed:gsub(&amp;#039;^%[%[%s*(%a+):.-%]%]$&amp;#039;,&lt;br /&gt;
									function(link_prefix)&lt;br /&gt;
										link_prefix = link_prefix:lower()&lt;br /&gt;
										if link_prefix == &amp;quot;image&amp;quot; or link_prefix == &amp;quot;file&amp;quot;&lt;br /&gt;
										or link_prefix == &amp;quot;media&amp;quot; or link_prefix == &amp;quot;category&amp;quot; then&lt;br /&gt;
											return &amp;quot;&amp;quot;&lt;br /&gt;
										end -- otherwise leave it alone&lt;br /&gt;
									end)&lt;br /&gt;
							end)&lt;br /&gt;
						--remove spans while keeping text inside&lt;br /&gt;
						--strip out remaining tags and the text inside&lt;br /&gt;
						:gsub(&amp;#039;&amp;lt;(%a+)[^&amp;gt;]+&amp;gt;(.-)&amp;lt;/%1&amp;gt;&amp;#039;, function(tag, contents)&lt;br /&gt;
							if tag:lower() == &amp;quot;span&amp;quot; then&lt;br /&gt;
								return contents&lt;br /&gt;
							else&lt;br /&gt;
								return &amp;quot;&amp;quot;&lt;br /&gt;
							end&lt;br /&gt;
						end)&lt;br /&gt;
						:gsub(&amp;#039;%b&amp;lt;&amp;gt;&amp;#039;, &amp;#039;&amp;#039;) --remove any other tag markup&lt;br /&gt;
						:gsub(&amp;#039;__[^_]+__&amp;#039;, &amp;#039;&amp;#039;) --remove __ markups&lt;br /&gt;
						:gsub(&amp;#039;^=+[^=]+=+&amp;#039;, &amp;#039;&amp;#039;):gsub(&amp;#039;\n=+[^=]+=+&amp;#039;, &amp;#039;&amp;#039;) --remove section titles&lt;br /&gt;
						:gsub(&amp;quot;&amp;#039;&amp;#039;+&amp;quot;, &amp;quot;&amp;quot;) --strip out bold and italic markup&lt;br /&gt;
						:gsub(&amp;#039;&amp;amp;nbsp;&amp;#039;, &amp;#039; &amp;#039;) --replace nbsp spaces with regular spaces&lt;br /&gt;
						:gsub(&amp;#039;^[:;%s]+&amp;#039;, &amp;#039;&amp;#039;):gsub(&amp;#039;\n[:;%s]+&amp;#039;, &amp;#039;\n&amp;#039;) --strip indents, leading&lt;br /&gt;
						:gsub(&amp;#039;{|.-\n|}&amp;#039;, &amp;#039;&amp;#039;) --remove tables&lt;br /&gt;
						:gsub(&amp;#039;\n|[^\n]*\n&amp;#039;, &amp;#039;&amp;#039;) --remove table fragments&lt;br /&gt;
						:gsub(&amp;#039;%s+\n&amp;#039;, &amp;#039;\n&amp;#039;) --and trailing spaces&lt;br /&gt;
						:gsub(&amp;#039;(%s)%s+&amp;#039;, &amp;#039;%1&amp;#039;) --strip redundant spaces&lt;br /&gt;
						:gsub(allcases(name)..&amp;#039;(%s)&amp;#039;, &amp;quot;&amp;#039;&amp;#039;&amp;#039;&amp;quot;..name..&amp;quot;&amp;#039;&amp;#039;&amp;#039;%1&amp;quot;)&lt;br /&gt;
						, 600, &amp;#039;&amp;#039;):gsub(&amp;#039;^(.+%.).+$&amp;#039;, &amp;#039;%1&amp;#039;) --truncate at end of last sentence before 600 chars&lt;br /&gt;
						.. &amp;#039;&amp;lt;!-- --&amp;gt;&amp;#039;&lt;br /&gt;
					desc = mw.text.trim(desc):gsub(&amp;#039;^(.+)%.$&amp;#039;, &amp;#039;%1&amp;#039;)..&amp;#039;.&amp;#039;  --trim and add last period, if missing&lt;br /&gt;
						.. &amp;#039; [[&amp;#039; .. docTitle .. &amp;#039;|→]]&amp;#039; --add arrow link to full doc&lt;br /&gt;
				end&lt;br /&gt;
				local row = rows:tag(&amp;#039;tr&amp;#039;):attr(&amp;#039;id&amp;#039;, scriptTitle):attr(&amp;#039;style&amp;#039;,&amp;#039;vertical-align:top&amp;#039;)&lt;br /&gt;
				if docText == &amp;#039;&amp;#039; then link = scriptTitle else link = docTitle end&lt;br /&gt;
				row:tag(&amp;#039;td&amp;#039;):wikitext(string.format(&amp;#039;\&amp;#039;\&amp;#039;\&amp;#039;[[%s|%s]]\&amp;#039;\&amp;#039;\&amp;#039;&amp;lt;span id=&amp;quot;%s&amp;quot; class=scriptInstallerLink&amp;gt;&amp;lt;/span&amp;gt;\n&amp;lt;p&amp;gt;%s&amp;lt;/p&amp;gt;&amp;#039;, link, name, scriptTitle, desc))&lt;br /&gt;
				row:tag(&amp;#039;td&amp;#039;):wikitext(string.format(&amp;#039;[[User:%s|%s]]&amp;#039;, author, author))&lt;br /&gt;
				row:tag(&amp;#039;td&amp;#039;):wikitext(frame:callParserFunction(&amp;#039;#time&amp;#039;, &amp;#039;j M Y&amp;#039;, frame:callParserFunction(&amp;#039;REVISIONTIMESTAMP&amp;#039;, scriptTitle))):addClass(&amp;#039;nowrap&amp;#039;):attr(&amp;#039;style&amp;#039;,&amp;#039;text-align:right&amp;#039;)&lt;br /&gt;
				row:tag(&amp;#039;td&amp;#039;):wikitext(status)&lt;br /&gt;
				row:tag(&amp;#039;td&amp;#039;):wikitext(skins)&lt;br /&gt;
				row:tag(&amp;#039;td&amp;#039;):wikitext(browsers)&lt;br /&gt;
				row:tag(&amp;#039;td&amp;#039;):wikitext(data[scriptTitle].active):attr(&amp;#039;style&amp;#039;,&amp;#039;text-align:right&amp;#039;)&lt;br /&gt;
				row:tag(&amp;#039;td&amp;#039;):wikitext(data[scriptTitle].total):attr(&amp;#039;style&amp;#039;,&amp;#039;text-align:right&amp;#039;)&lt;br /&gt;
				rows:wikitext(&amp;#039;\n&amp;#039;)&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	    if count &amp;gt;= rowsToGet + rowOffset then break end&lt;br /&gt;
    end&lt;br /&gt;
    return rows&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>imported&gt;Guarapiranga</name></author>
	</entry>
</feed>