Chrome extension: Attaching current tab to popup and then going through its DOM -


I am in the process of creating a Google Chrome extension, and faced a problem.

I am trying to upload and search through the DOM inside html popup html.

Here's how I get the current tab (I got a script more elsewhere, I do not have the credit):

  chrome.windows.getCurrent (function (W) {chrome.tabs.get selected (w.id, function (response) {}};  

My problem is this: I need to cross the response via the DOM So when I was trying to do it manually, I could not because the response variable is now unspecified for some reason So the use of the console is not an option. Response to the HTML file, it came in the form of an object. Then, I tried to navigate through the feedback as if it is a 'document' object, but no luck No.

Any help would be appreciated by many.

You can get selected tabs for the page in the form of window id to select Opup by moving redundant. () In your popup you can listen for expansion events and execute a script to push content into your popup:

  chrome.extension.onRequest AddListener (function (request, sender, sendResponse) {if (request.action == "content") {console.log ('content is' request.content.length + 'bytes');}}); Chrome.tabs.get selected (empty, function (tab) {chrome.tabs.executeScript (tab.id, {file: 'scripts / SendContent.js'})}};  

And finally the content script ... I have the "script / sand content.jess" in my extensions folder, but the script is quite simple, you can execute it by inserting the code name instead of the property name The assets of which you pass to execute the object:

  console.log ('SendContent.js'); Chrome.extension.sendRequest ({Action: "s Content: document.body.inner HTML}, function (response) {});  

Result:

  Code> Popup: content is 67533 bytes  

If you are having trouble, use the console Log in and right-click on your page or browser action and inspect it and consoles Read your message on (or debug your script from there).


Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -