Twitter 媒體下載

一鍵保存視頻/圖片

< 腳本Twitter 媒體下載的回應

評論:正評 - 腳本一切正常

§
發表於:2022-10-30
編輯:2022-10-30

Works but the console gets this error:
Uncaught TypeError: Cannot read properties of null (reading 'href')
at Object.inject (userscript.html?name=Twitter%2520Media%2520Downloader.user.js&id=743f41db-2f4a-4c73-8154-de5fd5de41fb:89:69)
at userscript.html?name=Twitter%2520Media%2520Downloader.user.js&id=743f41db-2f4a-4c73-8154-de5fd5de41fb:377:51
at NodeList.forEach ()
at userscript.html?name=Twitter%2520Media%2520Downloader.user.js&id=743f41db-2f4a-4c73-8154-de5fd5de41fb:375:59
at Array.forEach ()
at MutationObserver.observe.childList (userscript.html?name=Twitter%2520Media%2520Downloader.user.js&id=743f41db-2f4a-4c73-8154-de5fd5de41fb:375:33)
11userscript.html?name=My%2520Changes.user.js&id=a13e3485-0433-4107-a6a8-4eb56a3ac270:19 removing [object HTMLDivElement]

天音作者
§
發表於:2022-10-30

I can't reproduce this error

Does it occurs every time?

If not, I think this only appears on specific tweets.

§
發表於:2022-11-02
編輯:2022-11-02

Surprise! I fixed it:

Put this on line 87, just below the "if (media) {" line:

try { // Need to test if href is null first, else this generates an uncaught TypeError during scrolling occasionally.
let _ = article.querySelector('a[href*="/status/"]').href.split('/status/').pop().split('/').shift();
}
catch{
return // Script assumes setting status_id was successful.
}


I had a fiddle with it and yeah i dunno why it was erroring but it seemed to be related to me scrolling the homepage really fast, and i'm using Edge. Either way it seems to be fixed now that there is an assertion that status_id is valid. If i see anything else funky i'll let ya know <3 Love the script man.

天音作者
§
發表於:2022-11-04

yeah, i found the reason
the audio selector will match promotions
this is not twitter media content

will be fixed later

發表回覆

登入以回復