diff --git a/ChangeLog.md b/ChangeLog.md index 6d3efda..462ef1d 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,5 +1,9 @@ # 知乎疯牛病 --- 更新日志 +## 1.0.7 + * 知乎改前端啦,紧急修复 + * 几个辅助页面的小修复 + ## 1.0.6 * 修复了部分“关注问题”不记录的问题。 * 文章也可以像回答一样保存了。 diff --git a/DBExportor/POD.cs b/DBExportor/POD.cs index 54569f8..4d724b4 100644 --- a/DBExportor/POD.cs +++ b/DBExportor/POD.cs @@ -220,15 +220,15 @@ public class StandardDB { public List spams = new List(); public List follows = new List(); - public List users = new List(3000000); + public List users = new List(4500000); public List questions = new List(); public List
articles = new List
(); public List topics = new List(); - public List answers = new List(); - public List zans = new List(20000000); - public List zanarts = new List(3000000); + public List answers = new List(2000000); + public List zans = new List(23000000); + public List zanarts = new List(2000000); public List followqsts = new List(100000); - public List details = new List(); + public List details = new List(1500000); public List rectime = new List(); public void Slim(int level = 0) { diff --git a/ZhiHuExt.sln b/ZhiHuExt.sln index 943763a..3798e30 100644 --- a/ZhiHuExt.sln +++ b/ZhiHuExt.sln @@ -60,7 +60,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "template", "template", "{D3 ProjectSection(SolutionItems) = preProject template\answers-api.json = template\answers-api.json template\article-page.json = template\article-page.json + template\articles-api.json = template\articles-api.json + template\home-page.json = template\home-page.json template\people-page.json = template\people-page.json + template\question-answers-api.json = template\question-answers-api.json template\question-page.json = template\question-page.json template\voters-api.json = template\voters-api.json EndProjectSection diff --git a/ZhiHuExt/AssocAns.js b/ZhiHuExt/AssocAns.js index 08c6810..eac19c4 100644 --- a/ZhiHuExt/AssocAns.js +++ b/ZhiHuExt/AssocAns.js @@ -118,12 +118,12 @@ function initSlider(data) data.filter(x => x.date > 0).forEach(x => { mindate = Math.min(mindate, x.date); maxdate = Math.max(maxdate, x.date); }); rangetext.textContent = toDate(mindate) + " ~ " + toDate(maxdate); const dateRange = { "min": [mindate], "max": [maxdate] }; - if (mindate < maxdate - 3600 * 24 * 365) + if (mindate < maxdate - 3600 * 24 * 365) // a-year before dateRange["5%"] = [maxdate - 3600 * 24 * 365]; - if (mindate < maxdate - 3600 * 24 * 180) + if (mindate < maxdate - 3600 * 24 * 180) // 3-month before dateRange["30%"] = [maxdate - 3600 * 24 * 180]; - if (mindate < maxdate - 3600 * 24 * 30) - dateRange["60%"] = [maxdate - 3600 * 24 * 180]; + if (mindate < maxdate - 3600 * 24 * 30) // a-month before + dateRange["60%"] = [maxdate - 3600 * 24 * 30]; noUiSlider.create(sliderHandle, { start: [0, maxdate], diff --git a/ZhiHuExt/ContentBase.js b/ZhiHuExt/ContentBase.js index d11567d..7c69150 100644 --- a/ZhiHuExt/ContentBase.js +++ b/ZhiHuExt/ContentBase.js @@ -100,12 +100,12 @@ class ContentBase return pms; } /** - * @param {string} uid * @param {"followees" | "followers"} obj + * @param {string} uid * @param {number} offset * @returns {{data: User[], end: boolean, total: number}} */ - static _fetchFollows(uid, obj, offset) + static _fetchFollows(obj, uid, offset) { const pms = $.Deferred(); ContentBase._get(`https://www.zhihu.com/api/v4/members/${uid}/${obj}?include=data[*].account_status,gender,voteup_count,answer_count,follower_count,is_followed,is_following,badge[?(type=best_answerer)].topics&limit=20&offset=${offset}`) @@ -212,10 +212,10 @@ class ContentBase } catch (e) { - if (++errcnt > 5) - break; - else + if (++errcnt <= 5) continue; + console.warn("too many error occur when fetch voters, early return.", obj, id, limit, config); + break; } } return ret; @@ -278,10 +278,10 @@ class ContentBase } catch (e) { - if (++errcnt > 5) - break; - else + if (++errcnt <= 5) continue; + console.warn("too many error occur when fetch answers, early return.", qid, limit); + break; } } return whole; @@ -289,6 +289,7 @@ class ContentBase static async fetchComments(aid, limit) { + let errcnt = 0; const whole = []; let isEnd = false; for (let offset = 0; offset < limit && !isEnd;) @@ -302,22 +303,23 @@ class ContentBase } catch (e) { - if (++errcnt > 5) - break; - else + if (++errcnt <= 5) continue; + console.warn("too many error occur when fetch comments, early return.", aid, limit); + break; } } return whole; } /** - * @param {string} uid * @param {"followees" | "followers"} obj + * @param {string} uid * @param {number} limit */ - static async fetchFollows(uid, obj, limit) + static async fetchFollows(obj, uid, limit) { + let errcnt = 0; /**@type {User[]}*/ const whole = []; let isEnd = false; @@ -325,17 +327,17 @@ class ContentBase { try { - const part = await ContentBase._fetchFollows(uid, obj, offset); + const part = await ContentBase._fetchFollows(obj, uid, offset); whole.push(...part.data); isEnd = part.end; offset += part.data.length; } catch (e) { - if (++errcnt > 5) - break; - else + if (++errcnt <= 5) continue; + console.warn("too many error occur when fetch follows, early return.", obj, uid, limit); + break; } } /**@type {{users:User[],follows:Follow[]}}*/ diff --git a/ZhiHuExt/PageEnhance.js b/ZhiHuExt/PageEnhance.js index 9b2cc2b..038dfd3 100644 --- a/ZhiHuExt/PageEnhance.js +++ b/ZhiHuExt/PageEnhance.js @@ -216,9 +216,9 @@ const suffix = ev.currentTarget.href.split("/").pop(); let ret = null; if (suffix === "following") - ret = await ContentBase.fetchFollows(uid, "followees", cnt); + ret = await ContentBase.fetchFollows("followees", uid, cnt); else if (suffix === "followers") - ret = await ContentBase.fetchFollows(uid, "followers", cnt); + ret = await ContentBase.fetchFollows("followers", uid, cnt); else return; ContentBase._report("follow", ret); diff --git a/ZhiHuExt/StatVoter.js b/ZhiHuExt/StatVoter.js index 79c3ff9..ba57de7 100644 --- a/ZhiHuExt/StatVoter.js +++ b/ZhiHuExt/StatVoter.js @@ -66,7 +66,7 @@ async function StatVoters(...voters) /** * @param {User} objuser * @param {HTMLAnchorElement} anchor - * @param {number} deep + * @param {boolean} deep */ async function chkUser(objuser, anchor, deep) { @@ -75,7 +75,10 @@ async function chkUser(objuser, anchor, deep) return; finalUserMap[user.id] = user; if (user.status === "ban" || user.status === "sban") + { anchor.style.background = "red"; + await ContentBase.checkUserState(objuser.id, undefined, [250], true);//extra check + } } $(document).on("click", "#chkAllStatus", async e => diff --git a/ZhiHuExt/content.js b/ZhiHuExt/content.js index 5ae2f75..fb5219c 100644 --- a/ZhiHuExt/content.js +++ b/ZhiHuExt/content.js @@ -263,6 +263,10 @@ function monitorVoter(voterPopup) } } +/** + * Add "Analyse" and "ReportSpam" buttons for each ".List-item" + * @param {HTMLDivElement[]} answerNodes + */ function addAASpamBtns(answerNodes) { answerNodes.filter(node => !node.hasChild(".Btn-ReportSpam")) @@ -270,32 +274,45 @@ function addAASpamBtns(answerNodes) { if (!node) return; /**@type {{type: string, token: string, upvote_num: number, comment_num: number, parent_token: string, author_member_hash_id: string}}*/ - const ansInfo = JSON.parse(node.dataset.zaModuleInfo || node.dataset.zaExtraModule).card.content; - let thetype; - if (ansInfo.type === "Answer") - thetype = "answer"; - else if (ansInfo.type === "Post") - thetype = "article"; + let ansInfo; + try + { + const oldInfo = node.dataset.zaModuleInfo || node.dataset.zaExtraModule; + if (oldInfo) + ansInfo = JSON.parse(oldInfo).card.content; + else + ansInfo = JSON.parse(node.dataset.zop); + } + catch (e) + { + console.warn("in paring for AASpamBtn, Zhihu may have update API", node.dataset); + return; + } + let atype; + if (ansInfo.type === "Answer" || ansInfo.type === "answer") + atype = "answer"; + else if (ansInfo.type === "Post" || ansInfo.type === "article") + atype = "article"; else return; - const ansid = ansInfo.token; - const ansArea = node.querySelector(".AuthorInfo"); - if (!ansArea) + const aid = ansInfo.token || ansInfo.itemId; + const aArea = node.querySelector(".AuthorInfo"); + if (!aArea) return; { const btn = createButton(["Btn-CheckSpam", "Button--primary"], "分析"); - btn.dataset.id = ansid; - btn.dataset.type = thetype; + btn.dataset.id = aid; + btn.dataset.type = atype; setDraggable(btn); - ansArea.appendChild(btn); + aArea.appendChild(btn); } { const btn = createButton(["Btn-ReportSpam", "Button--primary"], "广告"); - btn.dataset.id = ansid; - btn.dataset.type = thetype; + btn.dataset.id = aid; + btn.dataset.type = atype; setDraggable(btn); - ansArea.appendChild(btn); + aArea.appendChild(btn); } }); } diff --git a/ZhiHuExt/manifest.json b/ZhiHuExt/manifest.json index 461fdb3..b3df85d 100644 --- a/ZhiHuExt/manifest.json +++ b/ZhiHuExt/manifest.json @@ -2,7 +2,7 @@ "manifest_version": 2, "name": "知乎疯牛病", "key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmYNx4WYJ0FifJIs5ojnD8St4/3gAbskGThOD4bVn7yPWNce9ZC5/vRIzVNBKeJ8iCfQlQJ9EZq4HUngDGesM9KvpdCKTpB38yceOOlPumx9jN30Oq6IuTwdZsDnDl62mDi+phvQ4XMuPMUvAlxqfeotdf1KxmWGWzoqlZwq+1K/atTco4c4bUPotDtzo6D80B7SBAYrug8L+/crZtfUR44T2MnaBy8GG9f+6+kwQQ3pi4ehb7bLMdyxKEZhCSN+r8SdVaz+mTMzPpEt3M0tdCFen6WWw4HH8gZk9hb7v/WkWVxsFN1pHe7LRv8/28+Cig8cKGjCfwoFBgHLdYE/FyQIDAQAB", - "version": "1.0.6", + "version": "1.0.7", "author": "XZiar", "description": "知乎疯牛病插件————专治广告(并不能)", "icons":