From 56884103a703f44c704359bbbf1113746e98af7c Mon Sep 17 00:00:00 2001 From: Hakadao Date: Fri, 10 Feb 2023 01:24:22 +0800 Subject: [PATCH] feat: update anime page --- src/background/apis/history.ts | 9 ++ src/contentScripts/views/History/History.vue | 131 ++++++++++++++----- 2 files changed, 104 insertions(+), 36 deletions(-) diff --git a/src/background/apis/history.ts b/src/background/apis/history.ts index 823ce6e9..ae39559a 100644 --- a/src/background/apis/history.ts +++ b/src/background/apis/history.ts @@ -2,6 +2,7 @@ import browser from 'webextension-polyfill' export const setupHistoryAPIs = () => { browser.runtime.onMessage.addListener((message) => { + // https://github.com/SocialSisterYi/bilibili-API-collect/blob/master/history&toview/history.md#%E8%8E%B7%E5%8F%96%E5%8E%86%E5%8F%B2%E8%AE%B0%E5%BD%95%E5%88%97%E8%A1%A8_web%E7%AB%AF if (message.contentScriptQuery === 'getHistoryList') { const url = `https://api.bilibili.com/x/web-interface/history/cursor?ps=20&type=${message.type}&view_at=${message.viewAt}` return fetch(url) @@ -9,5 +10,13 @@ export const setupHistoryAPIs = () => { .then(data => (data)) .catch(error => console.error(error)) } + // https://github.com/SocialSisterYi/bilibili-API-collect/blob/master/history&toview/history.md#%E5%88%A0%E9%99%A4%E5%8E%86%E5%8F%B2%E8%AE%B0%E5%BD%95 + else if (message.contentScriptQuery === 'deleteHistoryItem') { + const url = `https://api.bilibili.com/x/v2/history/delete?kid=${message.kid}&csrf=${message.csrf}` + return fetch(url) + .then(response => response.json()) + .then(data => (data)) + .catch(error => console.error(error)) + } }) } diff --git a/src/contentScripts/views/History/History.vue b/src/contentScripts/views/History/History.vue index 351ffbba..c8f76733 100644 --- a/src/contentScripts/views/History/History.vue +++ b/src/contentScripts/views/History/History.vue @@ -60,6 +60,10 @@ function getHistoryList() { }) } +function deleteHistoryItem() { + +} + /** * Return the URL of the history item * @param item history item @@ -82,6 +86,9 @@ function getHistoryUrl(item: HistoryItem) {