Last active
July 8, 2023 04:09
-
-
Save Getaji/1dfbb4e12232d6e3716391f327ddc06c to your computer and use it in GitHub Desktop.
Twitter Web Appの検索履歴のJSONを出力するやつ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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