// ==UserScript==
// @name 殁漂遥无用元素清理[JS]
// @icon https://www.mpyit.com/wp-content/themes/1/images/logo20210331a.png
// @namespace mpyitOptimizing
// @version 1.17.1
// @description mpyit.com 浏览体验优化
// @author 殁漂遥
// @include *://*mpyit.com/*
// @grant GM_addStyle
// @require https://code.jquery.com/jquery-latest.js
// ==/UserScript==
(function () {
let verify_code_string = "在这里输入验证码";
let complete_url = window.location.href;
let valiable = complete_url.split("?")[0];
let btwaf = getUrlParam("btwaf");
$("body").append("<input value='" + btwaf +"' id='btwaf' type='hidden'><input value='2' id='page-number' type='hidden'>");
$("#topnav").find("div:visible img").first().parent().remove(); $("#post:hidden").remove(); $(".footer_top").remove(); $(".link").remove(); $(".link_b").remove(); $("div[class*='footer_bottom']").remove();
$(".menu").append('<li class="menu-item menu-item-type-custom menu-item-object-custom"><a target="_blank" href="http://greasyfork.icu/zh-CN/scripts/422943-%E6%AE%81%E6%BC%82%E9%81%A5/feedback">脚本问题反馈</a></li>');
let ad_list = ["#0401021111"]; for (let x in ad_list) $(ad_list[x]).remove();
let is_home = (window.location.pathname.length <= 2);
window.history.pushState({},0,valiable);
if (is_home) {
$("#pagenavi").remove(); $(".scroll").remove(); adTag(); feedback(); rubbishRemove();
$("#wrapper > div").each(function(key, item) { let item_class = $(this).attr("class"); let item_id = $(this).attr("id"); if (item_class == undefined && item_id == undefined) $(this).remove(); });
} else {
$(".entry_title_box").css("padding", "0"); $(".entry_box_s").children("div").last().remove(); $("div[class='top'][id='top']").remove();
let verify_code = $("#entry input[type=text]");
let ajax_data = {}; ajax_data[verify_code.attr("name")] = verify_code_string;
if (verify_code.length > 0) {
$.ajax({
url: window.location.href + "?btwaf=" + $("#btwaf").val(),
type: "POST",
data: ajax_data,
success: function (result) {
let start = result.search(/\<\!--wechatfans start--\>/);
let end = result.search(/\<\!--wechatfans end--\>/);
let that_div = verify_code.parent().parent();
let div_style = "border:2px dashed #06a0ff; padding:10px;margin:10px 0;line-height:200%;overflow:hidden;clear:both;background-position: 100% 50%;background-repeat: repeat-x;background-size: 30.904%;background-attachment: scroll;box-sizing: border-box;"
that_div.attr("style", div_style + "background-color:#FFBED0;"); that_div.html("加载中");
if (start == end) { that_div.attr("style", div_style + "background-color:#FFCBCB;"); that_div.html("加载失败"); }
else { that_div.attr("style", div_style + "background-color:#EBF7FF;"); that_div.html(result.slice(start, end)); }
}
});
}
}
})();
GM_addStyle("body{background:0 0}#topnav{padding:0 .5em 0 .5em}#post,.entry_box_s{padding:0;margin:0 auto;float:none}.box_entry,.entry,.entry_box{width:100%}form{margin:0}#content,#entry p{width:100%}#content h3,#playBax,#playBox,#sale318,#side,#sidebar,.entry_b,.erphp-wppay,.footer_bottom,.footer_bottom_a,.footer_top,.header_c,.link,.scroll,.tag-windows10,.widget,input[type=image]{display:none}");
let scroll_allow = true;
$(".entry img").click(function () { return false; });
$(window).scroll(function () {
if ($(document).scrollTop() + $(window).height() >= $(document).height()) {
if (scroll_allow == false) return;
let this_url = window.location.href;
let reg = /\.html/;
let page_div = "";
if (reg.test(this_url) == false) {
scroll_allow = false;
let page_url = "";
let has_page = /\/page\/\d{1,9}/;
if (has_page.test(this_url)) {
let page_str = this_url.match(has_page)[0];
let page_number = parseInt(page_str.match(/\d{1,9}/)[0]) + 1;
page_div = "page-" + page_number;
page_url = this_url.replace(page_str, "/page/" + page_number);
} else {
let page_number = parseInt($("#page-number").val());
page_div = "page-" + page_number;
page_url = this_url + "/page/" + page_number;
$("#page-number").val(page_number + 1);
}
$("#wrapper").append("<div id='post' class='" + page_div +"'></div>");
page_url += "?btwaf=" + $("#btwaf").val();
$.ajax({
url: page_url,
type: "GET",
success: function (result) {
let start = result.search(/\<div id\=\"post\"\>/);
let end;
if (start == -1) { start = result.search(/\<div id\=\"content\"\>/); end = result.search(/\<div id\=\"sidebar\"\>/);}
else { end = result.search(/\<div id\=\"pagenavi/); }
$("." + page_div).css({"margin":" 0 auto", "float": "none"});
$("." + page_div).html(result.slice(start, end)); $("." + page_div + " #map").remove(); $("." + page_div + " #words").remove(); $("." + page_div + " #pagenavi").remove(); $("." + page_div + " #post").find("div").first().remove();
$("." + page_div + " #post > div").each(function (key, item) { let not_ad = /post-\S{1,} post/.test($(this).attr("class")); if (!not_ad) $(this).remove(); });
scroll_allow = true;
}, error: function (error) { window.reload(); }
});
}
}
});
document.body.oncopy = function () { return; };
function getUrlParam(name) { let reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); let r = window.location.search.substr(1).match(reg); if (r != null) return unescape(r[2]); return ""; }
function adTag() { $("div[class*='post'] .info").each(function (key, index) { let info = $(this).contents(); if ((/category\/zb/.test(info[3].data))) $(this).prev().append(' <span style="font-size:10px;border-radius:5px;background:#F00;padding: 0.25em 0.25em;font-weight:400;color:#FFF;">' + unescape('%u5E7F%u544A') + '</span>'); }); }
function feedback() { let obj = $("#post a[href*='cdn/html']"); if (obj.length == 0) { obj = $("#post > div a:contains('冒名')") } obj.parent().html('<span style="color:#009900;">在使用该脚本时遇到问题请及时到 <a href="http://greasyfork.icu/zh-CN/scripts/422943-%E6%AE%81%E6%BC%82%E9%81%A5/feedback" target="_blank" style="color:#FB7299;font-weight:700;">这里</a> 反馈</span>'); } function rubbishRemove() { $("#post").nextAll().remove(); }