用户:Salt lovely/common.js

Salt lovely留言 | 贡献2020年10月15日 (四) 10:21的版本 (// Edit via Wikiplus)

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

  • 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
/*使用wikiplus*/
mw.loader.load('https://wikiplus-app.com/Main.js');
/*引入高亮*/
$('head').append('<script src="https://cdn.bootcdn.net/ajax/libs/prettify/188.0.0/prettify.min.js"></script><link href="https://cdn.bootcdn.net/ajax/libs/prettify/r298/prettify.min.css" rel="stylesheet">')
/*文档准备完毕后执行*/
$(document).ready(function(){
    function countLog(obj) {
        $(obj).each(function(){
            var count=$(this).children('li').length;
            $(this).prepend('<span>共计'+count+'条记录</span>');
        });
    }
    /*代码高亮*/
    $('pre').each((i,el) => {el.classList.add()});
    prettyPrint();
    /*清理缓存*/
    $('#pt-logout').before('<li id="pt-purge"><a title="刷新页面并清理缓存" href="?action=purge">清理缓存</a><li>');

    /*日志统计*/
    countLog("#mw-log-deleterevision-submit>ul");

});

//弃用代码
/* var new_element1 = document.createElement("link");
new_element1.setAttribute("rel", "stylesheet");
new_element1.setAttribute(
  "href",
  "http://cdn.bootcss.com/highlight.js/8.0/styles/monokai_sublime.min.css"
);
document.head.appendChild(new_element1);

var new_element2 = document.createElement("script");
new_element2.setAttribute("type", "text/javascript");
new_element2.setAttribute(
  "src",
  "http://cdn.bootcss.com/highlight.js/8.0/highlight.min.js"
);
document.head.appendChild(new_element2);

var new_element3 = document.createElement("script");
new_element3.innerHTML="hljs.initHighlightingOnLoad();";
document.head.appendChild(new_element3);
*/
/*
var advanceFrame = function( parentElem, parentSelector ) {
	var curFrame = parentElem.querySelector( parentSelector + ' > .animated-active' );
	$( curFrame ).removeClass( 'animated-active' );
	var $nextFrame = $( curFrame && curFrame.nextElementSibling || parentElem.firstElementChild );
	return $nextFrame.addClass( 'animated-active' );
};
setInterval( function() {
	$('#mw-content-text').find('.animated').each( function() {
		var $nextFrame = advanceFrame( this, '.animated' );
		if ( $nextFrame.hasClass( 'animated-subframe' ) ) {
			advanceFrame( $nextFrame[0], '.animated-subframe' );
		}
	} );
}, 2000 );
*/
/*
$('head').append('<link href="https://cdn.bootcss.com/highlight.js/8.0/styles/monokai_sublime.min.css" rel="stylesheet"><script src="https://cdn.bootcss.com/highlight.js/8.0/highlight.min.js"></script><script >hljs.initHighlightingOnLoad();</script>');
*/