Skip to content

Instantly share code, notes, and snippets.

@brandonvanha
Forked from dance2die/popup.js
Created July 9, 2022 08:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brandonvanha/5f4e3e67eb2ee4e59318724625c12494 to your computer and use it in GitHub Desktop.
Save brandonvanha/5f4e3e67eb2ee4e59318724625c12494 to your computer and use it in GitHub Desktop.
chrome.tabs.query(
{ active: true, windowId: chrome.windows.WINDOW_ID_CURRENT },
function(tabs) {
const { id: tabId } = tabs[0].url;
let code = `document.querySelector('h1')`;
// http://infoheap.com/chrome-extension-tutorial-access-dom/
chrome.tabs.executeScript(tabId, { code }, function (result) {
// result has the return value from `code`
});
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment