Skip to content

[BUG] Orion反安裝MV3版本後,安裝MV2無法正常運作 #503

@cyfung1031

Description

@cyfung1031

Problem Description

資料庫版本問題,應該要檢查到資料庫版本低於實際版本時,要提醒用戶要不要重設ScriptCat

我發現ScriptCat裡沒有重設按鈕。

我用以下代碼重設成功。ScriptCat可以正常運作了

希望檢查到資料庫版本異常時,彈出「重設ScriptCat嗎?」,然後一鍵執行以下代碼

// Unregister all service workers
if (typeof navigator.serviceWorker !== 'undefined' && typeof navigator.serviceWorker.getRegistrations === 'function') {
  navigator.serviceWorker.getRegistrations().then(registrations => {
    registrations.forEach(reg => {
      reg.unregister().then(() => {
        console.log("Unregistered service worker:", reg);
      });
    });
  });
}


// Clear LocalStorage and SessionStorage
localStorage.clear();
sessionStorage.clear();

if (typeof caches !== 'undefined' && typeof caches.keys === 'function') {

  // Clear Cache Storage (used by service workers)
  caches.keys().then(keys => {
    keys.forEach(key => {
      caches.delete(key).then(success => {
        if (success) console.log(`Deleted cache: ${key}`);
      });
    });
  });
}

// Clear all IndexedDB databases
(async () => {
  const dbs = await indexedDB.databases();
  for (const db of dbs) {
    if (db.name) {
      console.log(`Deleting IndexedDB: ${db.name}`);
      const req = indexedDB.deleteDatabase(db.name);
      req.onsuccess = () => console.log(`Deleted ${db.name} successfully`);
      req.onerror = () => console.warn(`Failed to delete ${db.name}`);
      req.onblocked = () => console.warn(`Delete blocked for ${db.name}. Close other tabs?`);
    }
  }
})();

// Try clearing cookies with different paths
document.cookie.split(";").forEach(cookie => {
  const eqPos = cookie.indexOf("=");
  const name = eqPos > -1 ? cookie.slice(0, eqPos).trim() : cookie.trim();
  const paths = ["/", window.location.pathname];
  paths.forEach(path => {
    document.cookie = `${name}=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=${path}`;
  });
});

Reproduction Steps

ScriptCat Version

0.18.1 & 0.16.6

Operating System and Browser Information

Macbook MacOS Orion Beta

Additional Information (Optional)

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions