User:機智的小魚君/common.js
注意:在您儲存之後您必須清除瀏覽器快取才可看到最新的變動。
- Firefox / Safari:按住「Shift」時點選「重新整理」,或按「Ctrl-F5」或「Ctrl-R」 (Mac則為「⌘-R」)
- Google Chrome:按「Ctrl-Shift-R」 (Mac 則為「⌘-Shift-R」)
- Internet Explorer:按住「Ctrl」時點選「重新整理」,或按「Ctrl-F5」
- Opera:進入「工具→偏好設定」中清除快取。
- 如果您已登入但該頁面出現未登入狀態,請嘗試在網址列的URL最後新增代碼
?_=1
來訪問最新頁面。
- /** User Gadgets **/
- mw.loader.load(
- 'http://zh.moegirl.tw/index.php?title=User:機智的小魚君/gadget/index.js&action=raw&ctype=text/javascript'
- )
- /** InPageEdit **/
- // Global variable
- var InPageEdit = window.InPageEdit || {}
- // Load plugin
- import('http://127.0.0.1:1225/InPageEdit.js?_=' + Date.now())
- .then(
- function (payload) {
- console.info('[InPageEdit] Connected to dev server')
- var config = mw.config.get()
- return payload.InPageEdit.newFromApiEndpoint(
- config.wgServer + config.wgScriptPath + '/api.php'
- )
- },
- function (e) {
- console.info('[InPageEdit] Cannot fetch dev server', e)
- mw.loader.load('https://unpkg.com/mediawiki-inpageedit')
- return Promise.reject(e)
- }
- )
- .then(function (ctx) {
- console.info('[InPageEdit] Context', ctx)
- window.ipenext = ctx
- })
- // Preferences
- InPageEdit.myPreference = {
- editMinor: false,
- editSummary: '$section快速小編輯$oldid // InPageEdit-v2',
- outSideClose: false,
- plugins: [
- 'toolbox.js',
- 'edit-any-page.js',
- 'monaco/script.js',
- 'color-preview.js',
- 'quick-thank.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 */
- $(function () {
- window.toggleMoeskin = function (status) {
- if (typeof status === 'undefined') {
- status = !(mw.user.options.get('skin') === 'moeskin')
- } else {
- status = !!status
- }
- var api = new mw.Api({
- parameters: {
- format: 'json',
- formatversion: 2,
- },
- })
- return api
- .postWithToken('csrf', {
- format: 'json',
- action: 'options',
- change: 'skin=' + (status ? 'moeskin' : 'vector'),
- })
- .then(function (data) {
- if (data.options === 'success') {
- return true
- } else {
- return false
- }
- })
- }
- })
- /** More portletLinks */
- $(function () {
- var conf = mw.config.get()
- // 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'
- }
- // MoeSkin switcher
- 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 {
- import('http://localhost:2023/dev/autoload.ts?_=' + Date.now())
- } catch (e) {
- // NOOP
- }
- }
- })
此頁面最後編輯於 2025年5月14日 (週三) 22:36。