mirror of
https://github.com/BewlyBewly/BewlyBewly.git
synced 2025-04-14 13:15:29 +00:00
feat(VideoCard): improve not interested feature
This commit is contained in:
@@ -1,58 +1,57 @@
|
||||
import browser from 'webextension-polyfill'
|
||||
|
||||
function handleMessage(message: any) {
|
||||
// #region APP端api,遺棄
|
||||
/** Recommend Videos */
|
||||
// if (message.contentScriptQuery === 'getRecommendVideos') {
|
||||
// // https://github.com/indefined/UserScripts/blob/master/bilibiliHome/bilibiliHome.API.md#%E8%8E%B7%E5%8F%96%E9%A6%96%E9%A1%B5%E5%86%85%E5%AE%B9
|
||||
// const url = `${APP_URL}/x/feed/index?build=1&idx=${message.idx}&appkey=27eb53fc9058f8c3&access_key=${message.accessKey}`
|
||||
// return fetch(url)
|
||||
// .then(response => response.json())
|
||||
// .then(data => data)
|
||||
// .catch(error => console.error(error))
|
||||
// }
|
||||
// /** Submit a video that is not of interest */
|
||||
// else if (message.contentScriptQuery === 'submitDislike') {
|
||||
// // https://github.com/indefined/UserScripts/blob/master/bilibiliHome/bilibiliHome.API.md#%E6%8F%90%E4%BA%A4%E4%B8%8D%E5%96%9C%E6%AC%A2
|
||||
// let url = `https://app.bilibili.com/x/feed/dislike?access_key=${message.accessKey}
|
||||
// &goto=${message.goto}
|
||||
// &id=${message.id}
|
||||
// &mid=${message.mid}
|
||||
// &reason_id=${message.reasonID}
|
||||
// &rid=${message.rid}
|
||||
// &tag_id=${message.tagID}
|
||||
// &build=5000000`
|
||||
/** Submit a video that is not of interest */
|
||||
if (message.contentScriptQuery === 'dislikeVideo') {
|
||||
// https://github.com/indefined/UserScripts/blob/master/bilibiliHome/bilibiliHome.API.md#%E6%8F%90%E4%BA%A4%E4%B8%8D%E5%96%9C%E6%AC%A2
|
||||
const url = `https://app.bilibili.com/x/feed/dislike?access_key=${message.access_key}`
|
||||
+ `&goto=${message.goto}`
|
||||
+ `&id=${message.id}`
|
||||
+ `&idx=${message.idx}`
|
||||
// + `&mid=${message.mid}`
|
||||
+ `&reason_id=${message.reason_id}`
|
||||
// + `&rid=${message.rid}`
|
||||
// + `&tag_id=${message.tagId}`
|
||||
+ `&device=${message.device}`
|
||||
+ `&mobi_app=${message.mobi_app}`
|
||||
+ `&build=${message.build}`
|
||||
+ `&sign=${message.sign}`
|
||||
+ `&appkey=${message.appkey}`
|
||||
|
||||
// // remove url empty spaces
|
||||
// url = url.replace(/\s+/g, '')
|
||||
// // remove url empty spaces
|
||||
// url = url.replace(/\s+/g, '')
|
||||
|
||||
// return fetch(url)
|
||||
// .then(response => response.json())
|
||||
// .then(data => data)
|
||||
// .catch(error => console.error(error))
|
||||
// }
|
||||
return fetch(url)
|
||||
.then(response => response.json())
|
||||
.then(data => data)
|
||||
.catch(error => console.error(error))
|
||||
}
|
||||
|
||||
// /** Undo a video that is not of interest */
|
||||
// else if (message.contentScriptQuery === 'undoDislike') {
|
||||
// // https://github.com/indefined/UserScripts/blob/master/bilibiliHome/bilibiliHome.API.md#%E6%92%A4%E9%94%80%E4%B8%8D%E5%96%9C%E6%AC%A2
|
||||
// let url = `https://app.bilibili.com/x/feed/dislike/cancel?access_key=${message.accessKey}
|
||||
// &goto=${message.goto}
|
||||
// &id=${message.id}
|
||||
// &mid=${message.mid}
|
||||
// &reason_id=${message.reasonID}
|
||||
// &rid=${message.rid}
|
||||
// &tag_id=${message.tagID}
|
||||
// &build=5000000`
|
||||
/** Undo a video that is not of interest */
|
||||
else if (message.contentScriptQuery === 'undoDislikeVideo') {
|
||||
// https://github.com/indefined/UserScripts/blob/master/bilibiliHome/bilibiliHome.API.md#%E6%92%A4%E9%94%80%E4%B8%8D%E5%96%9C%E6%AC%A2
|
||||
const url = `https://app.bilibili.com/x/feed/dislike/cancel?access_key=${message.access_key}`
|
||||
+ `&goto=${message.goto}`
|
||||
+ `&id=${message.id}`
|
||||
+ `&idx=${message.idx}`
|
||||
// + `&mid=${message.mid}`
|
||||
+ `&reason_id=${message.reason_id}`
|
||||
// + `&rid=${message.rid}`
|
||||
// + `&tag_id=${message.tagId}`
|
||||
+ `&device=${message.device}`
|
||||
+ `&mobi_app=${message.mobi_app}`
|
||||
+ `&build=${message.build}`
|
||||
+ `&sign=${message.sign}`
|
||||
+ `&appkey=${message.appkey}`
|
||||
|
||||
// // remove url empty spaces
|
||||
// url = url.replace(/\s+/g, '')
|
||||
// // remove url empty spaces
|
||||
// url = url.replace(/\s+/g, '')
|
||||
|
||||
// return fetch(url)
|
||||
// .then(response => response.json())
|
||||
// .then(data => data)
|
||||
// .catch(error => console.error(error))
|
||||
// }
|
||||
// #endregion
|
||||
return fetch(url)
|
||||
.then(response => response.json())
|
||||
.then(data => data)
|
||||
.catch(error => console.error(error))
|
||||
}
|
||||
|
||||
if (message.contentScriptQuery === 'getRecommendVideos') {
|
||||
const url = `https://api.bilibili.com/x/web-interface/index/top/feed/rcmd?fresh_idx=${message.refreshIdx}&feed_version=V2&fresh_type=4&ps=30&plat=1`
|
||||
|
||||
Reference in New Issue
Block a user