There are a few ways to transfer an object from an injected page script to a content script:
Use message passing: In this approach, you can use the chrome.runtime.sendMessage()
method to send a message from the injected page script to the content script. The message can contain the object data, and the content script can receive the message using the chrome.runtime.onMessage()
method.
Use the DOM: If the injected page script and the content script share the same DOM, you can use the DOM to transfer the object data. For example, you can add the object data as an attribute to a DOM element, and then retrieve the data in the content script using the getAttribute()
method.
Use localStorage or chrome.storage: You can store the object data in the browser's localStorage or chrome.storage, and then retrieve the data in the content script. This approach requires both the injected page script and the content script to have access to the same storage location.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2022-03-22 11:00:00 +0000
Seen: 11 times
Last updated: Dec 17 '22
How can additional centered content be added to Bootstrap 5 images?
How can a FlatList with multiple rows be made horizontal using React Native?
Is it possible to prevent Nodejs express session from loading session for static content?
Is it true that the presence of "&" in a website's URL is overlooked while scraping its content?
What is the usage or application of innerHTML when using xPath?
What measures can be taken to avoid obtaining character(0) while using rvest for web scraping?
How can I substitute the content in the textInput field?
What does the error message "Invalid character in header content ['Host']" mean in Postman?