Open main menu
Home
Random
Donate
Recent changes
Special pages
Community portal
Preferences
About Stockhub
Disclaimers
Search
User menu
Talk
Contributions
Create account
Log in
Editing
Module:Sandbox/逆襲的天邪鬼/vandalism
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
--[[ Just for fun. ]]-- local func = {} local function rfind(s, pattern, init) local x, y local len = #s local i = init or len x, y = string.find(string.reverse(s), string.reverse(pattern), len-i+1, true) if x then return len-y+1, len-x+1 end end -- TODO: fix for English Wikipedia function func.eatuserbox(frame) local text = frame.args[1] or '' local output = '' output = string.gsub(text, '(class="wikipediauserbox" style=".-)"', '%1;visibility:hidden;"') output = string.gsub(output, '(style=".-)(" class="wikipediauserbox")', '%1;visibility:hidden;%2') output = string.gsub(output, '(class="wikipediauserbox%-m" style=".-)"', '%1;visibility:hidden;"') output = string.gsub(output, '(<div style=".-)(">%s*{%|%s*cellspacing="0")', '%1;visibility:hidden;%2') -- 專殺{{現在}} output = string.gsub(output, '(<div style="float:left; border: 1px solid orange; margin:1px; background: white; width: 238px; height:45px; text%-align: center; vertical%-align: middle;.-)(">)', '%1;visibility:hidden;%2') -- 將「坐等刪除」換成已被刪光 if (not frame.args['notaunt']) or (mw.text.trim(frame.args['notaunt']) == '') then local x, y = string.find(output, '這個用戶正坐等他人來刪除用戶框。</td>', 1, true) if x then local left1, left2 = rfind(output, 'visibility:hidden;', x) output = string.sub(output, 1, left1-1) .. string.sub(output, left2+1, x-1) .. '這個用戶的用戶框全都被人刪光啦!</td>' .. string.sub(output, y+1, -1) end end if (not frame.args['nocategory']) or (mw.text.trim(frame.args['nocategory']) == '') then output = output .. '[[Category:用戶框被刪光了的維基人]]' end return output end function func.countstars(frame) local text = frame.args[1] or '' local pattern = frame.args[2] or '%*' local count = 0 for _ in string.gmatch(text, pattern) do count = count + 1 end return count end function func.strrev(frame) local text = frame.args[1] or '' return string.reverse(text) end function func.strreplace(frame) local text = frame.args[1] or '' local i=2 local from, to while frame.args[i] do from = frame.args[i] to = frame.args[i+1] or '' text = string.gsub(text, from, to) i=i+2 end return text end function func.nowiki(frame) local text = frame.args[1] or '' return mw.text.nowiki(text) end function func.nowiki2(frame) local text = mw.title.new(frame.args[1]):getContent() return mw.text.nowiki(text) end local function islinkeatable(text) local test = string.lower(text) return not (string.find(test, 'category:') == 1 or string.find(test, 'image:') == 1 or string.find(test, 'file:') == 1 or string.find(test, 'zh:') == 1 or string.find(test, 'ja:') == 1) end function func.eatlinks(frame) local text = frame.args[1] or '' -- TODO: External links return (string.gsub(text, '%[%[([^\n]-)%]%]', function(x) if islinkeatable(x) then local target = string.gsub(x, '^(.-)%|.-$', '%1') local text = string.gsub(x, '^.-%|(.-)$', '%1') if string.find(target, ':') == 1 then if text == target then text = string.sub(text, 2) end return '<span style="color:#36b;cursor:pointer;">' .. text .. '</span>' else if mw.title.new(target):getContent() then return '<span style="color:#0645ad;cursor:pointer;">' .. text .. '</span>' else return '<span style="color:#ba0000;cursor:pointer;">' .. text .. '</span>' end end else return '[[' .. x .. ']]' end end)) end return func
Summary:
Please note that all contributions to Stockhub may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Stockhub:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Templates used on this page:
Template:Soft redirect
(
edit
)
Module:Sandbox/逆襲的天邪鬼/vandalism/doc
(
edit
)