From bd7e5e768e86cff2111cacc85f2bf4a4f5b030e4 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 13 May 2022 16:51:25 +0000 Subject: [PATCH] style: auto format --- docs/install/README.md | 3 +- lib/v2/zhihu/execlib/g_encrypt.js | 320 +++++++++++++----------------- 2 files changed, 136 insertions(+), 187 deletions(-) diff --git a/docs/install/README.md b/docs/install/README.md index 3a6333106..6f3e0d91d 100644 --- a/docs/install/README.md +++ b/docs/install/README.md @@ -815,5 +815,6 @@ RSSHub 支持使用访问密钥 / 码,白名单和黑名单三种方式进行 - `ZHIHU_COOKIES`: 知乎登录后的 cookie 值. 1. 可以在知乎网页版的一些请求的请求头中找到,如 `GET /moments` 请求头中的 `cookie` 值. + - 知乎问题 - - `ZHIHU_COOKIES_NO_LOGIN`: 知乎非登陆状态下的 cookie 值,其中 dc_0 是必要的,其他可删除 + - `ZHIHU_COOKIES_NO_LOGIN`: 知乎非登陆状态下的 cookie 值,其中 dc\_0 是必要的,其他可删除 diff --git a/lib/v2/zhihu/execlib/g_encrypt.js b/lib/v2/zhihu/execlib/g_encrypt.js index 9f7f301a0..8dc8dadd7 100644 --- a/lib/v2/zhihu/execlib/g_encrypt.js +++ b/lib/v2/zhihu/execlib/g_encrypt.js @@ -8,82 +8,66 @@ * Generate x-zse-96 * * taken from https://github.com/srx-2000/spider_collection/blob/3b9f3cc8badc01e3f3e3035c14139d4d5fd1382f/zhihuAnswerSpider/spider/g_encrypt.js -*/ + */ -const jsdom = require("jsdom"); -const {JSDOM} = jsdom; +const jsdom = require('jsdom'); +const { JSDOM } = jsdom; const dom = new JSDOM(`

Hello world

`); const window = dom.window; function t(e) { - return (t = "function" === typeof Symbol && "symbol" === typeof Symbol.A ? function (e) { - return typeof e; - } + return (t = + 'function' === typeof Symbol && 'symbol' === typeof Symbol.A + ? function (e) { + return typeof e; + } : function (e) { - return e && "function" === typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e; - } - )(e); + return e && 'function' === typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? 'symbol' : typeof e; + })(e); } -Object.defineProperty(exports, "__esModule", { - value: !0 +Object.defineProperty(exports, '__esModule', { + value: !0, }); -const A = "2.0", - __g = {}; +const A = '2.0', + __g = {}; -function s() { -} +function s() {} function i(e) { - this.t = (2048 & e) >> 11, - this.s = (1536 & e) >> 9, - this.i = 511 & e, - this.h = 511 & e; + (this.t = (2048 & e) >> 11), (this.s = (1536 & e) >> 9), (this.i = 511 & e), (this.h = 511 & e); } function h(e) { - this.s = (3072 & e) >> 10, - this.h = 1023 & e; + (this.s = (3072 & e) >> 10), (this.h = 1023 & e); } function a(e) { - this.a = (3072 & e) >> 10, - this.c = (768 & e) >> 8, - this.n = (192 & e) >> 6, - this.t = 63 & e; + (this.a = (3072 & e) >> 10), (this.c = (768 & e) >> 8), (this.n = (192 & e) >> 6), (this.t = 63 & e); } function c(e) { - this.s = e >> 10 & 3, - this.i = 1023 & e; + (this.s = (e >> 10) & 3), (this.i = 1023 & e); } -function n() { -} +function n() {} function e(e) { - this.a = (3072 & e) >> 10, - this.c = (768 & e) >> 8, - this.n = (192 & e) >> 6, - this.t = 63 & e; + (this.a = (3072 & e) >> 10), (this.c = (768 & e) >> 8), (this.n = (192 & e) >> 6), (this.t = 63 & e); } function o(e) { - this.h = (4095 & e) >> 2, - this.t = 3 & e; + (this.h = (4095 & e) >> 2), (this.t = 3 & e); } function r(e) { - this.s = e >> 10 & 3, - this.i = e >> 2 & 255, - this.t = 3 & e; + (this.s = (e >> 10) & 3), (this.i = (e >> 2) & 255), (this.t = 3 & e); } -s.prototype.e = function (e) { +(s.prototype.e = function (e) { e.o = !1; -} - , - i.prototype.e = function (e) { +}), + (i.prototype.e = function (e) { switch (this.t) { case 0: e.r[this.s] = this.i; @@ -91,13 +75,11 @@ s.prototype.e = function (e) { case 1: e.r[this.s] = e.k[this.h]; } - } - , - h.prototype.e = function (e) { + }), + (h.prototype.e = function (e) { e.k[this.h] = e.r[this.s]; - } - , - a.prototype.e = function (e) { + }), + (a.prototype.e = function (e) { switch (this.t) { case 0: e.r[this.a] = e.r[this.c] + e.r[this.n]; @@ -162,26 +144,18 @@ s.prototype.e = function (e) { case 20: e.r[this.a] = !e.r[this.c]; } - } - , - c.prototype.e = function (e) { - e.Q.push(e.C), - e.B.push(e.k), - e.C = e.r[this.s], - e.k = []; - for (let t = 0; t < this.i; t++) - {e.k.unshift(e.f.pop());} - e.g.push(e.f), - e.f = []; - } - , - n.prototype.e = function (e) { - e.C = e.Q.pop(), - e.k = e.B.pop(), - e.f = e.g.pop(); - } - , - e.prototype.e = function (e) { + }), + (c.prototype.e = function (e) { + e.Q.push(e.C), e.B.push(e.k), (e.C = e.r[this.s]), (e.k = []); + for (let t = 0; t < this.i; t++) { + e.k.unshift(e.f.pop()); + } + e.g.push(e.f), (e.f = []); + }), + (n.prototype.e = function (e) { + (e.C = e.Q.pop()), (e.k = e.B.pop()), (e.f = e.g.pop()); + }), + (e.prototype.e = function (e) { switch (this.t) { case 0: e.u = e.r[this.a] >= e.r[this.c]; @@ -207,9 +181,8 @@ s.prototype.e = function (e) { case 7: e.u = !e.r[this.a]; } - } - , - o.prototype.e = function (e) { + }), + (o.prototype.e = function (e) { switch (this.t) { case 0: e.C = this.h; @@ -221,56 +194,49 @@ s.prototype.e = function (e) { e.u || (e.C = this.h); break; case 3: - e.C = this.h, - e.w = null; + (e.C = this.h), (e.w = null); } e.u = !1; - } - , - r.prototype.e = function (e) { + }), + (r.prototype.e = function (e) { switch (this.t) { case 0: - for (var t = [], n = 0; n < this.i; n++) - {t.unshift(e.f.pop());} + for (var t = [], n = 0; n < this.i; n++) { + t.unshift(e.f.pop()); + } e.r[3] = e.r[this.s](t[0], t[1]); break; case 1: - for (var r = e.f.pop(), i = [], o = 0; o < this.i; o++) - {i.unshift(e.f.pop());} + for (var r = e.f.pop(), i = [], o = 0; o < this.i; o++) { + i.unshift(e.f.pop()); + } e.r[3] = e.r[this.s][r](i[0], i[1]); break; case 2: - for (var a = [], c = 0; c < this.i; c++) - {a.unshift(e.f.pop());} + for (var a = [], c = 0; c < this.i; c++) { + a.unshift(e.f.pop()); + } e.r[3] = new e.r[this.s](a[0], a[1]); } - } -; + }); const k = function (e) { for (var t = 66, n = [], r = 0; r < e.length; r++) { const i = 24 ^ e.charCodeAt(r) ^ t; - n.push(String.fromCharCode(i)), - t = i; + n.push(String.fromCharCode(i)), (t = i); } - return n.join(""); + return n.join(''); }; function Q(e) { - this.t = (4095 & e) >> 10, - this.s = (1023 & e) >> 8, - this.i = 1023 & e, - this.h = 63 & e; + (this.t = (4095 & e) >> 10), (this.s = (1023 & e) >> 8), (this.i = 1023 & e), (this.h = 63 & e); } function C(e) { - this.t = (4095 & e) >> 10, - this.a = (1023 & e) >> 8, - this.c = (255 & e) >> 6; + (this.t = (4095 & e) >> 10), (this.a = (1023 & e) >> 8), (this.c = (255 & e) >> 6); } function B(e) { - this.s = (3072 & e) >> 10, - this.h = 1023 & e; + (this.s = (3072 & e) >> 10), (this.h = 1023 & e); } function f(e) { @@ -286,28 +252,26 @@ function u(e) { } function w(e) { - this.t = (3840 & e) >> 8, - this.s = (192 & e) >> 6, - this.i = 63 & e; + (this.t = (3840 & e) >> 8), (this.s = (192 & e) >> 6), (this.i = 63 & e); } function G() { - this.r = [0, 0, 0, 0], - this.C = 0, - this.Q = [], - this.k = [], - this.B = [], - this.f = [], - this.g = [], - this.u = !1, - this.G = [], - this.b = [], - this.o = !1, - this.w = null, - this.U = null, - this.F = [], - this.R = 0, - this.J = { + (this.r = [0, 0, 0, 0]), + (this.C = 0), + (this.Q = []), + (this.k = []), + (this.B = []), + (this.f = []), + (this.g = []), + (this.u = !1), + (this.G = []), + (this.b = []), + (this.o = !1), + (this.w = null), + (this.U = null), + (this.F = []), + (this.R = 0), + (this.J = { 0: s, 1: i, 2: h, @@ -323,11 +287,11 @@ function G() { 12: f, 13: g, 14: u, - 15: w - }; + 15: w, + }); } -Q.prototype.e = function (e) { +(Q.prototype.e = function (e) { switch (this.t) { case 0: e.f.push(e.r[this.s]); @@ -341,9 +305,8 @@ Q.prototype.e = function (e) { case 3: e.f.push(k(e.b[this.h])); } -} - , - C.prototype.e = function (A) { +}), + (C.prototype.e = function (A) { switch (this.t) { case 0: var t = A.f.pop(); @@ -351,49 +314,39 @@ Q.prototype.e = function (e) { break; case 1: var s = A.f.pop(), - i = A.f.pop(); + i = A.f.pop(); A.r[this.c][s] = i; break; case 2: var h = A.f.pop(); A.r[this.a] = eval(h); } - } - , - B.prototype.e = function (e) { + }), + (B.prototype.e = function (e) { e.r[this.s] = k(e.b[this.h]); - } - , - f.prototype.e = function (e) { + }), + (f.prototype.e = function (e) { e.w = this.h; - } - , - g.prototype.e = function (e) { + }), + (g.prototype.e = function (e) { throw e.r[this.s]; - } - , - u.prototype.e = function (e) { + }), + (u.prototype.e = function (e) { const t = this, - n = [0]; - e.k.forEach(((e) => { - n.push(e); - } - )); + n = [0]; + e.k.forEach((e) => { + n.push(e); + }); const r = function (r) { - const i = new G; - return i.k = n, - i.k[0] = r, - i.v(e.G, t.h, e.b, e.F), - i.r[3]; + const i = new G(); + return (i.k = n), (i.k[0] = r), i.v(e.G, t.h, e.b, e.F), i.r[3]; }; - r.toString = function () { - return "() { [native code] }"; - } - , - e.r[3] = r; - } - , - w.prototype.e = function (e) { + (r.toString = function () { + return '() { [native code] }'; + }), + (e.r[3] = r); + }), + (w.prototype.e = function (e) { switch (this.t) { case 0: for (var t = {}, n = 0; n < this.i; n++) { @@ -403,55 +356,50 @@ Q.prototype.e = function (e) { e.r[this.s] = t; break; case 1: - for (var i = [], o = 0; o < this.i; o++) - {i.unshift(e.f.pop());} + for (var i = [], o = 0; o < this.i; o++) { + i.unshift(e.f.pop()); + } e.r[this.s] = i; } - } - , - G.prototype.D = function (e) { - for (var t = window.atob(e), n = t.charCodeAt(0) << 8 | t.charCodeAt(1), r = [], i = 2; i < n + 2; i += 2) - {r.push(t.charCodeAt(i) << 8 | t.charCodeAt(i + 1));} + }), + (G.prototype.D = function (e) { + for (var t = window.atob(e), n = (t.charCodeAt(0) << 8) | t.charCodeAt(1), r = [], i = 2; i < n + 2; i += 2) { + r.push((t.charCodeAt(i) << 8) | t.charCodeAt(i + 1)); + } this.G = r; - for (var o = [], a = n + 2; a < t.length;) { - const c = t.charCodeAt(a) << 8 | t.charCodeAt(a + 1), - u = t.slice(a + 2, a + 2 + c); - o.push(u), - a += c + 2; + for (var o = [], a = n + 2; a < t.length; ) { + const c = (t.charCodeAt(a) << 8) | t.charCodeAt(a + 1), + u = t.slice(a + 2, a + 2 + c); + o.push(u), (a += c + 2); } this.b = o; - } - , - G.prototype.v = function (e, t, n) { - for (t = t || 0, - n = n || [], - this.C = t, - "string" === typeof e ? this.D(e) : (this.G = e, - this.b = n), - this.o = !0, - this.R = Date.now(); this.o;) { + }), + (G.prototype.v = function (e, t, n) { + for (t = t || 0, n = n || [], this.C = t, 'string' === typeof e ? this.D(e) : ((this.G = e), (this.b = n)), this.o = !0, this.R = Date.now(); this.o; ) { const r = this.G[this.C++]; - if ("number" !== typeof r) - {break;} + if ('number' !== typeof r) { + break; + } const i = Date.now(); - if (500 < i - this.R) - {return;} + if (500 < i - this.R) { + return; + } this.R = i; try { this.e(r); } catch (e) { - this.U = e, - this.w && (this.C = this.w); + (this.U = e), this.w && (this.C = this.w); } } - } - , - G.prototype.e = function (e) { + }), + (G.prototype.e = function (e) { const t = (61440 & e) >> 12; new this.J[t](e).e(this); - } - , -"undefined" !== typeof window && (new G).v("AxjgB5MAnACoAJwBpAAAABAAIAKcAqgAMAq0AzRJZAZwUpwCqACQACACGAKcBKAAIAOcBagAIAQYAjAUGgKcBqFAuAc5hTSHZAZwqrAIGgA0QJEAJAAYAzAUGgOcCaFANRQ0R2QGcOKwChoANECRACQAsAuQABgDnAmgAJwMgAGcDYwFEAAzBmAGcSqwDhoANECRACQAGAKcD6AAGgKcEKFANEcYApwRoAAxB2AG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