Skip to content

Instantly share code, notes, and snippets.

@Getaji
Last active July 8, 2023 04:09
Show Gist options
  • Save Getaji/1dfbb4e12232d6e3716391f327ddc06c to your computer and use it in GitHub Desktop.
Save Getaji/1dfbb4e12232d6e3716391f327ddc06c to your computer and use it in GitHub Desktop.
Twitter Web Appの検索履歴のJSONを出力するやつ
(async () => {
/** ログイン中のユーザーID (数値の文字列) */
const userId = "730631798";
/** 出力モード ("dialog" | "console") */
const mode = "dialog";
const dbReq = await indexedDB.open("localforage");
dbReq.onsuccess = (evOpenDB) => {
const db = evOpenDB.target.result;
const tr = db.transaction("keyvaluepairs", "readonly");
const store = tr.objectStore("keyvaluepairs");
const storeReq = store.get(`user:${userId}:rweb.recentSearches`);
storeReq.onsuccess = (evStore) => {
const recentSearches = evStore.target.result.recentSearches;
switch (mode) {
case "dialog":
prompt("検索履歴(JSON)", JSON.stringify(recentSearches));
break;
case "console":
console.log(recentSearches);
break;
default:
console.error("サポートされていないモード: " + mode);
}
db.close();
};
storeReq.onerror = (evStore) => {
db.close();
};
};
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment