用户:夕舞八弦/common.js

来自PRTS
跳转到导航 跳转到搜索

注意:在发布之后,您可能需要清除浏览器缓存才能看到所作出的变更的影响。

  • Firefox或Safari:按住Shift的同时单击刷新,或按Ctrl-F5Ctrl-R(Mac为⌘-R
  • Google Chrome:Ctrl-Shift-R(Mac为⌘-Shift-R
  • Internet Explorer或Edge:按住Ctrl的同时单击刷新,或按Ctrl-F5
  • Opera:Ctrl-F5
(window.RLQ = window.RLQ || []).push(function () {
	mw.loader.load('/index.php?title=User:梅林/js/pair.js&action=raw&ctype=text/javascript');
	if(!!!mw.config.get('wgMFMode')){
		$( document ).ready( function(){
			mw.util.addPortletLink('p-personal', '/index.php?title='+mw.config.get('wgPageName')+'&action=view&debug=true', 'debug','','','','#pt-userpage');
			mw.util.addPortletLink('p-personal', '/w/Widget:TagSearch', 'TagSearch','','','','#pt-userpage');
			mw.util.addPortletLink('p-personal', '/w/特殊:版本', '版本','','','','#pt-userpage');
			mw.util.addPortletLink('p-personal', '/w/widget:8sandbox', '8sandbox','','','','#pt-userpage');
			mw.util.addPortletLink('p-personal', '/w/PRTS:文件一览', '文件一览','','','','#pt-userpage');
			mw.util.addPortletLink('p-personal','https://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual', 'lua手册','','','','#pt-userpage');
		} );
    }
    var interval=setInterval(function(){
        if (typeof mw.Api =='function'){
            clearInterval(interval);
            var url = window.location.pathname;
            url = decodeURI(url);
            url = url.substr(3);
            var ns;
            var api = new mw.Api();
            api.get({
                "action": "query",
                "prop": "pageprops",
                "titles": url
            }).done(function (data) {
                for (var temO in data.query.pages) {
                    var o = data.query.pages[temO];
                    ns = o.ns;
                    if (ns !== 0) {
                        url = url.substr(url.indexOf(":") + 1);
                    }
                    var api2 = new mw.Api();
                    api2.get({
                        "action": "query",
                        "list": "allpages",
                        "apprefix": url,
                        "aplimit": 500,
                        "apnamespace": ns
                    }).done(function (data2) {
                        data2.query.allpages.forEach(function (v) {
                            console.log("http://prts.wiki/w/" + v.title.replace(/ /g, "_"));
                        });
                    });
                }
            });
        }
    },1);
});


if(/action=(edit|submit)/.test(location.href)){
	if(/title=Widget:/.test(location.href)){
		var wpText = $('#wpTextbox1');
		console.log('preventTab');
		wpText[0].addEventListener(
			'keydown',function(e){
				var kc=e.keyCode||e.which;
				if(kc===9){
					var start=wpText[0].selectionStart;
					var end=wpText[0].selectionEnd;
					wpText[0].value=wpText[0].value.substring(0,start)+'\t'+wpText[0].value.substring(end);
					wpText[0].selectionStart=wpText[0].selectionEnd=start+1;
					e.preventDefault();
				}
			}
		);
	}
}