// ==UserScript== // @name 什么值得黑 // @namespace http://tampermonkey.net/ // @version 0.1 // @description 什么值得买网站助手 一键 收藏 点赞 评论 页面优化增强 兴趣使然的给张大妈擦屁股 :) // @author cuteribs // @match https://post.smzdm.com/* // @match https://test.smzdm.com/* // @match https://zhiyou.smzdm.com/* // @grant GM.xmlHttpRequest // @icon https://www.smzdm.com/favicon.ico // @downloadURL none // ==/UserScript== (function () { const addGlobalStyle = css => { $('').html(css).appendTo($('head')); }; const styles = ` * { font-family: 'PingFang SC','Hiragino Sans GB','Microsoft YaHei','Open Sans',sans-serif } #global-search { height: auto; } #global-search .search-inner { padding: 0; } #sub-head { display: none; } .feed-hot-hits .feed-top-hot, .feed-hot-index .feed-top-hot { float: inherit; } .feed-top-hot { width: auto; } .feed-top-hot .feed-hot-wrap { height: auto; margin: 0 11px; } .feed-hot-hits .feed-hot-item, .feed-hot-index .feed-hot-item { height: auto; } .feed-top-hot .feed-hot-list { width: auto; height: auto; } .feed-hot-hits .feed-hot-list .slick-list, .feed-hot-index .feed-hot-list .slick-list { width: auto; } .feed-top-hot .feed-hot-list .feed-hot-card { width: 287px; margin-right: 10px; } .feed-hot-list .feed-hot-card .feed-hot-pic { width: auto; height: auto; } .feed-hot-list .feed-hot-card .feed-hot-pic img { max-width: 100%; max-height: 100%; } .feed-hot-wrap .z-slick-btn-next { right: 0; } .feed-hot-wrap .slick-arrow { top: 75px; } .feed-right-top { display: none; } .filter-feed-wrap { width: auto; } .filter-tab-wrap { width: auto; } .primary-filter-tab-wrapper { width: auto; } .primary-filter-tab { width: auto; } .feed-grid-wrap #feed-main-list { width: auto; } .feed-grid-wrap #feed-main-list .feed-row-wide { margin-right: 0; margin-left: 12px; } .feed-grid-wrap #feed-main-list .feed-row-wide:nth-child(4n+1) { margin-left: 0; } .feed-grid-wrap #feed-main-list .feed-row-wide .feed-block { width: 291px; margin-left: 0; margin-right: 0; } .feed-grid-wrap #feed-main-list .z-feed-img { height: 164px; } .feed-grid-wrap #feed-main-list .z-feed-foot-l { top: 121px; width: 263px; } .feed-grid-wrap #feed-main-list .z-group-data { padding: 6px 0 6px 16px; margin: 0; width: 56px; } .feed-grid-wrap #feed-main-list .z-feed-foot-r { height: auto!important; } #feed-side { display: none; } `; // 调整社区首页 const adjustPostMain = () => { const hotPics = $('.feed-hot-card.slick-slide .feed-hot-pic img').toArray(); for (let img of hotPics) { img.src = img.src.replace('_a200.jpg', '_c350.jpg'); } const adjustListItem = item => { const $item = $(item); // 过滤媒体号... // 添加热度 const $icons = $item.find('.z-feed-foot-r'); console.log($icons); const amount = $icons.find('a.z-group-data').toArray().reduce((n, a) => n + parseInt(a.lastElementChild.textContent), 0); const $hot = $(`${amount}`); $icons.prepend($hot); }; for (let t of $('.feed-grid-wrap #feed-main-list .feed-row-wide').toArray()) { adjustListItem(t); } new MutationObserver(records => { for(let r of records) { if(r.addedNodes.length > 0) { for(let n of r.addedNodes) { adjustListItem(n); } } } }).observe($('#feed-main-list')[0], { childList: true }); }; const init = () => { addGlobalStyle(styles); adjustPostMain(); }; init(); })();