|
|
| (未显示同一用户的9个中间版本) |
| 第1行: |
第1行: |
| // test | | // test |
| mw.loader.load("//mcbbs-wiki.cn/index.php?title=MediaWiki:HanziConverter.js&action=raw&ctype=text/javascript", "text/javascript"); | | // mw.loader.load("//mcbbs-wiki.cn/index.php?title=MediaWiki:HanziConverter.js&action=raw&ctype=text/javascript", "text/javascript"); |
|
| |
|
| var thisHref = window.location.href;
| | // wikiplus |
| //使用wikiplus | | mw.loader.load('https://cdn.jsdelivr.net/npm/wikiplus-core@latest/dist/Main.js'); |
| mw.loader.load('https://wikiplus-app.com/Main.min.js'); | | // mw.loader.load('https://wikiplus-app.com/Main.js'); |
| | // mw.loader.load('https://cdn.jsdelivr.net/npm/mediawiki-inpageedit') |
|
| |
|
| // ------------------
| |
| // 文档准备完毕后执行
| |
| // ------------------
| |
| $(function(){ | | $(function(){ |
| //清理缓存 | | //清理缓存 |
| $('#pt-logout').before('<li id="pt-purge"><a title="刷新页面并清理缓存" href="?action=purge">清理缓存</a></li>' | | $('#pt-logout').before( |
| +'<li id="pt-editcount"><a title="查看编辑数" href="https://mcbbs-wiki.cn/wiki/特殊:编辑计数/Salt_lovely">编辑计数</a></li>'
| | '<li id="pt-purge"><a title="刷新页面并清理缓存" href="?action=purge">清理缓存</a></li>' |
| +'<li id="pt-editcount"><a title="查看所有模板页面" href="https://mcbbs-wiki.cn/wiki/特殊:所有页面?namespace=10">所有模板</a></li>'
| | +'<li id="salt-editcount"><a href="https://mcbbs.wiki/wiki/特殊:编辑计数/Salt_lovely">编辑计数</a></li>' |
| +'<li id="pt-editcount"><a title="查看所有MediaWiki页面" href="https://mcbbs-wiki.cn/wiki/特殊:所有页面?namespace=8">所有MediaWiki</a></li>'
| | +'<li id="all-template"><a href="https://mcbbs.wiki/wiki/特殊:所有页面?namespace=10">所有模板</a></li>' |
| +'<li id="pt-editcount"><a title="查看所有widget页面" href="https://mcbbs-wiki.cn/wiki/特殊:所有页面?namespace=274">所有widget</a></li>');
| | +'<li id="all-mw"><a href="https://mcbbs.wiki/wiki/特殊:所有页面?namespace=8">所有MediaWiki</a></li>' |
| | +'<li id="all-widget"><a href="https://mcbbs.wiki/wiki/特殊:所有页面?namespace=274">所有widget</a></li>' |
| | +'<li id="api-help"><a href="https://mcbbs.wiki/api.php?action=help&modules=main">API文档</a></li>'); |
| //日志统计 | | //日志统计 |
| countLog("#mw-log-deleterevision-submit>ul") | | countLog("#mw-log-deleterevision-submit>ul") |
| //编辑器更改 | | //编辑器更改 |
| loadAddon('WikiEditorModify')
| | // loadAddon('WikiEditorModify') |
| //loadAddon('loadprism') | |
| // 挂在GitHub,用CDN获取
| |
| // mw.loader.load('https://cdn.jsdelivr.net/gh/Salt-lovely/MCBBSWikiPrismLoader/load.js')
| |
| }) | | }) |
|
| |
|
| // ------------------
| |
| // 一些函数,需要自取
| |
| // ------------------
| |
| //加载Addon-XXX.js | | //加载Addon-XXX.js |
| function loadAddon(s) { | | function loadAddon(s) { |
| 第40行: |
第34行: |
| }) | | }) |
| } | | } |
|
| |
| // ------------------
| |
| // 防止手贱回退页面
| |
| // ------------------
| |
| $(function () {
| |
| for (let a of Array.from(document.querySelectorAll('.mw-rollback-link a'))) {
| |
| if (!a.hasAttribute('href')) { continue }
| |
| let handler = (ev) => {
| |
| ev.preventDefault()
| |
| confirmUI('确定要回退此页面吗?', (confirmed) => {
| |
| if (confirmed) { window.location.href = a.href }
| |
| })
| |
| }
| |
| a.addEventListener('click', handler)
| |
| a.addEventListener('touchend', handler)
| |
| }
| |
| /**
| |
| * 显示一个自定义确认框
| |
| * @param {string} text
| |
| * @param {(confirmed:boolean)=>void} callback
| |
| */
| |
| function confirmUI(text = '', callback) {
| |
| // 安全锁,防止用户多次点击
| |
| let safe = true
| |
| // 容器
| |
| let container = document.createElement('div')
| |
| container.className = 'confirmUIcontainer'
| |
| container.innerHTML = `<center>${text}</center>`
| |
| // 确定按钮
| |
| let yesBtn = document.createElement('div')
| |
| yesBtn.className = 'btn'
| |
| yesBtn.style.setProperty('--hover-color', '#FDF6E6')
| |
| yesBtn.textContent = '确定'
| |
| yesBtn.addEventListener('click', () => {
| |
| if (safe) {
| |
| safe = false // 安全锁
| |
| callback(true)
| |
| selfRemove() // 移除确认框
| |
| }
| |
| })
| |
| container.appendChild(yesBtn)
| |
| // 取消按钮
| |
| let noBtn = document.createElement('div')
| |
| noBtn.className = 'btn'
| |
| noBtn.style.setProperty('--hover-color', '#FDF6E6')
| |
| noBtn.textContent = '取消'
| |
| noBtn.addEventListener('click', () => {
| |
| if (safe) {
| |
| safe = false
| |
| callback(false)
| |
| selfRemove()
| |
| }
| |
| })
| |
| container.appendChild(noBtn)
| |
| // 关闭按钮
| |
| let closeBtn = document.createElement('div')
| |
| closeBtn.className = 'close'
| |
| closeBtn.textContent = '×'
| |
| closeBtn.addEventListener('click', () => {
| |
| if (safe) {
| |
| safe = false
| |
| selfRemove()
| |
| }
| |
| })
| |
| container.appendChild(closeBtn)
| |
| // 显示UI
| |
| container.style.opacity = '0'
| |
| container.style.top = '20%'
| |
| container.style.transitionTimingFunction = 'ease-out'
| |
| document.body.appendChild(container)
| |
| // 调整位置
| |
| container.style.marginLeft = (container.offsetWidth * -0.5) + 'px'
| |
| container.style.marginTop = (container.offsetHeight * -0.5) + 'px'
| |
| container.style.transitionDuration = '.3s'
| |
| container.style.opacity = '1'
| |
| container.style.top = '50%'
| |
| setTimeout(() => { container.style.transitionTimingFunction = 'ease-in' }, 400)
| |
| /**移除自己 */
| |
| function selfRemove() {
| |
| container.style.top = '20%'
| |
| container.style.opacity = '0'
| |
| setTimeout(() => { container.remove() }, 400)
| |
| }
| |
| }
| |
| // CSS
| |
| let s = document.createElement('style')
| |
| s.textContent = `
| |
| .confirmUIcontainer{
| |
| position: fixed;
| |
| border: 8px solid #0003;
| |
| border-radius: 8px;
| |
| overflow: hidden;
| |
| padding: 0;
| |
| top: 50%;
| |
| left: 50%;
| |
| min-width: 20vw;
| |
| background: #fbf2dc;
| |
| user-select: none;
| |
| }
| |
| .confirmUIcontainer > center{
| |
| padding: 1.2rem .6rem 1.2rem .6rem;
| |
| font-size: 1.05rem;
| |
| }
| |
| .confirmUIcontainer .btn{
| |
| width: 50%;
| |
| border: 1px solid #ccc;
| |
| padding: 1rem;
| |
| box-sizing: border-box;
| |
| font-size: 1.15rem;
| |
| line-height: 1.15rem;
| |
| float: left;
| |
| background-color: transparent;
| |
| text-align: center;
| |
| transition: .3s ease;
| |
| cursor: pointer;
| |
| }
| |
| .confirmUIcontainer .btn:hover{
| |
| background-color: var(--hover-color,transparent);
| |
| }
| |
| .confirmUIcontainer .close{
| |
| position: absolute;
| |
| width: 2rem;
| |
| height: 2rem;
| |
| top: 0;
| |
| right: 0;
| |
| font-size: 2rem;
| |
| line-height: 2rem;
| |
| text-align: center;
| |
| }
| |
| `
| |
| document.head.appendChild(s)
| |
| })
| |