tweetの画像をgyazoにuploadして置換する機能 (scrapbox-url-customizer)
tweet展開時に、画像をgyazoるようにした
gyazo側で元のtweet URLと紐づくようになっている
https://gyazo.com/ad49675e0112e0f0f023d603442e10ce
from scrapbox-url-customizer
gyazoにpbs.twimg.comの画像uploadする機能を実装し忘れてたtakker.icon
読者の課題とする
証明は読者に任せるよくない()yosider.icon
99%の読者がやらないやつ基素.icon
書きたくなってきたtakker.icon
code:ts
import { upload, UploadResult } from "../../takker/deno-gyazo/mod.ts";
import { getGyazoToken } from "../../takkerscrapbox-userscript-std/rest.ts";
const accessToken = token ?? await (async () => {
const result = await getGyazoToken();
if (!result.ok) throw new Error(JSON.stringify(result.value));
const accessToken = result.value;
if (!accessToken) throw new Error("Could not get the access token");
return accessToken;
})();
const image = await (await GM_fetch(url)).blob();
const result = await upload(image, { refererURL: twitterURL, accessToken });
if (!result.ok) throw result.value;
const gyazoURL = result.value.permalink_url;
あきた
まあこのあたりのsnippetを
https://code2svg.vercel.app/svg/L95-96/https://raw.githubusercontent.com/takker99/scrapbox-url-customizer/0.1.2/middlewares/formatTweet.ts#.svg https://github.com/takker99/scrapbox-url-customizer/blob/0.1.2/middlewares/formatTweet.ts#L95-L96
に挿入すれば動くと思います(適当)
2024/02/20で話題に上がったので実装してみるtakker.icon
18:42:01 テスト中
18:46:41 問題なさそうなのでreleaseする
https://github.com/takker99/scrapbox-url-customizer/pull/50
18:55:30 released!
2024/5/26 (今更)更新した 神!!!ありがとうございます!!!yosider.icon