問題タブ [google-chrome-storage]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票する
1 に答える
152 参照

google-chrome-extension - chrome.storage スロットル制限のモニタリング

拡張機能でchrome.storageを使用していますが、同期ストアまたはローカル ストアのドキュメントに記載されているスロットルのいずれかを超えたために実行時エラーが発生するのを避けたいと考えています。(、のようなQUOTA_BYTESものQUOTA_BYTES_PER_ITEM)

私の最初の選択は、実行時エラーが生成される前にこれらのエラーをインターセプトすることです。または、拡張機能側で使用状況を追跡し、それらをトリガーしないようにすることもできます。

これは誰かが対処したに違いない問題のように感じますが、解決策が見つからないようです - 提案をいただければ幸いです。

0 投票する
1 に答える
2840 参照

javascript - ポップアップとブラウザ アクション ウィンドウの間の chrome.storage

Chrome 拡張機能を作成していますが、すべてのデータ/変数を Chrome ストレージで管理したいと考えています。私が理解していることから、拡張機能全体で chrome.storage を使用できるはずです。

browser_action スクリプトで何かを設定し、バックグラウンド スクリプトによって作成されたウィンドウでアクセスしたいと考えています。HTML ファイルと JS ファイルには、すべて対応する名前があります。

これは私が運が悪かったことです:

//manifest.json

//background.js

//setting.js

//newPage.js

これを行うと、newPage.html に「script loaded... and status: undefined」と表示されます。

非同期であっても、スクリプトの 2 回目の実行時にストレージの値を設定する必要があります。

私はこれを間違って使用している可能性があります。その場合、Chrome ストレージを使用して新しいウィンドウにアクセスするように設定する正しい方法は何ですか?

どんな助けでも大歓迎です!

0 投票する
1 に答える
1157 参照

javascript - chrome.storage 拡張機能の使用方法

私の拡張ポップアップ ページは、サンドボックス ページとスクリプトからのメッセージからデータを取得します。できれば storage.sync メソッドを使用して、これを chrome.storage 内に保存する必要があります。次のエラーが表示されます: Uncaught TypeError: Cannot read property 'sync' of undefined

manifest.json 内にストレージのアクセス許可を既に追加しました。

... "パーミッション": ["ストレージ"], ... chrome.storage.sync 未定義?

Google はまた、バックグラウンド スクリプトは必要ないと述べています: https://developer.chrome.com/extensions/storage

引用:拡張機能のコンテンツ スクリプトは、バックグラウンド ページを必要とせずにユーザー データに直接アクセスできます。

私は何を見落としていますか?前もって感謝します!

0 投票する
1 に答える
173 参照

javascript - chrome.storage.sync が正しく保存されない

ページをリロードするときに保存されていないように見える理由がわかりません(オブジェクトをストレージに保存しているように見えますが.

関連するコードは次のとおりです。

options.js

console.log に表示される内容:

ここに画像の説明を入力

なぜ空なのかわからない。何か助けはありますか?

0 投票する
1 に答える
2004 参照

javascript - クロムストレージを使用してオブジェクトからデータを削除する方法は?

次のようなオブジェクトがクロムストレージ内に保存されています。

私は何かをしたいchrome.storage.sync.remove([{"planA": "123"}]);

しかし、それはうまくいかないようですError in response to storage.get: Error: Invalid value for argument 1. Value does not match any valid type choices.

ドキュメントから StorageArea.remove(string or array of string keys, function callback)

アリのアイデア?

0 投票する
1 に答える
1885 参照

javascript - Saving files in a Chrome App

Summary

Normally I could download a bunch of files, but Chrome Apps won't show the download shelf when a download occurs. What would be the best way of getting around this limitation of Chrome Apps?

Ideas

  • I could go about this by creating a zip file, but this would require the user to perform an extra step of unzipping the file.
  • I'm able to silently download the files, and so I could display a prompt to the user when the file is downloaded, but this would require the user to manually search for the file in their downloads folder.

What I've Learned

  • Everywhere on the internet tells me to use Chrome's download API, but this only works for Chrome extensions and not Chrome apps.
  • I can't bring up a save as window because 50 save as windows for 50 files is unacceptable
  • I can, however, bring up a prompt using chrome.fileSystem.chooseEntry({'type': "openDirectory"} to ask the user to choose a directory, but I can't find a way of saving to that directory.
  • My question is basically the same as How can a Chrome extension save many files to a user-specified directory? but for a Chrome app instead of an extension.

Project and Example Code

The app I'm building will be the same as this webpage I've built, but with a few modifications to make it work as a web-app.

This is how my website solves the problem