您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
smzdm user block 什么值得买 原创页面营销号屏蔽
当前为
// ==UserScript== // @name smzdm block // @namespace http://blog.ywwzwb.pw/ // @version 0.4 // @description smzdm user block 什么值得买 原创页面营销号屏蔽 // @author ywwzwb // @match https://post.smzdm.com/* // @match https://zhiyou.smzdm.com/member/* // @grant GM_xmlhttpRequest // @grant GM_setValue // @grant GM_getValue // @grant GM_listValues // @connect smzdm.com // ==/UserScript== (function () { 'use strict'; addSettingBtn(); addSettingDiv(); var customCSS = ` .icon-block-left { width: 16px; height: 16px; fill: currentColor } .left-layer>div.J_block{ height: auto; padding-bottom: 6px } .feed-grid-wrap #feed-main-list a.z-group-data.card-icon-with-block { width: 70px; padding-left: 0px; text-align: center; } .icon-block-card { width: 16px; height: 16px; fill: currentColor; vertical-align: top; margin-top: 1px; margin-right: 5px; } .icon-block-homepage { width: 16px; height: 16px; fill: #e62828; vertical-align: top; margin-top: 5px; margin-right: 3px; margin-left: 5px; } a.block-homepage.focus-other { width:auto; margin-left:10px; } a.block-homepage>span { margin-right:5px; color:currentColor; } .block-setting-box-bg { position: fixed; top: 0; right: 0; bottom: 0; left: 0; background: rgba(0,0,0,.5); z-index: 9999; display: none; } .block-setting-box { width: 80%; z-index: 10000; position: fixed; left: 10%; top: 10%; bottom:10%; background-color: #fff; } .block-setting-box-head-close:hover { fill: #e62828 } .block-setting-box-head-close { width: 32px; float: right; padding-top: 6px; padding-bottom: 6px; } .block-setting-box-head-title { font-size: 16px; color: #333; float: left; } .block-setting-box-head { height: 44px; line-height: 45px; padding: 0 14px; border-bottom: 1px solid #f5f5f5; } .block-setting-box-content-ul { box-sizing: border-box; margin-top: 10px; padding: 0 10px; width: 100%; height: calc(100% - 110px); overflow-y: scroll; display: flex; flex-wrap: wrap; align-content: flex-start; border-bottom: 1px solid #f5f5f5; } .block-setting-box-content-li { float: left; margin-top: 5px; margin-bottom: 5px; margin-left: 10px; margin-right: 10px; width: calc(33.3% - 20px); height:92px; box-shadow: 1px 1px 2px 1px rgba(0, 0, 0, .2); border-radius: 4px; } .block-setting-box-content-li-user-left { float: left; width: 84px; height: 84px; margin-right: 14px; font-size: 0; text-align: center; overflow: hidden; margin-top: 5px; margin-left: 7px; } .block-setting-box-content-li-user-right { float: left; width: 80; height: 80px; } .block-setting-box-content-li-user-avatar { border-radius: 100%; overflow: hidden; width: 100%; height: auto } .block-setting-box-content-li-user-title { font-size: 14px; color: #333; line-height: 24px; height: 48px; display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; } .block-setting-box-content-li-user-block-btn { margin-top: 8px; margin-bottom: 8px; display: inline-block; line-height: 26px; border: 1px solid #fee4e4; text-align: center; width: 66px; color: #e62828; border-radius: 2px; background: #feecec; } .block-setting-box .pagenation-list-self { text-align: center; cursor: pointer; margin-bottom: 10px; margin-top: 10px; } .pagenation-list-self { font-size: 0 } .pagenation-list-self li { display: inline-block; width: 30px; height: 30px; line-height: 30px; margin: 0 5px; color: #666; font-size: 14px; border-radius: 2px; background: #f7f7f7; overflow: hidden } .pagenation-list-self li a,.pagenation-list-self li span { display: block; width: 100%; height: 100%; color: #666 } .pagenation-list-self li.current,.pagenation-list-self li.current a,.pagenation-list-self li.page-number:hover,.pagenation-list-self li.page-turn:hover,.pagenation-list-self li a:hover { background-color: #e62828; color: #fff } .pagenation-list-self li i { font-size: 12px } #search-self{ height:24px; line-height:24px; margin-left:20px; background-color: #f5f5f5; border:0; color:#333; padding:2px 10px; border-radius:4px; } ` var styleSheet = document.createElement('style') styleSheet.type = 'text/css' styleSheet.innerText = customCSS document.head.appendChild(styleSheet) var blockTitleKeyWords = [ // '评测', 'hifi', '体验', '开箱', '测评', '耳机', '简评', '保险', '信用卡', // '上手', '社保', '也太好吃', '好?', '小小值' ]; var blocUserWords = [ // '值友', '数码', '科技', '之家', '耳机', '玩机', '达人', '工坊', '极客', // '小小值' ]; // 初始化数据库 if (window.location.href.startsWith('https://post.smzdm.com/p/')) { // post addBlockInPost(); return; } if (window.location.href.startsWith('https://zhiyou.smzdm.com/member/')) { // homepage addBlockInHomepage(); return; } refreshArticalList(); $(document).ajaxComplete(function (event, xhr, settings) { // 下拉加载时屏蔽 if (settings.url.startsWith('https://post.smzdm.com/json_more')) { refreshArticalList(); } }); // 刷新界面, 屏蔽特定的文章 function refreshArticalList() { $.each($('#feed-main-list>li'), function (index, obj) { // 屏蔽众测广告 if (isZhongce(obj)) { $(obj).remove(); return; } // 屏蔽晒物 if (isShaiwu(obj)) { $(obj).remove(); return; } // 屏蔽评测文章 if (isPingce(obj)) { $(obj).remove(); return; } // 屏蔽媒体号 if (isMediaAccountSimple(obj)) { $(obj).remove(); return; } // 屏蔽标题关键字 if (hasTitleKeyWord(obj)) { $(obj).remove(); return; } // 屏蔽用户名关键字 if (hasUserKeyWord(obj)) { $(obj).remove(); return; } // 查询屏蔽数据库 var uinfo = getUserForLi(obj); if (!uinfo) { return; } // 屏蔽垃圾营销号 // 从数据库中查找垃圾账号 uinfo = GM_getValue(uinfo.uid, uinfo); if (uinfo.flag == 0) { // 未知用户, 检查用户信息 testSpammer(uinfo.uid, function (isSpammer, error) { if (error) { return; } // 垃圾账户, 屏蔽 if (isSpammer) { uinfo.flag = 1; $(obj).remove(); } else { // 普通账户, 添加屏蔽按钮 uinfo.flag = 2; if ($(obj).find('.card-block').length == 0) { addBlockBtnTo(obj); } } GM_setValue(uinfo.uid, uinfo); }) } else if (uinfo.flag == 1) { // 设定为屏蔽的用户 $(obj).remove(); return; } else { // 普通账户, 添加屏蔽按钮 if ($(obj).find('.card-block').length == 0) { addBlockBtnTo(obj); } } }); } // 标题关键字屏蔽 function hasTitleKeyWord(item) { var title = $(item).find('.z-feed-title').text(); for (var i = 0; i < blockTitleKeyWords.length; i++) { if (title.includes(blockTitleKeyWords[i])) { return true; } } return false; } // 用户关键字屏蔽 function hasUserKeyWord(item) { var username = $(item).find('.z-avatar-name').text(); for (var i = 0; i < blocUserWords.length; i++) { if (username.includes(blocUserWords[i])) { return true; } } return false; } // 众测软文屏蔽 function isZhongce(item) { return $(item).find('.z-tag-sticky').text().trim() == '众测'; } // 晒物文章屏蔽 function isShaiwu(item) { return $(item).find('.z-tag-sticky').text().trim() == '晒物'; } // 评测文章屏蔽 function isPingce(item) { return $(item).find('.z-tag-sticky').text().trim() == '评测'; } // 判断媒体账号, 简易版 function isMediaAccountSimple(item) { var imgsrc = $(item).find('.feed-talent-ordinary').attr('src'); return imgsrc && imgsrc.includes('media_medal'); } // 检查用户是否是垃圾账号 function testSpammer(uid, cb) { GM_xmlhttpRequest({ method: 'POST', url: 'https://api.smzdm.com/users/info', data: 'user_smzdm_id=' + uid, headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' }, responseType: 'json', onload: response => { var data = response.response; if (parseInt(data.error_code) != 0) { cb(false, true) return; } // 媒体号 if (parseInt(data.data.role.is_media) != 0) { cb(true, false); return; } // 官方号 if (parseInt(data.data.role.is_official) != 0) { cb(true, false); return; } // 运营号 if (parseInt(data.data.role.is_merchant) != 0) { cb(true, false); return; } // 评论 / 文章 < 5 or 评论 == 0 则是营销号 var articalsCount = parseInt(data.data.articles.article); var commentsCount = parseInt(data.data.comments); if (commentsCount == 0 || commentsCount / articalsCount < 5) { cb(true, false); return; } cb(false, false); }, onerror: response => { cb(false, true) } }); } // 获取用户信息 function getUserForLi(li_item) { var a = $(li_item).find('.z-feed-foot-l .z-avatar-name'); var uname = a.text().trim(); var href = a.attr('href'); if (!href) { return null; } var uidResult = /\/(\d+)\/?$/.exec(href); if (!uidResult) { return null; } var uicon = $(li_item).find('.z-feed-foot-l .z-avatar-pic>img') .attr('src') .replace('-small.', '-middle.'); return { 'uid': uidResult[1], 'uname': uname, 'uicon': uicon, 'flag': 0 }; } // 文章列表页面屏蔽按钮 function addBlockBtnTo(item) { $(item).find('.z-feed-foot-r').children('a').addClass('card-icon-with-block'); var a = $(`<a class='z-group-data card-icon-with-block' title='屏蔽'></a>`); var blockIcon = $(` <svg class='icon-block-card' version="1.1" xmlns="http://www.w3.org/2000/svg" viewBox = "0 0 1024 1024" > <path d="M202.666667 256h-42.666667a32 32 0 0 1 0-64h704a32 32 0 0 1 0 64H266.666667v565.333333a53.333333 53.333333 0 0 0 53.333333 53.333334h384a53.333333 53.333333 0 0 0 53.333333-53.333334V352a32 32 0 0 1 64 0v469.333333c0 64.8-52.533333 117.333333-117.333333 117.333334H320c-64.8 0-117.333333-52.533333-117.333333-117.333334V256z m224-106.666667a32 32 0 0 1 0-64h170.666666a32 32 0 0 1 0 64H426.666667z m-32 288a32 32 0 0 1 64 0v256a32 32 0 0 1-64 0V437.333333z m170.666666 0a32 32 0 0 1 64 0v256a32 32 0 0 1-64 0V437.333333z" p-id="2813"></path> </svg>`); var span = $(`<span>屏蔽</span>`) a.append(blockIcon); a.append(span); $(item).find('.z-feed-foot-r').append(a); a.click(function () { var li = a.parents('li'); var uinfo = getUserForLi(li); $(item).remove(); if (uinfo) { uinfo.flag = 1; GM_setValue(uinfo.uid, uinfo); } }); } // 文章内部屏蔽按钮 function addBlockInPost() { if ($('.author-title').length == 0) { return; } var authorA = $($('.author-title')[0]); var authorHref = authorA.attr('href'); if (!authorHref) { return null; } var uidResult = /\/(\d+)\/?$/.exec(authorHref); if (!uidResult || uidResult.length < 2) { return null; } var uid = uidResult[1]; var uname = authorA.text().trim(); ''.replace( ', ', ) var uicon = $('.tx_name>img').attr('src').replace('-big.', '-middle.'); var user = GM_getValue(uid, { 'uid': uid, 'uname': uname, 'uicon': uicon, 'flag': 0 }); user['uicon'] = uicon; GM_setValue(uid, user); var blockIcon = $(` <svg class='icon-block-left' version="1.1" xmlns="http://www.w3.org/2000/svg" viewBox = "0 0 1024 1024" > <path d="M202.666667 256h-42.666667a32 32 0 0 1 0-64h704a32 32 0 0 1 0 64H266.666667v565.333333a53.333333 53.333333 0 0 0 53.333333 53.333334h384a53.333333 53.333333 0 0 0 53.333333-53.333334V352a32 32 0 0 1 64 0v469.333333c0 64.8-52.533333 117.333333-117.333333 117.333334H320c-64.8 0-117.333333-52.533333-117.333333-117.333334V256z m224-106.666667a32 32 0 0 1 0-64h170.666666a32 32 0 0 1 0 64H426.666667z m-32 288a32 32 0 0 1 64 0v256a32 32 0 0 1-64 0V437.333333z m170.666666 0a32 32 0 0 1 64 0v256a32 32 0 0 1-64 0V437.333333z" p-id="2813"></path> </svg>`); var span = $(`<span>屏蔽</span>`) var isBlock = false; if (user.flag == 1) { span.html('取消<br/>屏蔽') isBlock = true; } var div = $('<div class="J_block comment"> </div>'); div.append(blockIcon); div.append(span); $('.qrcode').before(div) div.attr('data-block', isBlock); div.click(function () { var isBlock = $(this).attr('data-block') == 'true' isBlock = !isBlock; $(this).attr('data-block', isBlock); if (isBlock) { span.html('取消<br/>屏蔽') } else { span.html('屏蔽') } user.flag = (isBlock ? 1 : 2); gm_set_value(uid, user); }); }; // 用户首页屏蔽按钮 function addBlockInHomepage() { if ($('.info-stuff-nickname>a').length == 0) { return; } var authorA = $('.info-stuff-nickname>a'); var authorHref = authorA.attr('href'); if (!authorHref) { return null; } var uidResult = /\/(\d+)\/?$/.exec(authorHref); if (!uidResult || uidResult.length < 2) { return null; } var uid = uidResult[1]; var uname = authorA.text().trim(); var uicon = $('.avatar-box>img').attr('src'); var user = GM_getValue(uid, { 'uid': uid, 'uname': uname, 'uicon': uicon, 'flag': 0 }); user['uicon'] = uicon; GM_setValue(uid, user); var blockIcon = $(` <svg class='icon-block-homepage' version="1.1" xmlns="http://www.w3.org/2000/svg" viewBox = "0 0 1024 1024" > <path d="M202.666667 256h-42.666667a32 32 0 0 1 0-64h704a32 32 0 0 1 0 64H266.666667v565.333333a53.333333 53.333333 0 0 0 53.333333 53.333334h384a53.333333 53.333333 0 0 0 53.333333-53.333334V352a32 32 0 0 1 64 0v469.333333c0 64.8-52.533333 117.333333-117.333333 117.333334H320c-64.8 0-117.333333-52.533333-117.333333-117.333334V256z m224-106.666667a32 32 0 0 1 0-64h170.666666a32 32 0 0 1 0 64H426.666667z m-32 288a32 32 0 0 1 64 0v256a32 32 0 0 1-64 0V437.333333z m170.666666 0a32 32 0 0 1 64 0v256a32 32 0 0 1-64 0V437.333333z" p-id="2813"></path> </svg>`); var a = $(`<a class="focus-other block-homepage"></a>`); var span = $(`<span>屏蔽</span>`) var isBlock = false; if (user.flag == 1) { span.html('取消屏蔽') isBlock = true; } a.append(blockIcon); a.append(span); $('.info-stuff-set').append(a) a.attr('data-block', isBlock); a.click(function () { var isBlock = $(this).attr('data-block') == 'true' isBlock = !isBlock; $(this).attr('data-block', isBlock); if (isBlock) { span.text('取消屏蔽'); } else { span.text('屏蔽'); } user.flag = (isBlock ? 1 : 2); GM_setValue(uid, user); }); }; // 添加屏蔽设置按钮 function addSettingBtn() { var li = $(` <li> <span class="elevator-report">屏蔽<br>设置</span> </li>`); $('#elevator>.back-top').before(li); li.click(function () { $('.block-setting-box-bg').show(); $('#search-self').val(""); setPageDataForSettingBox(1, 12, 1, ''); }); }; // 添加设置框 function addSettingDiv() { var bg = $(`<div class="block-setting-box-bg"></div>`); var box = $(`<div class="block-setting-box"></div>`); var boxHead = $(`<div class="block-setting-box-head"></div>`); var closeIcon = $(` <svg class='block-setting-box-head-close' version="1.1" xmlns="http://www.w3.org/2000/svg" viewBox = "0 0 1024 1024" > <path d="M676.44928 688.042667L542.17728 553.813333 675.510613 420.437333a21.290667 21.290667 0 0 0 0-30.165333 21.290667 21.290667 0 0 0-30.165333 0L512.011947 523.605333 378.635947 390.272a21.333333 21.333333 0 1 0-30.208 30.165333L481.846613 553.813333 347.574613 688.042667a21.333333 21.333333 0 0 0 30.208 30.165333L512.011947 583.978667l134.229333 134.229333a21.248 21.248 0 0 0 30.208 0 21.333333 21.333333 0 0 0 0-30.165333" p-id="3802"></path> </svg>`); var title = $( `<span class="block-setting-box-head-title">屏蔽设置</span><input id="search-self" type="text" value="" placeholder="筛选"/>`); var contentul = $( `<ul class="block-setting-box-content-ul" id="block-setting-content"></ul>`); var pageul = $(`<ul class="pagenation-list-self" id="block-setting-page"></ul>`); boxHead.append(title); boxHead.append(closeIcon); box.append(boxHead); box.append(contentul); box.append(pageul); bg.append(box); $('body').append(bg); closeIcon.click(function () { $('.block-setting-box-bg').hide(); }); $('#search-self').keyup(function (e) { var value = e.target.value; setPageDataForSettingBox(1, 12, 1, value); }) } function setPageDataForSettingBox( page /*: int*/, pageSize /*: int*/, blockTypeFilter /*: int*/, usernameFilter /*: string*/) { if (page <= 0) { page = 1 } if (pageSize <= 0) { pageSize = 10; } $('#block-setting-content').empty(); $('#block-setting-page').empty(); var allValue = []; for (var id of GM_listValues()) { allValue.push(GM_getValue(id)); } if (blockTypeFilter != -1) { var tmp = []; for (var i = 0; i < allValue.length; i++) { if (allValue[i].flag == blockTypeFilter) { tmp.push(allValue[i]); } } allValue = tmp; } if (usernameFilter != '') { var tmp = []; for (var i = 0; i < allValue.length; i++) { if (allValue[i].uname.includes(usernameFilter)) { tmp.push(allValue[i]); } } allValue = tmp; } var startPostion = (page - 1) * pageSize; var pageData = []; for (var i = startPostion; i < allValue.length && i < startPostion + pageSize; i++) { pageData.push(allValue[i]); } for (var i = 0; i < pageData.length; i++) { let user = pageData[i]; let img = $(`<img class="block-setting-box-content-li-user-avatar"></img>`); if (!('uicon' in user)) { getICONForUser(user.uid, function (success, url) { img.attr('src', url); if (success) { user['uicon'] = url; GM_setValue(user.uid, user); } }); } else { img.attr('src', user['uicon']); } let imga = $(`<a class="block-setting-box-content-li-user-left"></a>`); imga.attr('href', 'https://zhiyou.smzdm.com/member/' + user['uid']); imga.append(img); let title = $(`<a class="block-setting-box-content-li-user-title"></a>`); title.text(user.uname); title.attr('href', 'https://zhiyou.smzdm.com/member/' + user['uid']); let blockBtn = $(`<a class="block-setting-box-content-li-user-block-btn"></a>`); let btnSpan = $(`<span></span>`); if (user.flag == 1) { btnSpan.text('取消屏蔽') } else { btnSpan.text('屏蔽'); } blockBtn.append(btnSpan); let li = $(`<li class="block-setting-box-content-li"></li>`); li.append(imga); let userRight = $(`<div class=""block-setting-box-content-li-user-right"></div>`); userRight.append(title); userRight.append(blockBtn); li.append(userRight); btnSpan.click(function () { if (user.flag == 1) { user.flag = 2; btnSpan.text('屏蔽'); } else { user.flag = 1; btnSpan.text('取消屏蔽') } GM_setValue(user.uid, user); }); $('#block-setting-content').append(li); } let pageCount = Math.ceil(allValue.length / pageSize); let maxPagerCount = 5; let pagerStart = page - parseInt((maxPagerCount / 2)); if (pagerStart <= 0) { pagerStart = 1; } let pagerEnd = pagerStart + maxPagerCount; if (pagerEnd > pageCount) { pagerEnd = pageCount; } if (pagerStart != 1) { let lastPage = $(`<li class=""><i class="icon-angle-left-o-thin"></i></li>`); $('#block-setting-page').append(lastPage); lastPage.click(function () { setPageDataForSettingBox( page - 1, pageSize, blockTypeFilter, usernameFilter); }); let firstPage = $(`<li class="page-number">1</li>`); $('#block-setting-page').append(firstPage); firstPage.click(function () { setPageDataForSettingBox(1, pageSize, blockTypeFilter, usernameFilter); }); $(`<li class=""><i class="icon-angle-left-o-thin"></i></li>`); $('#block-setting-page').append($(`<li class="noHover">...</li>`)); } for (let i = pagerStart; i <= pagerEnd; i++) { let pager = $(`<li class="page-number"></li>`); pager.text(i); if (i == page) { pager.addClass('current'); } pager.click(function () { setPageDataForSettingBox(i, pageSize, blockTypeFilter, usernameFilter); }); $('#block-setting-page').append(pager); } if (pagerEnd != pageCount) { $(`<li class=""><i class="icon-angle-left-o-thin"></i></li>`); $('#block-setting-page').append($(`<li class="noHover">...</li>`)); let nextPage = $( `<li class="page-turn next-page"><i class="icon-angle-right-o-thin"></i></li>`); $('#block-setting-page').append(nextPage); nextPage.click(function () { setPageDataForSettingBox( page + 1, pageSize, blockTypeFilter, usernameFilter); }); } } function getICONForUser(uid, cb) { GM_xmlhttpRequest({ method: 'POST', url: 'https://api.smzdm.com/users/info', data: 'user_smzdm_id=' + uid, headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' }, responseType: 'json', onload: response => { var data = response.response; if (parseInt(data.error_code) != 0) { cb(false, 'https://res.smzdm.com/images/user_logo/default_avatar/5-middle.png'); return; } cb(true, data.data.meta.avatar); }, onerror: response => { cb(false, 'https://res.smzdm.com/images/user_logo/default_avatar/5-middle.png'); } }); } })();