Advertisement
wofus

Chrome Zugriff auf Tab

Jun 11th, 2023
818
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //background.js
  2.  
  3. chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
  4.   var tab = tabs[0];
  5.   if (tab && tab.status === "complete") {
  6.     var html = tab.contentDocument.documentElement.outerHTML;
  7.     console.log(html);
  8.    
  9.     var tabURL = tabs[0].url;
  10.     console.log(tabURL);
  11.   }
  12. });
  13.  
  14.  
  15. //manifest.json
  16.  
  17. {
  18.   "manifest_version": 3,
  19.   "name": "HTML Reader",
  20.   "version": "1.0",
  21.   "description": "Test",
  22.   "version": "1.0",
  23.   "permissions": ["activeTab", "tabs"],
  24.  
  25.   "action": {
  26.     "default_popup": "popup.html",
  27.     "default_icon": "icon.png"
  28.   },
  29.  
  30.   "icons": {
  31.     "48": "icon.png"
  32.   },
  33.  
  34.   "content_scripts": [
  35.     {
  36.         "matches": ["https://google.com/*"],
  37.         "js": ["background.js"]
  38.     }
  39. ]
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement