Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix code format for busuanzi.js #2680

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
155 changes: 99 additions & 56 deletions lib/plugins/busuanzi.js
Original file line number Diff line number Diff line change
@@ -1,96 +1,139 @@
/* eslint-disable */
let bszCaller, bszTag, scriptTag, ready

let t; let e; let n; let a = !1
let c = []
let intervalId;
let executeCallbacks;
let onReady;
let isReady = false;
let callbacks = [];

// 修复Node同构代码的问题
if (typeof document !== 'undefined') {
ready = function (t) {
return a || document.readyState === 'interactive' || document.readyState === 'complete'
? t.call(document)
: c.push(function () {
return t.call(this)
}), this
}, e = function () {
for (let t = 0, e = c.length; t < e; t++) c[t].apply(document)
c = []
}, n = function () {
a || (a = !0, e.call(window),
document.removeEventListener ? document.removeEventListener('DOMContentLoaded', n, !1) : document.attachEvent && (document.detachEvent('onreadystatechange', n), window == window.top && (clearInterval(t), t = null)))
}, document.addEventListener
? document.addEventListener('DOMContentLoaded', n, !1)
: document.attachEvent && (document.attachEvent('onreadystatechange', function () {
/loaded|complete/.test(document.readyState) && n()
}), window == window.top && (t = setInterval(function () {
try {
a || document.documentElement.doScroll('left')
} catch (t) {
return
ready = function (callback) {
if (isReady || document.readyState === 'interactive' || document.readyState === 'complete') {
callback.call(document);
} else {
callbacks.push(function () {
return callback.call(this);
});
}
return this;
};

executeCallbacks = function () {
for (let i = 0, len = callbacks.length; i < len; i++) {
callbacks[i].apply(document);
}
callbacks = [];
};

onReady = function () {
if (!isReady) {
isReady = true;
executeCallbacks.call(window);
if (document.removeEventListener) {
document.removeEventListener('DOMContentLoaded', onReady, false);
} else if (document.attachEvent) {
document.detachEvent('onreadystatechange', onReady);
if (window == window.top) {
clearInterval(intervalId);
intervalId = null;
}
}
}
};

if (document.addEventListener) {
document.addEventListener('DOMContentLoaded', onReady, false);
} else if (document.attachEvent) {
document.attachEvent('onreadystatechange', function () {
if (/loaded|complete/.test(document.readyState)) {
onReady();
}
n()
}, 5)))
});
if (window == window.top) {
intervalId = setInterval(function () {
try {
if (!isReady) {
document.documentElement.doScroll('left');
}
} catch (e) {
return;
}
onReady();
}, 5);
}
}
}

bszCaller = {
fetch: function (t, e) {
const n = 'BusuanziCallback_' + Math.floor(1099511627776 * Math.random())
t = t.replace('=BusuanziCallback', '=' + n)
scriptTag = document.createElement('SCRIPT'), scriptTag.type = 'text/javascript', scriptTag.defer = !0, scriptTag.src = t, scriptTag.referrerPolicy = "no-referrer-when-downgrade", document.getElementsByTagName('HEAD')[0].appendChild(scriptTag)
window[n] = this.evalCall(e)
fetch: function (url, callback) {
const callbackName = 'BusuanziCallback_' + Math.floor(1099511627776 * Math.random())
url = url.replace('=BusuanziCallback', '=' + callbackName)
scriptTag = document.createElement('SCRIPT');
scriptTag.type = 'text/javascript';
scriptTag.defer = true;
scriptTag.src = url;
scriptTag.referrerPolicy = "no-referrer-when-downgrade";
document.getElementsByTagName('HEAD')[0].appendChild(scriptTag);
window[callbackName] = this.evalCall(callback)
},
evalCall: function (e) {
return function (t) {
evalCall: function (callback) {
return function (data) {
ready(function () {
try {
e(t)
callback(data);
if (scriptTag && scriptTag.parentElement && scriptTag.parentElement.contains(scriptTag)) {
scriptTag.parentElement.removeChild(scriptTag)
scriptTag.parentElement.removeChild(scriptTag);
}
} catch (t) {
// console.log(t), bszTag.hides()
} catch (e) {
// console.log(e);
// bszTag.hides();
}
})
}
}
}

const fetch = () => {
bszTag && bszTag.hides()
bszCaller.fetch('//busuanzi.ibruce.info/busuanzi?jsonpCallback=BusuanziCallback', function (t) {
// console.log('不蒜子',t)
bszTag.texts(t), bszTag.shows()
if (bszTag) {
bszTag.hides();
}
bszCaller.fetch('//busuanzi.ibruce.info/busuanzi?jsonpCallback=BusuanziCallback', function (data) {
// console.log('不蒜子',data)
bszTag.texts(data);
bszTag.shows();
})
}

bszTag = {
bszs: ['site_pv', 'page_pv', 'site_uv'],
texts: function (n) {
this.bszs.map(function (t) {
const e = document.getElementsByClassName('busuanzi_value_' + t)
if(e){
for (var element of e) {
element.innerHTML = n[t]
texts: function (data) {
this.bszs.map(function (key) {
const elements = document.getElementsByClassName('busuanzi_value_' + key)
if (elements) {
for (var element of elements) {
element.innerHTML = data[key];
}
}
})
},
hides: function () {
this.bszs.map(function (t) {
const e = document.getElementsByClassName('busuanzi_container_' + t)
if(e){
for (var element of e){
element.style.display = 'none'
this.bszs.map(function (key) {
const elements = document.getElementsByClassName('busuanzi_container_' + key)
if (elements) {
for (var element of elements) {
element.style.display = 'none';
}
}
})
},
shows: function () {
this.bszs.map(function (t) {
const e = document.getElementsByClassName('busuanzi_container_' + t)
if(e){
for(var element of e){
element.style.display = 'inline'
this.bszs.map(function (key) {
const elements = document.getElementsByClassName('busuanzi_container_' + key)
if (elements) {
for (var element of elements) {
element.style.display = 'inline';
}
}
})
Expand Down
4 changes: 2 additions & 2 deletions pushUrl.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
QUOTA = 100


def parse_stiemap(site):
def parse_sitemap(site):
site = f'{site}/sitemap.xml'
try:
result = requests.get(site)
Expand Down Expand Up @@ -78,7 +78,7 @@ def push_to_baidu(site, urls, token):

if args.url:
# 解析urls
urls = parse_stiemap(args.url)
urls = parse_sitemap(args.url)
if urls is not None:
# 判断当前urls数量是否超过额度,若超过则取当日最大值,默认为100,可根据实际情况修改
if len(urls) > QUOTA:
Expand Down