// ==UserScript== // @name yaohuo // @namespace http://tampermonkey.net/ // @version 0.3 // @description try to take over the world! // @author Polygon // @match https://yaohuo.me/bbs* // @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw== // @grant none // @run-at document-end // @downloadURL none // ==/UserScript== (function () { 'use strict'; let nextPageURL = null let nextPageButton = document.querySelector('.more a') if (nextPageButton) { nextPageURL = nextPageButton.getAttribute('href') } else { return } console.log(nextPageURL) console.log(nextPageURL.match(/Total=(\d+)/g)[0].split('=')[1]) if (parseInt(nextPageURL.match(/Total=(\d+)/g)[0].split('=')[1]) <= 15) { return } // 获取更多评论地址 let commentURL = location.protocol + '//' + location.host + nextPageURL.replace('page=2', 'page=1') // 移除简短评论url 第一个是正文,第二个是评论 let commentDiv = document.querySelectorAll('.content')[1] commentDiv.innerHTML = "" let iframe = document.createElement('iframe') iframe.id = 'full-comment' iframe.src = commentURL iframe.width = '100%' iframe.setAttribute('frameborder', 'no') iframe.setAttribute('scrolling', 'no') iframe.setAttribute('border', '0') iframe.style = ` transition: height 0.3s linear; ` commentDiv.appendChild(iframe) setInterval(() => { let iframeDocument = document.getElementById('full-comment').contentWindow.document let body = iframeDocument.querySelector('body') if (body.querySelector('.tip')) { document.getElementById('full-comment').contentWindow.history.back() } else { let removeEles = ['a[href^="/bbs/message"] + .btBox', 'a[href^="/bbs/message"]', '.showpage + .btBox', '.subtitle'] for (let i = 0; i < removeEles.length; i++) { let node = body.querySelector(removeEles[i]) if (node) { node.parentNode.removeChild(node) } } iframe.height = iframeDocument.body.scrollHeight iframeDocument.querySelector('.showpage').style['background-color'] = 'white' } }, 600) })();