├── README.md └── 98BAMI3.user.js /README.md: -------------------------------------------------------------------------------- 1 | 98浏览助手多图版油猴脚本 2 | ====================== 3 | 4 | ## 简介 5 | * 让98帖子列表、搜索结果、个人页和收藏列表支持多图预览,点击图片可以查看大图 6 | * 脚本编辑模式下 //@match中可以自行修改、添加或排除你常用的论坛版块网址 7 | * 支持.org和.net域名,如果你使用的域名不一样,请修改网址的域名 8 | -------------------------------------------------------------------------------- /98BAMI3.user.js: -------------------------------------------------------------------------------- 1 | // ==UserScript== 2 | // @name 98浏览助手多图版3 3 | // @namespace 98BAMI 4 | // @author Virya 5 | 6 | // @description 为堂内帖子列表、搜索页、个人页和收藏页增加多图预览支持。下面链接分别是org和net域名下的论坛地址,也可自行添加修改论坛域名或分区地址。如果你希望脚本对某个分区不生效,请在下方添加// @exclude并填写分区地址。 7 | 8 | // @match https://www.sehuatang.org/forum* 9 | // @match https://sehuatang.org/forum* 10 | // @match https://www.sehuatang.net/forum* 11 | // @match https://sehuatang.net/forum* 12 | 13 | // @match https://www.sehuatang.org/search* 14 | // @match https://sehuatang.org/search* 15 | // @match https://www.sehuatang.net/search* 16 | // @match https://sehuatang.net/search* 17 | 18 | // @match https://www.sehuatang.org/home* 19 | // @match https://sehuatang.org/home* 20 | // @match https://www.sehuatang.net/home* 21 | // @match https://sehuatang.net/home* 22 | 23 | // @match https://gfggfdw.0nkaz.com/forum* 24 | // @match https://gfggfdw.0nkaz.com/search* 25 | // @match https://gfggfdw.0nkaz.com/home* 26 | 27 | 28 | // @connect sehuatang.org 29 | // @connect sehuatang.net 30 | 31 | // @grant GM_setValue 32 | // @grant GM_getValue 33 | // @grant GM_setClipboard 34 | // @grant GM_xmlhttpRequest 35 | // @grant GM_getResourceText 36 | // @grant GM_addStyle 37 | // @grant GM_openInTab 38 | // @grant GM_registerMenuCommand 39 | 40 | // @require https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.min.js 41 | // @require http://lib.baomitu.com/jquery.lazyload/1.9.1/jquery.lazyload.min.js 42 | 43 | // @version 3.5.6 44 | // @license MIT 45 | // ==/UserScript== 46 | /* global $ */ 47 | 48 | 49 | 50 | //为新增内容添加样式 51 | function addStyles() { 52 | const title1_style = `.s.xst { 53 | font-size: 17px; 54 | font-weight: 700; 55 | font-family: 'PingFang SC', 'Helvetica Neue', 'Microsoft YaHei New', 'STHeiti Light', sans-serif; 56 | }`; 57 | const title2_style = `.xst { 58 | font-size: 17px; 59 | font-weight: 700; 60 | font-family: 'PingFang SC', 'Helvetica Neue', 'Microsoft YaHei New', 'STHeiti Light', sans-serif; 61 | }`; 62 | const imgThumb_style = `.lazy { 63 | width: 32%; 64 | max-height: 500px; 65 | margin-right: 1%; 66 | border-radius: 2px; 67 | display: inline; 68 | cursor: pointer; 69 | object-fit: contain; 70 | } 71 | `; 72 | const filterButton_style = `.filterButton { 73 | position: fixed; 74 | top: 141px; 75 | left: 93%; 76 | background: #ed4014; 77 | color: white; 78 | padding: 0px 7px; 79 | border: 0; 80 | cursor: pointer; 81 | border-radius: 3px; 82 | height : 24px; 83 | font-size: 14px; 84 | font-family:'PingFang SC','Helvetica Neue','Microsoft YaHei New','STHeiti Light',sans-serif; 85 | } 86 | `; 87 | GM_addStyle(title1_style); 88 | GM_addStyle(title2_style); 89 | GM_addStyle(imgThumb_style); 90 | GM_addStyle(filterButton_style); 91 | } 92 | 93 | 94 | 95 | 96 | //主功能函数 97 | function main() { 98 | 99 | //判断是帖子列表页、搜索页还是个人页 100 | var url = window.location.href; 101 | getSelectors(url); 102 | //console.log(selector1); 103 | 104 | //获取每个帖子内容 105 | selector1.each(function(){ 106 | 107 | var urls = 'https://'+ location.hostname+'/'; 108 | urls+=$(this).find(selector2).attr("href"); 109 | //console.log(urls); 110 | 111 | //根据页面类型加载图片插入方式 112 | var insertion = addRow(appendMethod, $(this)); 113 | 114 | 115 | //跳过已处理过的帖子列表 116 | if ($(insertion).find('img').length != 0) { 117 | return true 118 | } 119 | 120 | 121 | GM_xmlhttpRequest({ 122 | method: 'GET', 123 | url: urls, 124 | headers: { 125 | 'User-agent': 'Mozilla/5.0 Chrome/70. Safari/537.36', 126 | 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3', 127 | }, 128 | onload: function(result) { 129 | var doc = result.responseText; 130 | 131 | 132 | //加载图片 133 | var img =$(doc).find('#postlist div:nth-child(1) .zoom').filter( ":not([file*='static/image'])").slice(0, 3) 134 | //console.log(img) 135 | 136 | img.each(function(index) { 137 | 138 | var pic_url = $(this).attr( "zoomfile" ) || $(this).attr( "file" ) || $(this).attr( "src" ); 139 | var img_thumb = $(''); 140 | img_thumb.attr({ 141 | "data-original": pic_url, 142 | src: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB/AAffA0nNPuCLAAAAAElFTkSuQmCC", 143 | onclick:"zoom(this, this.src, 0, 0, 0)", 144 | }); 145 | 146 | img_thumb.addClass('lazy') 147 | img_thumb.appendTo(insertion); 148 | }); 149 | 150 | //图片延迟加载效果 151 | $(function() { 152 | $(insertion).find('img.lazy').lazyload({effect: "fadeIn"}); 153 | }); 154 | //动态调整图片预览遮罩层高度 155 | $(insertion).find('img.lazy').click(function() { 156 | setTimeout(function() { 157 | modifyCoverHeight(); 158 | }, 100); 159 | }); 160 | 161 | 162 | } 163 | }); 164 | 165 | }); 166 | } 167 | 168 | 169 | 170 | 171 | 172 | //根据不同页面确定图片插入位置和插入方式 173 | var selector1, selector2, appendMethod; 174 | 175 | function getSelectors(url) { 176 | if (url.match(/^.*forum\.php\?.*mod=forumdisplay.*$/) || url.match(/[\w.-]+\/.*forum-\d+.*/)) { 177 | selector1 = $('[id^=normalthread]'); 178 | selector2 = ".icn a"; 179 | appendMethod = 'append'; 180 | 181 | } else if (url.match(/.*\/search.*/)) { 182 | 183 | // 将按钮添加到页面中 184 | $('body').append(filterButton); 185 | // 如果配置项的值为 true,则调用 removeSpecialPosts() 函数 186 | if (filterConfig.enabled) { 187 | removeSpecialPosts("fid=143","fid=118"); 188 | } 189 | 190 | selector1 = $('.pbw'); 191 | selector2 = ".xs3 a"; 192 | appendMethod = 'append'; 193 | $('head').append( $('').attr('href', 'data/cache/style_1_forum_forumdisplay.css?acl') ); 194 | } else if (url.match(/^.*home\.php\?.*do=thread.*$/)) { 195 | selector1 = $('tr'); 196 | selector2 = "th a"; 197 | appendMethod = 'after'; 198 | $('head').append( $('').attr('href', 'data/cache/style_1_forum_forumdisplay.css?acl') ); 199 | } else if (url.match(/^.*home\.php\?.*do=favorite.*$/)) { 200 | selector1 = $('.bbda.ptm.pbm'); 201 | selector2 = "a:eq(1)"; 202 | appendMethod = 'append'; 203 | //$('head').append( $('').attr('href', 'data/cache/style_1_forum_forumdisplay.css?acl') ); 204 | } else if (url.match(/^.*forum\.php\?.*mod=guide.*$/)) { 205 | selector1 = $('[id^=normalthread]'); 206 | selector2 = ".icn a"; 207 | appendMethod = 'append_guide'; 208 | } 209 | } 210 | 211 | 212 | //根据不同的页面以不同方式插入图片 213 | function addRow(appendMethod, target) { 214 | if (appendMethod === 'append') { 215 | var row = $(''); 216 | row.appendTo(target); 217 | return target.find('#imgbox_td') 218 | } else if (appendMethod === 'after') { 219 | row = $(''); 220 | target.after(row); 221 | return target.next('tr').find('#imgbox_td') 222 | } else if (appendMethod === 'append_guide') { 223 | row = $(''); 224 | row.appendTo(target); 225 | return target.find('#imgbox_td') 226 | } 227 | } 228 | 229 | 230 | 231 | 232 | //在当前页面过滤特殊帖子类型 233 | function removeSpecialPosts(keyword1,keyword2) { 234 | $("li:has(a[href*='" + keyword1 + "'])").remove(); 235 | $("li:has(a[href*='" + keyword2 + "'])").remove(); 236 | } 237 | 238 | // 设置过滤按钮 239 | var filterButton = $('