MediaWiki:Common.js:修订间差异
Adminlinkbns(留言 | 贡献) 无编辑摘要 |
无编辑摘要 |
||
(未显示2个用户的94个中间版本) | |||
第354行: | 第354行: | ||
if (text.slice(-3).toLowerCase() !== '.js') text = text + '.js'; | if (text.slice(-3).toLowerCase() !== '.js') text = text + '.js'; | ||
//if ($x.data('debug') !== true) text = text + '&debug=false'; | //if ($x.data('debug') !== true) text = text + '&debug=false'; | ||
return mw.loader.load("//bnswiki.com | return mw.loader.load("//bnswiki.com/index.php?title=" + text + "&action=raw&ctype=text/javascript", "text/javascript"); | ||
}); | }); | ||
第457行: | 第457行: | ||
/* 轮播的js,勿动 */ | /* 轮播的js,勿动 */ | ||
mw.loader.load('https://cdn.jsdelivr.net/npm/swiper@11/swiper-bundle.min.css', "text/css"); | mw.loader.load('https://bnswiki.com/MediaWiki:Swiper.css?action=raw&ctype=text/css', "text/css"); | ||
//mw.loader.load('https://cdn.jsdelivr.net/npm/swiper@11/swiper-bundle.min.css', "text/css"); | |||
importScript('MediaWiki:Swiper.js'); | importScript('MediaWiki:Swiper.js'); | ||
if (document.querySelector('.my_swiper')){ | |||
var swiper = document.getElementsByClassName("my_swiper"); | |||
for (i = 0; i < swiper.length; i++){ | |||
if (swiper[i].querySelector('.my_swiper_wrapper').children.length > 10){ | |||
swiper[i].querySelector('.my_swiper_wrapper').innerHTML = "最多10张图片"; | |||
} | |||
} | |||
} | |||
/* 底部logo删除 */ | /* 底部logo删除 */ | ||
document.getElementById("footer-icons").style.display = "none"; | document.getElementById("footer-icons").style.display = "none"; | ||
第482行: | 第493行: | ||
while (i < jinengs.length){ | while (i < jinengs.length){ | ||
jineng = jinengs[i]; | jineng = jinengs[i]; | ||
//document.querySelector('.' + jineng.getAttribute("id")).style.display = "none"; | //document.querySelector('.' + jineng.getAttribute("id")).style.display = "none"; | ||
jineng.onclick = addclick(jineng) | jineng.onclick = addclick(jineng) | ||
第494行: | 第504行: | ||
if (document.getElementById("pt-userpage")){ | if (document.getElementById("pt-userpage")){ | ||
if (document.getElementById("pt-userpage").querySelector(".new").innerHTML != "Adminlinkbns"){ | if (document.getElementById("pt-userpage").querySelector(".new").innerHTML != "Adminlinkbns"){ | ||
document. | warnings = document.getElementsByClassName("warning"); | ||
i = 0; | |||
while (i < warnings.length){ | |||
warning = warnings[i]; | |||
warning.style.display = "none"; | |||
i += 1; | |||
} | |||
} | } | ||
}else{ | }else{ | ||
document.querySelector(". | warnings = document.getElementsByClassName("warning"); | ||
i = 0; | |||
while (i < warnings.length){ | |||
warning = warnings[i]; | |||
warning.style.display = "none"; | |||
i += 1; | |||
} | |||
} | |||
} | |||
/* 工具栏添加批量上传 */ | |||
if (document.querySelector(".dropdown-menu")){ | |||
menus = document.getElementsByClassName("dropdown-menu"); | |||
for (i = 0; i < menus.length; i++){ | |||
if (menus[i].getAttribute("aria-labelledby") == "工具"){ | |||
menus[i].innerHTML += '<li id="t-ups" class="mw-list-item"><a href="/特殊:BatchUpload">批量上传</a></li>'; | |||
} | |||
} | |||
} | |||
var request=new XMLHttpRequest();//建立request请求 | |||
request.open('post','/webData/add.php');//发送对象是boke.php 发送post | |||
request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');//请求头 默认即可 | |||
var uv = "isLogin=1" | |||
if (document.cookie.indexOf("isLogin") == -1){ | |||
document.cookie="isLogin=1"; | |||
uv = "isLogin=0" | |||
} | |||
request.send(uv);//发送request请求 | |||
//确认接收消息 | |||
request.onreadystatechange=function () { | |||
// readyState=4为php收到并返回值 status为返回字段为200火304 | |||
if(request.readyState==4&&(request.status==200||request.status==304)){ | |||
//弹出窗口显示php返回的值 | |||
console.log(request.responseText); | |||
if(document.querySelector(".uv_pv")){ | |||
nums = request.responseText.split("|"); | |||
document.querySelector(".uv").innerHTML = "本站浏览量:" + nums[0]; | |||
document.querySelector(".pv").innerHTML = "本站访问量:" + nums[1]; | |||
} | |||
} | |||
} | |||
function jifen(action,user,num,callback){ | |||
var request=new XMLHttpRequest();//建立request请求 | |||
request.open('GET','/webData/jifen.php?action='+action+'&user='+user+'&num='+num); | |||
request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');//请求头 默认即可 | |||
request.send();//发送request请求 | |||
//确认接收消息 | |||
request.onreadystatechange=function () { | |||
// readyState=4为php收到并返回值 status为返回字段为200火304 | |||
if(request.readyState==4&&(request.status==200||request.status==304)){ | |||
callback(request.responseText); | |||
} | |||
} | |||
} | |||
var user = ''; | |||
var isRun = false; | |||
if (document.querySelector("#pt-userpage")){ | |||
if (document.querySelector("#pt-userpage").querySelector(".new")){ | |||
user = document.querySelector("#pt-userpage").querySelector(".new").innerHTML; | |||
}else { | |||
user = document.querySelector("#pt-userpage").getElementsByTagName("a")[0].innerHTML; | |||
} | |||
var http1 = new XMLHttpRequest(); | |||
http1.open('GET', 'https:///bnswiki.com/api.php?action=query&list=users&ususers='+user+'&usprop=editcount&format=json'); | |||
http1.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');//请求头 默认即可 | |||
http1.send(); | |||
http1.onreadystatechange=function () { | |||
if(http1.readyState==4&&(http1.status==200||http1.status==304)){ | |||
var count1 = http1.responseText.split('"editcount":')[1]//.split('}')[0];//; | |||
count1 = count1.split('}')[0]; | |||
//console.log(count1); | |||
jifen('new', user, count1, function(a){}) | |||
isRun = true; | |||
} | |||
} | |||
}else{ | |||
console.log('a') | |||
} | |||
if (sessionStorage.getItem("isChanage")){ | |||
if (sessionStorage.getItem("isChanage") == "true"){ | |||
console.log("333"); | |||
sessionStorage.setItem("isChanage", "false"); | |||
var request1=new XMLHttpRequest();//建立request请求 | |||
request1.open('GET','/webData/jifen.php?action=add&user='+user); | |||
request1.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');//请求头 默认即可 | |||
request1.send();//发送request请求 | |||
//确认接收消息 | |||
request1.onreadystatechange=function () { | |||
// readyState=4为php收到并返回值 status为返回字段为200火304 | |||
if(request1.readyState==4&&(request1.status==200||request1.status==304)){ | |||
console.log("123"); | |||
} | |||
} | |||
} | |||
}else{ | |||
console.log("333"); | |||
sessionStorage.setItem("isChanage", "false"); | |||
} | |||
if (document.querySelector("#wpSave")){ | |||
document.querySelector("#wpSave").onclick = function(){ | |||
sessionStorage.setItem("isChanage", "true"); | |||
} | |||
} | |||
if (document.querySelector(".my_jifen1")){ | |||
document.querySelector(".my_jifen1").style.display = "inline"; | |||
document.querySelector(".my_jifen2").style.display = "inline"; | |||
var request2=new XMLHttpRequest();//建立request请求 | |||
request2.open('GET','/webData/jifen.php?action=my&user='+user); | |||
request2.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');//请求头 默认即可 | |||
request2.send();//发送request请求 | |||
//确认接收消息 | |||
request2.onreadystatechange=function () { | |||
// readyState=4为php收到并返回值 status为返回字段为200火304 | |||
if(request2.readyState==4&&(request2.status==200||request2.status==304)){ | |||
_jifen = request2.responseText.split('|'); | |||
document.querySelector(".my_jifen1").innerHTML = _jifen[1]; | |||
document.querySelector(".my_jifen2").innerHTML = _jifen[0]; | |||
} | |||
} | |||
} | |||
if (document.querySelector(".all_jifen1")){ | |||
var request3=new XMLHttpRequest();//建立request请求 | |||
request3.open('GET','/webData/jifen.php?action=all&user='+user); | |||
request3.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');//请求头 默认即可 | |||
request3.send();//发送request请求 | |||
//确认接收消息 | |||
request3.onreadystatechange=function () { | |||
// readyState=4为php收到并返回值 status为返回字段为200火304 | |||
if(request3.readyState==4&&(request3.status==200||request3.status==304)){ | |||
var all_jifen = request3.responseText.split('|b|'); | |||
var all_jifen1 = all_jifen[0].split('|a|'); | |||
var all_jifen2 = all_jifen[1].split('|a|'); | |||
for (i = 0; i < all_jifen1.length; i++){ | |||
if (all_jifen1[i].split(":")[0] !== "Moqi" && all_jifen1[i].split(":")[0] !== "Adminlinkbns" && all_jifen1[i].split(":")[0] !== "Admin" && all_jifen1[i].split(":")[0] !== "Test135"){ | |||
document.querySelector(".all_jifen1").innerHTML += '<div>'+ all_jifen1[i] +'</div>'; | |||
} | |||
} | |||
for (i = 0; i < all_jifen2.length; i++){ | |||
if (all_jifen2[i].split(":")[0] !== "Moqi" && all_jifen2[i].split(":")[0] !== "Adminlinkbns" && all_jifen2[i].split(":")[0] !== "Admin" && all_jifen2[i].split(":")[0] !== "Test135"){ | |||
document.querySelector(".all_jifen2").innerHTML += '<div>'+ all_jifen2[i] +'</div>'; | |||
} | |||
} | |||
} | |||
} | } | ||
} | } |
2024年7月30日 (二) 22:27的最新版本
/* 这里的任何JavaScript将为所有用户在每次页面加载时加载。 */ /* 这里的任何JavaScript将为所有用户在每次页面载入时加载。 */ // 判断是否触摸屏幕,强制设置ua if (navigator.maxTouchPoints && navigator.maxTouchPoints > 2) { Object.defineProperty(navigator, 'userAgent', { value: navigator.userAgent.replace('Macintosh', 'ipadpro'), writable: false }); }; $(function() { //解决手机上按键选项hover效果不消失的问题 //筛选页面列表筛选 $('.filter li').on('mouseenter touchstart',function(e) { $(this).children().addClass('hover'); }); $('.filter li').on('mouseleave touchend',function(e) { $(this).children().removeClass('hover'); }); $('.filter li').on('click',function(e) { $(this).siblings().children().removeClass('active'); $(this).children().toggleClass('active'); var item = new Array(); $('.filter').find('.active').parent().each(function() { var data_type = $(this).parent().attr('data-type'); item.push("[data-param" + data_type + "='" + $(this).attr("data-value") + "']"); }); if(item.length != 0) { $('#wiki_table tbody').children().hide(400); $('#wiki_table tbody').children(item.toString().replace(/,/g, '')).show(300); //$('#wiki_table tbody').children().not(item.toString().replace(/,/g, '')).hide(1000); } else { $('#wiki_table tbody').children().show(300); } }); }); $(function InitCardSelect() { var self = {}; var selectOptions; //所有筛选按钮 var filters = {}; //当前筛选规则 var filterKeys = []; //所有筛选Key var showAll = true; //不筛选,显示全部 var tableRows; //所有要被筛选的行 var computedRows; //筛选后的行 var $sorter; //当前进行排序的表头 var sortDesent = false; //反向排序 function isNil(s) { return s === '' || s === undefined || s === null || s === false } //点击筛选按钮时 function OnSelectOptionClick(e) { var $x = e.data; e.preventDefault(); var label = '['+$.trim($x.text())+'] 筛选'; console.time(label); //显示全部 if ($x.FilterKey == 0) { for (i in selectOptions) { selectOptions[i].Select = false; selectOptions[i].removeClass('selected'); } filters = {}; showAll = true; //更新表格 self.FilterRows(); console.timeEnd(label); return; } showAll = false; var select = !$x.Select; $x.Select = select; //变更筛选状态 var key = $x.FilterKey; filters[key] = filters[key] || {}; var opt = $x.FilterOpt == "AND" ? "AND" : "OR"; filters[key][opt] = filters[key][opt] || []; if (select) { filters[key][opt].push($x.FilterValue); } else { filters[key][opt] = filters[key][opt].filter(function(x) { return x !== $x.FilterValue; }); if (filters[key][opt].length < 1) delete filters[key][opt]; } select ? $x.addClass('selected') : $x.removeClass('selected'); self.FilterRows(); console.timeEnd(label); } function OnHeaderSortClick(e) { var $x = e.data; e.preventDefault(); var label = '['+$.trim($x.text())+'] 排序'; console.time(label); if ($sorter !== $x) { //第一次:新的排序 $sorter = $x; sortDesent = false; } else if (!sortDesent) { //第二次:切换排序 sortDesent = true; } else { //第三次:不进行排序 $sorter = null; } self.SortRows(); console.timeEnd(label); } //初始化 self.Init = function () { selectOptions = $('.cardSelectOption').toArray().map(function(x) { var $x = $(x); var dataOption = $.trim($x.data('option')); var dataGroup = $.trim($x.data('group')); if (isNil(dataOption) || isNil(dataGroup)) return $x; var splt = dataOption.split('|'); $x.FilterKey = dataGroup; $x.FilterValue = $.trim(splt[1]); $x.FilterOpt = $.trim($x.data('opt') || 'OR').toUpperCase(); if (filterKeys.indexOf(dataGroup) < 0) filterKeys.push(dataGroup); $x.click($x, OnSelectOptionClick); return $x; }); //$head = $('#CardSelectTabHeader'); tableRows = $('#CardSelectTr>tbody>tr').toArray().map( function(x) { var $x = $(x); //if (x == $head[0]) continue; for (i in filterKeys) { var key = filterKeys[i]; var val = $x.data('param'+key); if (val === undefined) continue; if (typeof val == 'number'){ val = val.toString(10); } var splt = val.split(','); for (j in splt) { var s = $.trim(splt[j]); if (!isNil(s)) { $x.FilterData = $x.FilterData || {}; $x.FilterData[key] = $x.FilterData[key] || []; $x.FilterData[key].push(s); } } } return $x; }); //computedRows = tableRows.concat([]); $('#CardSelectTr>thead>tr>th').each(function(index, x) { var $x = $(x); $x.off('click').off('mousedown'); if ($x.hasClass('headerSort')) { $x.Index = index; //$x.SortKey = $x.data('group'); $x.click($x, OnHeaderSortClick); } }); } //t1中包含t2中所有项 function includeAll(t1, t2) { for (i in t2) { if (t1.indexOf(t2[i]) < 0) return false; } return true; } //t1中包含t2中的任一项 function includeAny(t1, t2) { if (t2.length == 0) return true; for (i in t2) { if (t1.indexOf(t2[i]) > -1) return true; } return false; } //使用show/hide来显示表格行 self.FilterRows = function() { if (showAll) { filters = {}; } $('#CardSelectTr>tbody').hide(); for (var idx in tableRows) { var $x = tableRows[idx]; var data = $x.FilterData; var hide = false; for (key in filters) { hide = !data || !data[key]; if (!hide && filters[key]['AND']) { hide = !includeAll(data[key],filters[key]['AND']); } if (!hide && filters[key]['OR']) { hide = !includeAny(data[key],filters[key]['OR']); } if (hide) break; } if (!hide != !$x.Hide) { $x.Hide = hide; hide ? $x.hide() : $x.show(); } } $('#CardSelectTr .headerSort').removeClass('headerSortDown headerSortUp'); $('#CardSelectTr>tbody').show(); $sorter = null; } function grabSortData($tr, index) { $tr.SortData = $tr.SortData || []; if ($tr.SortData[index] !== undefined) return $tr.SortData[index]; var td = $tr.children('td')[index]; if (!td) { $tr.SortData[index] = -1; return -1; } var text = $.trim(td.textContent); $tr.SortData[index] = text; return text; } //对行排序,不显示的行会被移除 self.SortRows = function() { //var residues = []; if (!$sorter) { computedRows = tableRows.filter(function($x) { return !$x.Hide; }); $('#CardSelectTr .headerSort').removeClass('headerSortDown headerSortUp'); } else if (!sortDesent) { var index = $sorter.Index; computedRows = tableRows.filter(function($x) { return !$x.Hide; }); computedRows.sort(function compareFunction($x, $y) { var x = grabSortData($x, index); var y = grabSortData($y, index); var nx = + x; var ny = + y; return (isNaN(nx) || isNaN(ny)) ? isNaN(nx) && isNaN(ny) ? x < y ? -1 : 1 : isNaN(nx) ? 1 : -1 //字符串排后 : nx === ny ? 0 : nx < ny ? -1 : 1; //数值小的排前 //console.log (`${x} ~ ${y} => ${ret}`); //return ret; }); $('#CardSelectTr .headerSort').removeClass('headerSortDown headerSortUp'); $sorter.addClass('headerSortDown'); } else { computedRows.reverse(); $('#CardSelectTr .headerSort').removeClass('headerSortDown headerSortUp'); $sorter.addClass('headerSortUp'); } $('#CardSelectTr>tbody').hide() .prepend(computedRows) .show(); } $('.cardSelectOption').off('click').off('mousedown'); if ($('#CardSelectTabHeader').parent().is('tbody')){ $('#CardSelectTr').prepend( $('<thead/>').append($('#CardSelectTabHeader'))); } self.Init(); console.log('CardSelectTr.js Initialized.'); return self; }); /* -- 为页面加载JS脚本或CSS样式表 -- */ /* 参见[[模板:ResourceLoader]]*/ /* 来源:碧蓝航线WIKI*/ $('.resourceLoader').each(function () { var $x = $(this); var text = $.trim($x.text()); if (!text) return; //加载模块 if ($x.data('isModule') === true) return mw.loader.load(text); //自动补充MediaWiki命名空间 var ns = text.match('^.*?:'); if (!ns) text = 'MediaWiki:' + text; //加载CSS样式表 var mime = ($x.data('mime') || "text/javascript").toLowerCase(); if (mime == "text/css") { if (text.slice(-4).toLowerCase() !== '.css') text = text + '.css'; //if ($x.data('debug') !== true) text = text + '&debug=false'; return mw.loader.load("//bnswiki.com/index.php?title=" + text + "&action=raw&ctype=text/css", "text/css"); } //加载JS脚本 if (ns && ns[0].toLowerCase() !== 'mediawiki:') { return console.log('ResourceLoader: 不允许加载MediaWiki以外的js脚本'); } if (text.slice(-3).toLowerCase() !== '.js') text = text + '.js'; //if ($x.data('debug') !== true) text = text + '&debug=false'; return mw.loader.load("//bnswiki.com/index.php?title=" + text + "&action=raw&ctype=text/javascript", "text/javascript"); }); //音频事件 $('.audio-controls').click(function () { var audio = $(this).parent().find('audio').get(0); var controlBtn = $(this).find('.icon-btn'); audio.addEventListener('ended', function() { audio.currentTime = 0; audio.pause(); controlBtn.removeClass('icon-pause').addClass('icon-play'); }, false); // 监听播放完成事件 // 改变暂停/播放icon if (audio.paused) { audio.play(); controlBtn.removeClass('icon-play').addClass('icon-pause'); } else { audio.pause(); controlBtn.removeClass('icon-pause').addClass('icon-play'); } }) /* ==Popover弹出框== */ //找到Bootstrap初始化的jQuery function getjQuery(jquery) { var x = [jquery, $, window.$, window.jQuery]; var _j = window.$; for (var i = 0; i < 4; i++) { var j = x[i]; if (j && j.fn) { if (typeof j.fn.popover == 'function') return j; j.noConflict(); j = window.$; window.$ = _j; if (j && j.fn && typeof j.fn.popover == 'function') return j; } } throw('getjQuery:未能找到Bootstrap初始化的jQuery'); } $(function() { var $ = getjQuery(); $('[data-toggle="wafer-popover"]').popover({ container: false, content: function() { var $c = $(this); var content = '<p class="head">' + ($c.data('head') || '详细信息') + '</p>' + '<p>' + $c.data('text') + '</p>'; return content; }, html: true, placement: 'auto bottom', template: '<div class="popover wafer-popover" role="tooltip"><div class="arrow"></div><div class="popover-content"></div></div>', trigger: 'hover' }).find('a').attr('title',''); }); /* --Popover弹出框-- */ /* == 加载Bikit == */ try { mw.loader.load('//wiki.biligame.com/wiki/MediaWiki:Bikit.js?action=raw&ctype=text/javascript');} catch(e) {} /* -- 加载Bikit -- */ /* == 动态加载 == */ try { mw.loader.load('//wiki.biligame.com/wiki/MediaWiki:Asyncloader.js?action=raw&ctype=text/javascript');} catch(e) {} /* == 加载评论区头衔设置 == */ var avatarCheckboxSet={switch: true,} /* -- try { mw.loader.load("/tools/用户:16083703/BwikiAvatarFrameSet.js?action=raw&ctype=text/javascript", "text/javascript");} catch(e) {} -- */ /* -- 加载评论区头衔设置-- */ /* 技术处理外链 来源:异星工厂WIKI */ $("a").each(function(){ url=$(this).attr("href"); if(typeof(url)!="undefined"){ key=["filec.bnswiki.com","game.bilibili.com","space.bilibili.com","wiki.biligame.com","qun.qq.com","bnswiki.com"]; var status=false; key.forEach(function(k){ status=url.replace(/^.+linkfilter\/\?url=https*:\/\/([^\/]+).*$/ig, "$1").indexOf(k)>=0||status; }); url=status?url.replace(/^.+linkfilter\/\?url=(.+)/g, "$1"):url; $(this).attr("href",url); } }); /* 优化版本差异,爱来自 编辑组 Lu 39886146 */ mw.loader.load("/tools/MediaWiki:DiffTool.js?action=raw&ctype=text/javascript&rand=", "text/javascript"); /* 20240318新加入 */ /* 打开页面使用新的页面 */ document.addEventListener('DOMContentLoaded', function() { var links = document.querySelectorAll('a[href^="/wiki/"]'); links.forEach(function(link) { link.target = '_blank'; }); }); /* 轮播的js,勿动 */ mw.loader.load('https://bnswiki.com/MediaWiki:Swiper.css?action=raw&ctype=text/css', "text/css"); //mw.loader.load('https://cdn.jsdelivr.net/npm/swiper@11/swiper-bundle.min.css', "text/css"); importScript('MediaWiki:Swiper.js'); if (document.querySelector('.my_swiper')){ var swiper = document.getElementsByClassName("my_swiper"); for (i = 0; i < swiper.length; i++){ if (swiper[i].querySelector('.my_swiper_wrapper').children.length > 10){ swiper[i].querySelector('.my_swiper_wrapper').innerHTML = "最多10张图片"; } } } /* 底部logo删除 */ document.getElementById("footer-icons").style.display = "none"; /* 搜索默认 内容页面 */ document.getElementById("searchform").innerHTML += '<input type="hidden" name="profile" title="搜索默认类型" value="default">'; if (document.getElementById("nav-searchform")){ document.getElementById("nav-searchform").innerHTML += '<input type="hidden" name="profile" title="搜索默认类型" value="default">'; } /* 技能列表的js */ function addclick(a){ return function(){ document.querySelector('.jinengshuoming').innerHTML = "" + document.querySelector('.' + a.getAttribute("id")).innerHTML; document.querySelector('.jinengshuoming').style.display = "block"; document.querySelector('.jinengshuoming').className = "mw-collapsible jinengshuoming mw-made-collapsible"; } } var jinengs = document.getElementsByClassName("jineng"); if (jinengs.length > 0 || jinengs != null){ i = 0; addHtml = []; while (i < jinengs.length){ jineng = jinengs[i]; //document.querySelector('.' + jineng.getAttribute("id")).style.display = "none"; jineng.onclick = addclick(jineng) i += 1; } } /* 忽略warning */ if (document.querySelector(".warning")){ console.log("aa") if (document.getElementById("pt-userpage")){ if (document.getElementById("pt-userpage").querySelector(".new").innerHTML != "Adminlinkbns"){ warnings = document.getElementsByClassName("warning"); i = 0; while (i < warnings.length){ warning = warnings[i]; warning.style.display = "none"; i += 1; } } }else{ warnings = document.getElementsByClassName("warning"); i = 0; while (i < warnings.length){ warning = warnings[i]; warning.style.display = "none"; i += 1; } } } /* 工具栏添加批量上传 */ if (document.querySelector(".dropdown-menu")){ menus = document.getElementsByClassName("dropdown-menu"); for (i = 0; i < menus.length; i++){ if (menus[i].getAttribute("aria-labelledby") == "工具"){ menus[i].innerHTML += '<li id="t-ups" class="mw-list-item"><a href="/特殊:BatchUpload">批量上传</a></li>'; } } } var request=new XMLHttpRequest();//建立request请求 request.open('post','/webData/add.php');//发送对象是boke.php 发送post request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');//请求头 默认即可 var uv = "isLogin=1" if (document.cookie.indexOf("isLogin") == -1){ document.cookie="isLogin=1"; uv = "isLogin=0" } request.send(uv);//发送request请求 //确认接收消息 request.onreadystatechange=function () { // readyState=4为php收到并返回值 status为返回字段为200火304 if(request.readyState==4&&(request.status==200||request.status==304)){ //弹出窗口显示php返回的值 console.log(request.responseText); if(document.querySelector(".uv_pv")){ nums = request.responseText.split("|"); document.querySelector(".uv").innerHTML = "本站浏览量:" + nums[0]; document.querySelector(".pv").innerHTML = "本站访问量:" + nums[1]; } } } function jifen(action,user,num,callback){ var request=new XMLHttpRequest();//建立request请求 request.open('GET','/webData/jifen.php?action='+action+'&user='+user+'&num='+num); request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');//请求头 默认即可 request.send();//发送request请求 //确认接收消息 request.onreadystatechange=function () { // readyState=4为php收到并返回值 status为返回字段为200火304 if(request.readyState==4&&(request.status==200||request.status==304)){ callback(request.responseText); } } } var user = ''; var isRun = false; if (document.querySelector("#pt-userpage")){ if (document.querySelector("#pt-userpage").querySelector(".new")){ user = document.querySelector("#pt-userpage").querySelector(".new").innerHTML; }else { user = document.querySelector("#pt-userpage").getElementsByTagName("a")[0].innerHTML; } var http1 = new XMLHttpRequest(); http1.open('GET', 'https:///bnswiki.com/api.php?action=query&list=users&ususers='+user+'&usprop=editcount&format=json'); http1.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');//请求头 默认即可 http1.send(); http1.onreadystatechange=function () { if(http1.readyState==4&&(http1.status==200||http1.status==304)){ var count1 = http1.responseText.split('"editcount":')[1]//.split('}')[0];//; count1 = count1.split('}')[0]; //console.log(count1); jifen('new', user, count1, function(a){}) isRun = true; } } }else{ console.log('a') } if (sessionStorage.getItem("isChanage")){ if (sessionStorage.getItem("isChanage") == "true"){ console.log("333"); sessionStorage.setItem("isChanage", "false"); var request1=new XMLHttpRequest();//建立request请求 request1.open('GET','/webData/jifen.php?action=add&user='+user); request1.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');//请求头 默认即可 request1.send();//发送request请求 //确认接收消息 request1.onreadystatechange=function () { // readyState=4为php收到并返回值 status为返回字段为200火304 if(request1.readyState==4&&(request1.status==200||request1.status==304)){ console.log("123"); } } } }else{ console.log("333"); sessionStorage.setItem("isChanage", "false"); } if (document.querySelector("#wpSave")){ document.querySelector("#wpSave").onclick = function(){ sessionStorage.setItem("isChanage", "true"); } } if (document.querySelector(".my_jifen1")){ document.querySelector(".my_jifen1").style.display = "inline"; document.querySelector(".my_jifen2").style.display = "inline"; var request2=new XMLHttpRequest();//建立request请求 request2.open('GET','/webData/jifen.php?action=my&user='+user); request2.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');//请求头 默认即可 request2.send();//发送request请求 //确认接收消息 request2.onreadystatechange=function () { // readyState=4为php收到并返回值 status为返回字段为200火304 if(request2.readyState==4&&(request2.status==200||request2.status==304)){ _jifen = request2.responseText.split('|'); document.querySelector(".my_jifen1").innerHTML = _jifen[1]; document.querySelector(".my_jifen2").innerHTML = _jifen[0]; } } } if (document.querySelector(".all_jifen1")){ var request3=new XMLHttpRequest();//建立request请求 request3.open('GET','/webData/jifen.php?action=all&user='+user); request3.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');//请求头 默认即可 request3.send();//发送request请求 //确认接收消息 request3.onreadystatechange=function () { // readyState=4为php收到并返回值 status为返回字段为200火304 if(request3.readyState==4&&(request3.status==200||request3.status==304)){ var all_jifen = request3.responseText.split('|b|'); var all_jifen1 = all_jifen[0].split('|a|'); var all_jifen2 = all_jifen[1].split('|a|'); for (i = 0; i < all_jifen1.length; i++){ if (all_jifen1[i].split(":")[0] !== "Moqi" && all_jifen1[i].split(":")[0] !== "Adminlinkbns" && all_jifen1[i].split(":")[0] !== "Admin" && all_jifen1[i].split(":")[0] !== "Test135"){ document.querySelector(".all_jifen1").innerHTML += '<div>'+ all_jifen1[i] +'</div>'; } } for (i = 0; i < all_jifen2.length; i++){ if (all_jifen2[i].split(":")[0] !== "Moqi" && all_jifen2[i].split(":")[0] !== "Adminlinkbns" && all_jifen2[i].split(":")[0] !== "Admin" && all_jifen2[i].split(":")[0] !== "Test135"){ document.querySelector(".all_jifen2").innerHTML += '<div>'+ all_jifen2[i] +'</div>'; } } } } }