MediaWiki:Common.js

来自恶俗维基
跳转到导航 跳转到搜索

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

  • Firefox或Safari:按住Shift的同时单击刷新,或按Ctrl-F5Ctrl-R(Mac为⌘-R
  • Google Chrome:Ctrl-Shift-R(Mac为⌘-Shift-R
  • Edge:按住Ctrl的同时单击刷新,或按Ctrl-F5
mw.loader.implement('adsrandomizer',function($,jQuery,require,module) {
	$(function(){
	  var i = 0;
	  var al = document.querySelectorAll('#ASSPC');
	  for(i = 0;i < al.length;i++){
	    if(!al[i].scrollHeight){
	        al[i].setAttribute('id',Math.random().toString().replace('.',''));
	    }
	  }
	});
});

mw.loader.implement('recaptcha',function($,jQuery,require,module) {
	window.recv2_key = '6LezXqUUAAAAAF_313T4wn1tJNNiJ4dTZYoj4V2Q';
	window.recv3_key = '6LehXKUUAAAAAAz56fq0N-julZrTVQlOc3fLhvgm';
	
    jQuery.ajax({
            type: "GET",
            url: 'https://www.recaptcha.net/recaptcha/api.js',
            dataType: "script",
            cache: true
    });
    
    window.m_esu_log_event = function(action,data){
    	var client_id = window.recv3_client;
    	if(!client_id){
    		var ele = document.createElement('div');
    		ele.style.display = 'none';
    		document.body.appendChild(ele);
    		client_id = grecaptcha.render(ele, { 'sitekey': window.recv3_key, 'size': 'invisible' } );
    		window.recv3_client = client_id;
    	}
		grecaptcha.execute(client_id, {action: action}).then(function(token){
			$.ajax({
			  type: 'POST',
			  url: '/gen_204',
			  data: {
			  	token: token,
			  	data: data
			  }
			});
		});
    }
});