Skip to content

Instantly share code, notes, and snippets.

@patwonder
Last active September 2, 2018 12:08
Show Gist options
  • Save patwonder/3c488bc39c6816cd8cc7 to your computer and use it in GitHub Desktop.
Save patwonder/3c488bc39c6816cd8cc7 to your computer and use it in GitHub Desktop.
贴吧去除ajax翻页
// ==UserScript==
// @id tieba-remove-ajax-pager@[email protected]
// @name 贴吧去除ajax翻页
// @version 1.7
// @namespace [email protected]
// @author patwonder
// @description
// @updateURL https://gist.githubusercontent.com/patwonder/3c488bc39c6816cd8cc7/raw/tieba-remove-ajax-pager.user.js
// @downloadURL https://gist.githubusercontent.com/patwonder/3c488bc39c6816cd8cc7/raw/tieba-remove-ajax-pager.user.js
// @include /^https?://tieba\.baidu\.com/((f\?(kz|(.*kw))=.*)|(p/.*))/
// @include http://tieba.baidu.com/club/*/p/*
// @include http://tieba.baidu.com/f?kz=*
// @include http://tieba.baidu.com/p/*
// @include http://tieba.baidu.com/f?*ct=*z=*
// @include http://tieba.baidu.com.cn/f?kz=*
// @include http://tieba.baidu.com.cn/p/*
// @include http://tieba.baidu.com.cn/f?*ct=*z=*
// @include http://post.baidu.com/f?kz=*
// @include http://post.baidu.com/p/*
// @include http://post.baidu.com/f?*ct=*z=*
// @include http://post.baidu.com.cn/f?kz=*
// @include http://post.baidu.com.cn/p/*
// @include http://post.baidu.com.cn/f?*ct=*z=*
// @include http://tieba.baidu.com/f?*kw=*
// @run-at document-end
// @grant none
// ==/UserScript==
(function(d, w) {
var stopListener = function(e) {
e.stopImmediatePropagation();
};
var matchesSelector = function(element, selector) {
if (element.mozMatchesSelector) {
return element.mozMatchesSelector(selector);
} else if (element.webkitMatchesSelector) {
return element.webkitMatchesSelector(selector);
} else if (element.matchesSelector) {
return element.matchesSelector(selector);
} else {
try {
var elems = element.parentElement ? element.parentElement.querySelectorAll(selector) : [];
for (var i = 0, l = elems.length; i < l; i++) {
if (elems[i] === element) return true;
}
} catch (ex) { }
return false;
}
};
w.addEventListener("click", function(e) {
if (matchesSelector(e.target, ".l_pager *, .pager *, #frs_list_pager *") && !matchesSelector(e.target, ".lzl_li_pager *"))
return stopListener(e);
}, true);
})(document, window);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment