Skip to content

Commit 167b246

Browse files
committed
更新 [百度贴吧] 规则
1 parent e555290 commit 167b246

1 file changed

Lines changed: 24 additions & 32 deletions

File tree

Autopage.user.js

Lines changed: 24 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// ==UserScript==
22
// @name 自动无缝翻页
3-
// @version 3.2.4
3+
// @version 3.2.5
44
// @author X.I.U
55
// @description 无缝拼接下一页内容(瀑布流),目前支持:[所有「Discuz!、Flarum、phpBB、Xiuno、XenForo、DUX/XIU/D8/Begin(WP主题)」网站]、百度、谷歌、必应、搜狗、头条搜索、360 搜索、微信搜索、贴吧、豆瓣、微博、NGA、V2EX、B 站(Bilibili)、蓝奏云、煎蛋网、糗事百科、龙的天空、起点小说、IT之家、千图网、Pixabay、3DM、游侠网、游民星空、NexusMods、Steam 创意工坊、CS.RIN.RU、FitGirl、片库、茶杯狐、NO视频、低端影视、奈菲影视、91美剧网、音范丝、BT之家、萌番组、动漫花园、樱花动漫、爱恋动漫、AGE动漫、Nyaa、SrkBT、RARBG、SubHD、423Down、不死鸟、扩展迷、极简插件、小众软件、动漫狂、漫画猫、漫画DB、动漫之家、古风漫画网、PubMed、wikiHow、GreasyFork、Github、StackOverflow(以上仅一小部分,更多的写不下了...
66
// @match *://*/*
@@ -4586,37 +4586,29 @@
45864586
// [百度贴吧] 插入数据
45874587
function baidu_tieba_insertE(newBody, type) {
45884588
if (!newBody) return
4589-
let pageElems = getAll(curSite.pager.pageE, newBody, newBody),
4590-
toElement = getAll(curSite.pager.insertP[0])[0];
4591-
if (pageElems.length >= 0) {
4592-
// 执行插入前函数
4593-
pageElems = curSite.function.bF(pageElems);
4594-
// 插入位置
4595-
let addTo = getAddTo(curSite.pager.insertP[1]);
4596-
// 获取 <script> 内容
4597-
const scriptElems = getAll('//script', newBody, newBody);
4598-
let scriptText = '';
4599-
for (let i = 0; i < scriptElems.length; i++) {
4600-
if (scriptElems[i].textContent.indexOf('Bigpipe.register("frs-list/pagelet/thread_list"') > -1) {
4601-
scriptText = scriptElems[i].textContent.replace('Bigpipe.register("frs-list/pagelet/thread_list", ','');
4602-
break
4603-
}
4604-
}
4605-
if (scriptText) {
4606-
scriptText = scriptText.slice(0, scriptText.indexOf(').')) // 获取主体内容
4607-
let scriptJSON = JSON.parse(scriptText).content; // 字符串转 JSON
4608-
var temp_baidu_tieba = document.createElement('div'); temp_baidu_tieba.innerHTML = scriptJSON; // 字符串转 Element 元素
4609-
pageElems = curSite.function.bF(getAll(curSite.pager.pageE, temp_baidu_tieba, temp_baidu_tieba)); // 插入前执行函数
4610-
pageElems.forEach(function (one) {toElement.insertAdjacentElement(addTo, one);}); // 插入元素
4611-
// 当前页码 + 1
4612-
pageNum.now = pageNum._now + 1
4613-
// 替换元素
4614-
let oriE = document.querySelectorAll(curSite.pager.pageE.replace('css;', '')),
4615-
repE = getAll(curSite.pager.replaceE, temp_baidu_tieba, temp_baidu_tieba);
4616-
if (oriE.length === repE.length) {
4617-
for (let i = 0; i < oriE.length; i++) {
4618-
oriE[i].outerHTML = repE[i].outerHTML;
4619-
}
4589+
let toElement = getAll(curSite.pager.insertP[0])[0], pageElems;
4590+
// 插入位置
4591+
let addTo = getAddTo(curSite.pager.insertP[1]);
4592+
// 获取 <script> 内容
4593+
const scriptElems = getXpath(`//script[contains(text(), 'Bigpipe.register("frs-list/pagelet/thread_list", ')]`, newBody, newBody);
4594+
if (scriptElems) {
4595+
// 从 <script> 中提取帖子列表字符串
4596+
let scriptText = scriptElems.textContent.replace('Bigpipe.register("frs-list/pagelet/thread_list", ','');
4597+
scriptText = scriptText.slice(0, scriptText.indexOf(').'));
4598+
// 字符串格式化并转为 Element 元素
4599+
var temp_baidu_tieba = document.createElement('div'); temp_baidu_tieba.innerHTML = JSON.parse(scriptText).content;
4600+
// 插入前执行函数
4601+
pageElems = curSite.function.bF(getAll(curSite.pager.pageE, temp_baidu_tieba, temp_baidu_tieba));
4602+
// 插入元素
4603+
pageElems.forEach(function (one) {toElement.insertAdjacentElement(addTo, one);});
4604+
// 当前页码 + 1
4605+
pageNum.now = pageNum._now + 1
4606+
// 替换元素
4607+
let oriE = document.querySelectorAll(curSite.pager.replaceE.replace('css;', '')),
4608+
repE = getAll(curSite.pager.replaceE, temp_baidu_tieba, temp_baidu_tieba);
4609+
if (oriE.length === repE.length) {
4610+
for (let i = 0; i < oriE.length; i++) {
4611+
oriE[i].outerHTML = repE[i].outerHTML;
46204612
}
46214613
}
46224614
}

0 commit comments

Comments
 (0)