贴吧会自动折叠长图不喜欢,是个坏功能,不要
当前为
// ==UserScript==
// @name 贴吧禁止折叠长图
// @namespace You Boy
// @version 0.3
// @description 贴吧会自动折叠长图不喜欢,是个坏功能,不要
// @author You Boy
// @match *://tieba.baidu.com/*
// @icon https://tb3.bdstatic.com/public/icon/favicon-v2.ico
// @grant none
// ==/UserScript==
(function() {
'use strict';
// 遍历删除replace_div
function removeReplaceDiv(){
const replaceDivArray = document.querySelectorAll("div.replace_div");
try{
for(const item of replaceDivArray){
item.classList.remove('replace_div');
item.querySelector('div.replace_tip').remove();
}
}catch(err){
console.group('贴吧禁止折叠长图 Error Info');
console.error(err);
console.groupEnd();
}
}
// 增加绑定事件,使之可以监听pushState和replaceState
const bindStateListener = function(stateName) {
const historyState = history[stateName];
return function() {
const newState = historyState.apply(this, arguments);
const e = new Event(stateName);
e.arguments = arguments;
window.dispatchEvent(e);
return newState;
};
};
history.pushState = bindStateListener('pushState');
history.replaceState = bindStateListener('replaceState');
// 延迟函数
const delay = function(fun,time){
const delayTime = time || 1000;
setTimeout(fun,delayTime);
// 原来基础上多加个2秒,再次执行一次,网速慢导致有部分漏网之鱼
setTimeout(fun,delayTime + 2e3);
// 还。。还想来?
setTimeout(fun,delayTime + 4e3);
}
window.addEventListener('load', function() {
removeReplaceDiv();
});
window.addEventListener('popstate', function() {
delay(removeReplaceDiv);
});
window.addEventListener('replaceState', function() {
delay(removeReplaceDiv);
});
window.addEventListener('pushState', function() {
delay(removeReplaceDiv);
});
})();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址