User:Sportzpikachu/11nm.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
![]() | Documentation for this user script can be added at User:Sportzpikachu/11nm. |
/*!
* Ultraviolet - the user-friendly MediaWiki counter-vandalism tool.
* Version v0.2.0+e7e1012, commit e7e1012, built on 2024-05-24T15:44:38.990Z.
*
* Contact us at tools.ultraviolet@toolforge.org or [[WT:UV]].
* For external library license information, see http://localhost:4173/LICENSES.txt.
*
* ------------------------------------------------------------------------------
*
* (c) 2024 The Ultraviolet Development Team (10nm) and contributors
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* ------------------------------------------------------------------------------
*
* Ultraviolet is an open source project, and we invite others to develop extensions,
* styles, translation, and other expansions for Ultraviolet! If you'd like to learn
* more, reach out at https://en.wikipedia.org/wiki/Wikipedia:Ultraviolet/Contact.
*
* ------------------------------------------------------------------------------
*
* ! ATTENTION TO ALL WITH SCRIPT EDITING PERMISSIONS !
*
* Changing this file will affect a large amount of users.
* It is not suggested that you directly change this file
* as there may be unknown implications of doing so. If
* there is an immediate threat posed by the script which
* needs to be settled immediately, please inform the
* Ultraviolet team after making your changes.
*
* This file is automatically generated by webpack when a
* new update is released. If you wish to modify the code,
* it is better to do so by making a pull request to the
* Ultraviolet repository on GitLab, which can be found here:
*
* https://gitlab.wikimedia.org/repos/10nm/ultraviolet/
*
* ------------------------------------------------------------------------------
* <nowiki>
*/
mw.loader.using( [
"vue",
"pinia",
"mediawiki.api"
], function ( require ) {
"use strict";var L=Object.create;var k=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var U=Object.getPrototypeOf,q=Object.prototype.hasOwnProperty;var F=(e,t,o)=>t in e?k(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o;var Z=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of j(t))!q.call(e,s)&&s!==o&&k(e,s,{get:()=>t[s],enumerable:!(r=P(t,s))||r.enumerable});return e};var y=(e,t,o)=>(o=e!=null?L(U(e)):{},Z(t||!e||!e.__esModule?k(o,"default",{value:e,enumerable:!0}):o,e));var m=(e,t,o)=>(F(e,typeof t!="symbol"?t+"":t,o),o);const l=require("vue"),_=require("pinia"),x="v0.2.0+e7e1012",M="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 672.6 192'%3E%3Cdefs%3E%3CclipPath id='a'%3E%3Cpath style='fill:none' d='M0 0h673v192H0z'/%3E%3C/clipPath%3E%3C/defs%3E%3Cg style='clip-path:url(%23a)'%3E%3Cpath d='M43 173q-12 0-18-8t-7-23V95h16v44q0 20 15 20a22 22 0 0 0 13-4 27 27 0 0 0 9-12V95h16v57a6 6 0 0 0 1 4 5 5 0 0 0 4 2v13a53 53 0 0 1-7 1 12 12 0 0 1-8-2 8 8 0 0 1-3-7v-7a34 34 0 0 1-14 12 38 38 0 0 1-17 5Zm58-108h16v84a9 9 0 0 0 2 7 8 8 0 0 0 6 2 15 15 0 0 0 4 0l4-2 2 13a37 37 0 0 1-8 2 45 45 0 0 1-9 1q-8 0-12-4t-5-13Zm79 102a83 83 0 0 1-8 4 36 36 0 0 1-12 1 24 24 0 0 1-7-1 17 17 0 0 1-6-3 14 14 0 0 1-4-5 19 19 0 0 1-1-8v-47h-10V95h10V70h16v25h16v13h-16v42q0 4 2 6a9 9 0 0 0 6 2 18 18 0 0 0 6-1l5-2Zm47-58a36 36 0 0 0-16 4 22 22 0 0 0-11 12v46h-16V95h15v17a35 35 0 0 1 10-12 25 25 0 0 1 14-5h2a8 8 0 0 1 2 0Zm24 64a28 28 0 0 1-10-2 25 25 0 0 1-8-5 23 23 0 0 1-6-8 23 23 0 0 1-2-9 20 20 0 0 1 3-10 23 23 0 0 1 6-7 32 32 0 0 1 10-5 46 46 0 0 1 13-2 59 59 0 0 1 11 1 53 53 0 0 1 9 2v-5q0-8-4-13t-14-5a33 33 0 0 0-12 3 61 61 0 0 0-12 6l-5-10q14-10 30-10t25 8q8 8 8 23v27q0 5 4 6v13a43 43 0 0 1-7 1l-7-2a10 10 0 0 1-3-6l-1-5a34 34 0 0 1-12 10 37 37 0 0 1-16 4Zm4-12a29 29 0 0 0 11-2 19 19 0 0 0 8-6q3-3 3-6v-10a49 49 0 0 0-17-3q-9 0-14 4a11 11 0 0 0-6 10 12 12 0 0 0 5 9 15 15 0 0 0 10 4Z' style='fill:%23fff'/%3E%3Cpath d='m326 171-28-76h20l19 60 19-60h19l-28 76Zm52-86V65h20v20Zm0 86V95h20v76Zm66 2a42 42 0 0 1-17-4 37 37 0 0 1-13-8 38 38 0 0 1-8-13 42 42 0 0 1 0-30 38 38 0 0 1 8-12 38 38 0 0 1 13-9 42 42 0 0 1 17-3 41 41 0 0 1 16 3 37 37 0 0 1 21 21 42 42 0 0 1 0 30 39 39 0 0 1-8 13 37 37 0 0 1-13 8 42 42 0 0 1-16 4Zm-20-40a27 27 0 0 0 1 10 23 23 0 0 0 4 7 19 19 0 0 0 15 6 18 18 0 0 0 7-2 19 19 0 0 0 7-4 22 22 0 0 0 4-8 27 27 0 0 0 1-9 27 27 0 0 0-1-9 22 22 0 0 0-4-7 19 19 0 0 0-7-5 18 18 0 0 0-7-2 18 18 0 0 0-8 2 20 20 0 0 0-7 5 22 22 0 0 0-4 7 27 27 0 0 0-1 9Zm66-68h19v82a10 10 0 0 0 2 6 7 7 0 0 0 6 3 14 14 0 0 0 4-1 25 25 0 0 0 4-1l2 14a38 38 0 0 1-9 3 50 50 0 0 1-9 1q-9 0-14-5t-5-13Zm74 108a42 42 0 0 1-16-3 37 37 0 0 1-21-21 40 40 0 0 1-3-15 42 42 0 0 1 3-16 37 37 0 0 1 8-12 38 38 0 0 1 13-9 42 42 0 0 1 16-3 41 41 0 0 1 17 3 38 38 0 0 1 12 9 36 36 0 0 1 8 12 42 42 0 0 1 3 15v4a14 14 0 0 1 0 2h-59a23 23 0 0 0 2 8 20 20 0 0 0 4 6 20 20 0 0 0 7 4 20 20 0 0 0 7 2 22 22 0 0 0 11-3 15 15 0 0 0 7-8l17 5a34 34 0 0 1-14 14q-9 6-22 6Zm20-46q-1-9-6-14a20 20 0 0 0-27 0 20 20 0 0 0-5 6 21 21 0 0 0-2 8Zm70 40a87 87 0 0 1-9 4 40 40 0 0 1-12 2 27 27 0 0 1-8-1 17 17 0 0 1-6-4 16 16 0 0 1-4-6 21 21 0 0 1-2-8v-44h-10V95h10V71h19v24h16v15h-16v37q0 4 2 6a8 8 0 0 0 6 2 18 18 0 0 0 6-1l4-2Z' style='fill:%237659b1'/%3E%3Cpath style='fill:none;stroke:%23fff;stroke-linecap:round;stroke-linejoin:round;stroke-width:10px' d='m364 61-19-24m67 24 19-24m-43 17V24'/%3E%3C/g%3E%3C/svg%3E",$="#7758B3",p="userjs-uv-config-user-vue",R=2,D=`Ultraviolet/${x} ([[mw:w:WP:UV]]; https://w.wiki/4xbt;)`,E=Date.now(),G={0:"TRACE",1:"DEBUG",2:"INFO",3:"WARN",4:"ERROR",5:"FATAL"},C={0:"gray",1:"green",2:"aqua",3:"yellow",4:"red",5:"red"},z={0:"trace",1:"debug",2:"log",3:"warn",4:"error",5:"error"};class B{constructor(...t){m(this,"formatString","");m(this,"css",[]);m(this,"_prefix",[]);m(this,"prodMinLevel",3);m(this,"logs",[]);this.prefix=t}get prefix(){return[this.formatString,...this.css,...this._prefix]}set prefix(t){if(t.length===0)return;this.formatString=t.shift();const o=[...this.formatString.matchAll(/%c/g)].length;this.css=t.splice(0,o),this._prefix=t}getPrefixArgs(t=2,o=Date.now()-E){return[`${this.formatString} %c${G[t]}`,...this.css,`color: ${C[t]}; border: 1px solid ${C[t]};font-weight: bold; border-radius: 2px; font-size: 0.9em; padding: 0 1px;`,...this._prefix,`[${o}ms]`]}get trace(){return this.log.bind(this,0)}get debug(){return this.log.bind(this,1)}get info(){return this.log.bind(this,2)}get warn(){return this.log.bind(this,3)}get error(){return this.log.bind(this,4)}get fatal(){return this.log.bind(this,5)}log(t,o,...r){const s=Date.now()-E;this.logs.push({t:s,l:t,m:o,d:r.map(a=>a instanceof Error?{n:a.name,m:a.message,...a.cause&&{c:a.cause},s:a.stack,...a.fileName&&{loc:{f:a.fileName,l:a.lineNumber,c:a.columnNumber}}}:a)}),t>=this.prodMinLevel&&console[z[t]].call(console,...this.getPrefixArgs(t,s),o,...r),t>=4&&this.warn("An unexpected error has occured in Ultraviolet. To export UV's logs for reporting, please run 'await uv.log.dump()' in the console.")}async dump(){const t=JSON.stringify(this.logs);let o="";try{const r=new CompressionStream("gzip"),s=new Blob([t]).stream().pipeThrough(r),a=await new Response(s).blob(),u=await new Promise(f=>{const n=new FileReader;n.onload=()=>{f(n.result)},n.readAsDataURL(a)});o=u.slice(u.indexOf(",")+1)}catch(r){console.error(r),o=btoa(t)}return o}}const i=new B("%cultraviolet",`background: url("${M}") no-repeat center; color: rgba(0,0,0,0); font-family: sans-serif;`);i.info("Starting Ultraviolet...",{start:new Date(E),version:x});const H=["https://tools-static.wmflabs.org/fontcdn/css?family=Roboto:100,100italic,300,300italic,400,400italic,500,500italic,700,700italic,900,900italic&subset=cyrillic,cyrillic-ext,greek,greek-ext,latin,latin-ext,vietnamese","https://tools-static.wmflabs.org/fontcdn/css?family=Material+Icons"];function J(){const e=[];for(const t of H){const o=document.createElement("link");o.rel="stylesheet",o.href=t,document.head.appendChild(o),e.push(new Promise(r=>{o.addEventListener("load",()=>{r(t)})}))}return Promise.all(e)}const T=new mw.Api({parameters:{format:"json",formatversion:2,errorformat:"plaintext"},ajax:{headers:{"Api-User-Agent":D}}});var O=(e=>(e[e.CheckboxGroup=0]="CheckboxGroup",e[e.RadioGroup=1]="RadioGroup",e[e.Select=2]="Select",e[e.Switch=3]="Switch",e[e.Input=4]="Input",e))(O||{});function v(e,t,o,r,s){const a=l.ref(structuredClone(t)),u=l.computed({get:()=>a.value,set:n=>{switch(o==null?void 0:o.type){case 0:if(!Array.isArray(n)){const c=new TypeError("Expected array for setting "+e);throw i.error("Invalid value for setting",e,n,c),c}break;case 1:case 2:if(!o.options.find(c=>c.value===n)){const c=new TypeError("Unknown option for setting "+e);throw i.error("Invalid value for setting",e,n,c),c}break;case 3:if(typeof n!="boolean"){const c=new TypeError("Expected boolean for setting "+e);throw i.error("Invalid value for setting",e,n,c),c}break}a.value=n}}),f=l.computed({get:()=>JSON.stringify(a.value),set:n=>a.value=JSON.parse(n)});return{id:e,value:u,display:o,defaultValue:t,serializedValue:f}}function W(){return{latestVersion:v("latestVersion",x,null),configVersion:v("configVersion",R,null),neopolitan:v("neopolitan",void 0,null)}}var d=(e=>(e.Auto="auto",e.Dark="dark",e.Light="light",e))(d||{});function K(){return{theme:v("theme",null,null),themeMode:v("themeMode","auto",{type:O.Select,options:[{label:"auto",value:"auto"},{label:"dark",value:"dark"},{label:"light",value:"light"}]})}}const A=_.defineStore("preferences",()=>{const e=l.ref(W()),t=l.ref(K()),o={core:e,ui:t};async function r(){const n=mw.user.options.get(p);n?(i.debug("Loading preferences from MediaWiki options",{key:p,config:n}),s(JSON.parse(n))):(i.debug("Preferences not found in MediaWiki options, saving defaults",{key:p}),await a())}r().then(()=>{i.info("Preferences loaded succesfully")}).catch(n=>{i.error("Failed to load preferences",n)});function s(n){if(typeof n!="object")throw i.error("Invalid config object",n),new TypeError(`Invalid config object type, expected object, got ${typeof n}`);for(const[c,h]of Object.entries(n)){if(typeof h!="object"){i.warn("Invalid type for setting group",c,h);continue}if(c in o){const w=o[c];for(const[g,b]of Object.entries(h))g in w.value?(w.value[g].serializedValue=b,i.debug("Loaded setting",g)):i.warn("Unknown setting",g,b)}else i.warn("Unknown setting group",c,h)}}async function a(){const n={};for(const[h,w]of Object.entries(o)){n[h]={};for(const[g,b]of Object.entries(w.value))n[h][g]=b.serializedValue}i.debug("Saving preferences",{key:p,config:n});const c=await T.saveOption(p,JSON.stringify(n));if(c.options!=="success")throw i.error("Failed to save preferences",c,{key:p,config:n}),new Error(`Failed to save preferences: ${c.options}`);i.info("Saved preferences",c,{key:p,config:n}),f()}const u=l.ref([]);function f(){for(const n of u.value)n()}return{core:e,ui:t,load:r,save:a,applyHooks:u,apply:f}}),Y=e=>(l.pushScopeId("data-v-7dfbbe24"),e=e(),l.popScopeId(),e),Q=Y(()=>l.createElementVNode("h1",null,"Ultraviolet",-1)),X=l.defineComponent({__name:"PreferencesApp",setup(e){const t=l.ref(0),o=A();return(r,s)=>(l.openBlock(),l.createElementBlock(l.Fragment,null,[Q,l.createElementVNode("p",null,"no more vandals! you last used "+l.toDisplayString(l.unref(o).core.latestVersion.value),1),l.createElementVNode("md-filled-button",{onClick:s[0]||(s[0]=a=>t.value++)},l.toDisplayString(r.$i18n("ultraviolet-clickme",t.value)),1)],64))}}),ee=(e,t)=>{const o=e.__vccOpts||e;for(const[r,s]of t)o[r]=s;return o},te=ee(X,[["__scopeId","data-v-7dfbbe24"]]),I=_.createPinia();function oe(e){return e.use(I),e}async function re(){const{themeFromSourceColor:e}=await import("http://localhost:4173/./material-color-utilities.js").then(s=>s.theme_utils),{argbFromHex:t,hexFromArgb:o}=await import("http://localhost:4173/./material-color-utilities.js").then(s=>s.string_utils),r=e(t($));return i.debug("Generated material theme",r),{dark:S(o,r.schemes.dark),light:S(o,r.schemes.light)}}function S(e,t){const o={};for(const[r,s]of Object.entries(t.toJSON())){const a=r.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),u=e(s);o[a]=u}return o}function V(e,t){for(const[o,r]of Object.entries(t))e.style.setProperty(`--md-sys-color-${o}`,r)}async function N(e,t=!0){const o=A(I),r=o.ui.theme;r.value||(r.value=await re(),o.save().catch(u=>{i.error("Failed to save theme",u)}));let s=o.ui.themeMode.value;const a=new AbortController;s===d.Auto&&(s=window.matchMedia("(prefers-color-scheme: dark)").matches?d.Dark:d.Light,window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",u=>{const f=u.matches?d.Dark:d.Light;if(!r.value){i.error("Missing theme in matchMedia change event"),a.abort();return}V(e,r.value[f])},{signal:a.signal})),V(e,r.value[s]),t&&o.applyHooks.push(()=>{a.abort(),N(e,!1)})}async function ne(e){if(e.attr("id")!=="mw-content-text"||mw.config.get("wgNamespaceNumber")!==4||mw.config.get("wgTitle")!=="Ultraviolet/Preferences"||mw.config.get("wgAction")!=="view")return;const t=e[0];await N(t),oe(l.createMwApp(te)).mount(t),i.debug("Preferences injector mounted",t)}const se={"wikipage.content":[ne]};function ae(e){const t=o=>async(...r)=>(await e,o(...r));for(const[o,r]of Object.entries(se)){const s=mw.hook(o);for(const a of r)s.add(t(a))}}async function ie(){const e=J().then(o=>{i.debug("Loaded fonts",o)}),t=import("http://localhost:4173/./material-web.js");await Promise.all([e,t])}try{const e=ie().catch(t=>{i.fatal("Error initialising Ultraviolet!",t)});mw.messages.set({"ultraviolet-clickme":"Click me! Count: $1"}),ae(e)}catch(e){i.fatal("Error starting Ultraviolet!",e)}
(function(){"use strict";mw.util.addCSS("button[data-v-7dfbbe24]{width:100%}")})();
} );
/*!
* There is no happy end. It's only just the end.
* https://www.youtube.com/watch?v=aaF9pXj7isg
* </nowiki>
*/