注意:在保存之后,您可能需要清除浏览器缓存才能看到所作出的变更的影响。
?_=1
来访问最新页面。https://zh.moegirl.org.cn/User:%E6%9C%BA%E6%99%BA%E7%9A%84%E5%B0%8F%E9%B1%BC%E5%90%9B/common.js?_=1
;(window.RLQ ||= []).push([
['mediawiki.base', 'mediawiki.api', 'mediawiki.util', 'jquery'],
async () => {
// Constants
const api = new mw.Api({
parameters: {
format: 'json',
formatversion: 2,
},
})
const conf = mw.config.get()
/**
*
* @param {string} url
* @param {Record<string, string>} attrs
* @returns {Promise<Event>}
*/
const loadScript = (url, attrs = {}) => {
return new Promise((resolve, reject) => {
/** @type {HTMLScriptElement} */
const script = document['create'.concat('Element')]('script')
script.src = url
script.async = true
Object.keys(attrs).forEach((key) => {
script.setAttribute(key, attrs[key])
})
script.onload = (e) => resolve(e)
script.onerror = () =>
reject(new Error(`Failed to load script: ${url}`))
document.head.appendChild(script)
})
}
/** User Gadgets **/
loadScript(
'https://zh.moegirl.org.cn/index.php?title=User:机智的小鱼君/gadget/index.js&action=raw&ctype=text/javascript'
)
/** InPageEdit **/
// Global variable
const InPageEdit = (window.InPageEdit ||= {})
// Load plugin
loadScript('https://unpkg.com/mediawiki-inpageedit')
/** InPageEdit Preferences */
InPageEdit.myPreference = {
doNotCollectMyInfo: false,
editMinor: false,
editSummary: '$section快速小编辑$oldid // InPageEdit-v2',
redLinkQuickEdit: true,
outSideClose: false,
watchList: 'preferences',
noConfirmEdit: false,
plugins: [
'toolbox.js',
'edit-any-page.js',
'color-preview.js',
'quick-thank.js',
'monaco/script.js',
'fix-double-entrance.js',
'april-fool-2025/main.js',
],
codeMirrorTheme: 'mdn-like',
}
// Test linksHere
mw.hook('InPageEdit').add(function () {
$('#t-whatlinkshere').on('click', function (e) {
if (!InPageEdit.linksHere) return
e.preventDefault()
InPageEdit.linksHere()
})
})
// 修改 IPE 文字防止抑郁
InPageEdit.i18n = InPageEdit.i18n || {}
InPageEdit.i18n['zh-hans'] = InPageEdit.i18n['zh-hans'] || {}
InPageEdit.i18n['zh-hans']['quick-edit'] = 'IPE 快编'
/**
* MoeSkin switcher
* @param {boolean} [enable] - `true` for enabling MoeSkin, `false` for disabling.
* If not provided, it toggles the current state.
*/
const toggleMoeskin = (enable) => {
if (typeof enable === 'undefined') {
enable = !(mw.user.options.get('skin') === 'moeskin')
} else {
enable = !!enable
}
return api
.postWithToken('csrf', {
format: 'json',
action: 'options',
optionname: 'skin',
optionvalue: enable ? 'moeskin' : 'vector',
})
.then(function (data) {
if (data.options === 'success') {
return true
} else {
return false
}
})
}
/** More portletLinks */
$(function () {
// prefix index
if (conf.wgIsArticle) {
var prefixIndex = mw.util.addPortletLink(
'p-tb',
mw.util.getUrl(
'Special:PrefixIndex/' + mw.config.get('wgPageName') + '/'
),
'前缀索引',
'前缀索引'
)
prefixIndex.querySelector('a').target = '_blank'
}
// toggle moeskin
mw.util
.addPortletLink(
'p-navigation',
'javascript:;',
'Toggle MoeSkin',
'Toggle MoeSkin'
)
.addEventListener('click', function () {
if (this.innerText !== 'Toggle MoeSkin') return
var anchorEl = this.querySelector('a')
anchorEl.innerText = 'Loading...'
window.toggleMoeskin().then(function (res) {
if (res) {
anchorEl.innerText = 'Reloading page...'
var url = new URL(location.href)
url.searchParams['delete']('useskin')
if (url.hostname.startsWith('mzh.')) {
url.hostname = url.hostname.replace('mzh', ' zh')
}
location.href = url.href
} else {
anchorEl.innerText = 'Toggle MoeSkin'
}
})
})
})
/** MoeHomeland Dev */
$(function () {
if ($('.mainpage').length) {
try {
loadScript('http://localhost:2023/dev/autoload.ts?_=' + Date.now(), {
type: 'module',
})
} catch (e) {
// NOOP
}
}
})
},
])