Error: Unable to access the 'inspectedWindow' property because it is undefined

I need assistance with building a chrome-extension. I encountered an issue when running the following code:

document.addEventListener('DOMContentLoaded', function() {
    chrome.devtools.inspectedWindow.getResources(function(response){
        console.log("enter");
    });
});

An Uncaught TypeError is thrown, stating: Cannot read property 'inspectedWindow' of undefined.

If anyone has any insights on solving this problem, please advise. Thank you!

Answer №1

This particular API is exclusively accessible within the confines of a DevTools page:

https://i.sstatic.net/NkPQF.png

It's worth noting that in order to utilize this API, you must integrate a page into DevTools via manifest:

"devtools_page": "devtools.html"

Subsequently, this designated page will be initiated (along with its scripts being executed) every time DevTools is launched.

A unique instance of the extension's DevTools page is generated whenever a new DevTools window opens. This DevTools page remains active for as long as the DevTools window is open, thereby granting access to the DevTools APIs and a restricted selection of extension APIs.

To delve deeper into this topic, consult the official documentation.


If you seek similar functionality offered by the DevTools API but prefer to circumvent actually opening DevTools, consider exploring the debugger API. Nevertheless, exercise caution as it possesses substantial power. Imagine it more as a hefty yet intricate tool rather than a mere hammer.

Alternatively, to interact with the content of a page, you might need to inject a Content Script or monitor traffic using the webRequest API.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Run a PHP function using <button onclick=""> tag

Is it possible to trigger the execution of a PHP script when clicking an HTML button? I am aware that simply calling a PHP function directly from the button's onclick event like this: <button onclick="myPhpFunction("testString")">Button</butt ...

Error in Java: org.apache.jasper.JasperException - Class compilation error in JSP:

I'm looking to create a website for uploading photos to MySQL using JSP code, but I'm encountering an error that I'm struggling to resolve in the code. First, I found an example "upload.html" <title>Select your File to upload</tit ...

Guide on smoothly transitioning between 2 points within a requestAnimationframe iteration

Would it be possible to acquire a library for this task, or does anyone have any suggestions for my psuedocode API? Inquiry: How can I create a function that accepts 4 parameters interpolate(start, end, time, ease) and smoothly transition between the sta ...

Best practices for securely storing access tokens in React's memory

I'm on a quest to find a secure and efficient way to store my access token in a React application. First and foremost, I have ruled out using local storage. I don't see the need to persist the access token since I can easily refresh it when nece ...

Sending data to another page by selecting a list item

Being new to web programming and JavaScript, I am facing a scenario where I have a list of requests displayed on one page and I need to pass the ID of the selected request to another page to display all the details of that particular request. I am strugg ...

Listen to Vue.js event only when it is at the top

I have developed a unique Vue component for touch screen devices that allows users to input pin codes using buttons instead of standard keyboard input. The component also features customizable key mapping, and I would like to extend its functionality to su ...

Executing JavaScript in Page Object Model

When working on my automation script using Java with Selenium and the Page Object Model, I sometimes find it necessary to utilize Javascript Executor. This is because default WebDriver clicks can result in exceptions when elements are not found. Within th ...

Move the cursor to the end of the text when the key is released

I've developed a feature similar to that of a command line interface. When you input commands and hit the up key, the previous command is displayed. Everything is functioning as intended, but there's one minor issue. The current problem I'm ...

How does a database contribute to the functionality of a redux application?

Recently, I started exploring redux and finally understood the architecture behind it. In a single page redux application where all data is stored in a central store and updated through frontend actions, what purpose does the back-end and database serve? ...

Routing WebSocket connections with Node.js

Currently, I am in the process of developing a chat application for my company which will run on node js with websocket (ws). The app is designed to cater to various departments within the organization, each with its own set of users. My goal is to ensure ...

Positioning the label for a Material-UI text field with an icon adornment when the shrink property is set

https://i.stack.imgur.com/E85yj.png Utilizing Material-UI's TextField, I have an Icon embedded within. The issue arises when the label "Your good name here" overlaps the icon instead of being placed beside it. This problem emerged after I included ...

Extract information from an array that has been populated with data stored in a JSON file

I've been attempting to load a JSON file into an array and then access the data from it, but unfortunately, the alert isn't displaying any information. JSON file: data.json [ {"Name":"John", "Occupation":"Developer"}, {"Name":"Jane", "Occupatio ...

Attempting to transmit information to database using AJAX in the context of CodeIgniter

I'm having some trouble with my AJAX setup. It doesn't seem to be posting any data to the database, despite trying various solutions I found online. That's why I've turned to this platform for help. When testing in Postman and sending ...

Struggling to add information to a database table with PHP

Check out the code snippet below: Here is the HTML5 code block: <div class="col-md-8 blogger-right-container"> <form action="blogger_account.php" method="post" role="form" enctype="multipart/form-data"> < ...

Issue with Material UI Autocomplete: onChange event not firing

When using Material UI's Autocomplete example, I am trying to choose an option using keyboard events: Navigate through options with the Up and Down arrow keys Press ENTER to select the desired option However, the onChange event is not being triggere ...

When the function $(document).width() is called, it may yield varying results depending on the timing of the call

Every time I use $(document).width(); within $(window).load(function(){}) or $(document).ready(function(){}), the result differs from when it is called inside $(window).resize(function(){}). The discrepancy is approximately 100px, and it's not due to ...

Using Javascript to Highlight a Single Row in a Table

Greetings esteemed members of the skilled community at StackOverflow, I must humbly ask for your expertise in solving a dilemma that I am currently facing. The situation is as follows: I have a table generated from an SQL query, and it is crucial for the ...

Searching to loop through JSON within a Sequelize / Postgres database query in order to identify a corresponding value

Hello everyone, I'm new here so please bear with me. I'm currently working on a project using Sequelize with PostgresDB in Node and I need to search for a contact by email using findOrCreate function. The email entry is stored in JSON format (se ...

Need help figuring out how to use Javascript:void(0) to click a button in Selenium?

Struggling with finding the right solution, I have attempted various methods. Apologies for any formatting errors, but the element that requires clicking is: <button href="javascript:void(0)" id="payNewBeneficiary" class="button-new-payee"> ...

Is there a more concise method in Vue to transmit data from the script section to the template section aside from utilizing a function?

My current code structure is as follows: <template> ..somecode {{showEditFlag}} </template> <script> export default{ data: function() { return { showEditFlag }; } } </script> Could it be simplified to something like this in ...