Skip to content

Commit

Permalink
handle table missing
Browse files Browse the repository at this point in the history
  • Loading branch information
dimdenGD committed Apr 12, 2024
1 parent 6410db6 commit ce095cf
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 19 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Old Twitter Layout (2024)",
"description": "__MSG_ext_description__",
"version": "1.8.3.6",
"version": "1.8.3.7",
"manifest_version": 3,
"homepage_url": "https://github.com/dimdenGD/OldTwitter",
"background": {
Expand Down
41 changes: 23 additions & 18 deletions scripts/injection.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,25 +260,29 @@ async function readCryptoKey() {
const db = event.target.result;

// Open a transaction to access the keyvaluepairs object store
const transaction = db.transaction(['keyvaluepairs'], 'readonly');
const objectStore = transaction.objectStore('keyvaluepairs');

objectStore.openCursor().onsuccess = function(event) {
const cursor = event.target.result;
if (cursor) {
// Check if the key matches the pattern
const key = cursor.key;
if (key.startsWith('device:rweb.dmCryptoKeys')) {
resolve(cursor.value);
}
if (db.objectStoreNames.contains('keyvaluepairs')) {
const transaction = db.transaction(['keyvaluepairs'], 'readonly');
const objectStore = transaction.objectStore('keyvaluepairs');

// Move to the next entry
cursor.continue();
} else {
// No more entries, reject the promise
resolve("No key found");
}
};
objectStore.openCursor().onsuccess = function(event) {
const cursor = event.target.result;
if (cursor) {
// Check if the key matches the pattern
const key = cursor.key;
if (key.startsWith('device:rweb.dmCryptoKeys')) {
resolve(cursor.value);
}

// Move to the next entry
cursor.continue();
} else {
// No more entries, reject the promise
reject("No key found");
}
};
} else {
reject("No key found");
}
};
});
}
Expand Down Expand Up @@ -598,6 +602,7 @@ let page = realPath === "" ? pages[0] : pages.find(p => (!p.exclude || !p.exclud

try {
let cryptoKey = await readCryptoKey();
console.log('Crypto key', cryptoKey);
if(cryptoKey) {
OLDTWITTER_CONFIG.deviceId = cryptoKey.deviceId;
} else {
Expand Down

0 comments on commit ce095cf

Please sign in to comment.