Skip to content

Commit

Permalink
fix(Weixin.js, Zhihu.js): 去除不必要的笔记note,现在zotero可方便的阅读网页快照, closed #213
Browse files Browse the repository at this point in the history
  • Loading branch information
l0o0 committed Sep 27, 2023
1 parent 6e96070 commit 391e939
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
12 changes: 6 additions & 6 deletions Weixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"inRepository": true,
"translatorType": 4,
"browserSupport": "gcsibv",
"lastUpdated": "2023-07-05 03:39:17"
"lastUpdated": "2023-09-27 07:06:52"
}

/*
Expand Down Expand Up @@ -44,11 +44,11 @@ function scrape(doc, url) {
item.abstractNote = ogMetadataCache.get("og:description");
item.creators = getArticleCreator(doc, ogMetadataCache.get("og:article:author"));
item.date = doc.querySelector("#publish_time").innerText;
note_content = doc.body.querySelector("#js_content").innerHTML.trim();
note_content = note_content.replace(/\"/g, "'");
note_content = note_content.replace(/<img .*?src='(.*?)'.*?>/g, "<img src='$1'\/>");
note_content = `<h1>${item.title}</h1>` + note_content;
item.notes.push({note:note_content});
// note_content = doc.body.querySelector("#js_content").innerHTML.trim();
// note_content = note_content.replace(/\"/g, "'");
// note_content = note_content.replace(/<img .*?src='(.*?)'.*?>/g, "<img src='$1'\/>");
// note_content = `<h1>${item.title}</h1>` + note_content;
// item.notes.push({note:note_content});
item.attachments.push({url: url, title: "Snapshot", document: doc});
item.complete();
}
Expand Down
16 changes: 8 additions & 8 deletions Zhihu.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"inRepository": true,
"translatorType": 4,
"browserSupport": "gcsibv",
"lastUpdated": "2023-04-03 06:43:09"
"lastUpdated": "2023-09-27 07:14:43"
}

/*
Expand Down Expand Up @@ -105,11 +105,11 @@ async function doWeb(doc, url) {
}
else {
var ZID = getIDFromUrl(url);
await scrape(ZID);
await scrape(ZID, doc);
}
}

async function scrape(ZID) {
async function scrape(ZID, doc) {
var { ztype, zid, url } = ZID;
var newItem = new Zotero.Item(ztype === 'answer' ? 'forumPost' : 'blogPost');
newItem.url = url;
Expand Down Expand Up @@ -141,18 +141,18 @@ async function scrape(ZID) {
newItem.date = new Date(createdTime * 1000).toISOString();
newItem.websiteType = "知乎专栏文章";
newItem.blogTitle = textJson.column ? textJson.column.title : '回答';
let content = textJson.content.replace(/<figure.*?<img src="(.*?)".*?<\/figure>/g, "<img src='$1'/>");
content = content.replace(/<sup.*?data-text="(.*?)".*?data-url="(.*?)".*?>\[(\d+)\]<\/sup>/g, '<sup><a title="$1" href="$2">[$3]</a></sup>');
content = "<h1>正文详情</h1>" + content;
// let content = textJson.content.replace(/<figure.*?<img src="(.*?)".*?<\/figure>/g, "<img src='$1'/>");
// content = content.replace(/<sup.*?data-text="(.*?)".*?data-url="(.*?)".*?>\[(\d+)\]<\/sup>/g, '<sup><a title="$1" href="$2">[$3]</a></sup>');
// content = "<h1>正文详情</h1>" + content;
newItem.creators.push({ lastName: textJson.author.name, creatorType: "author" });
newItem.notes.push({ note: content });
// newItem.notes.push({ note: content });
if (textJson.topics) {
textJson.topics.forEach(t => newItem.tags.push({ tag: t.name }));
}
newItem.extra = `赞数:${textJson.voteup_count};`;
}
newItem.language = 'zh-CN';
newItem.attachments.push({ url: url, title: "Snapshot" });
newItem.attachments.push({ url: url, title: "Snapshot", document: doc });
newItem.complete();
}

Expand Down

0 comments on commit 391e939

Please sign in to comment.