Hacker News new | ask | show | jobs
by dotproto 1840 days ago
Sure. If you're the only one using it, you can just run the extension locally as an unpacked extension. Check out the step-by-step getting started guide: https://developer.chrome.com/docs/extensions/mv3/getstarted/

For your case, you'll probably want to save the bookmarklet as a JS file, let's say content.js, and inject in when you click the extension's icon. Here's the basics to get you started.

manifest.json

  {
    "name": "Demo",
    "version": "1.0",
    "manifest_version": 3,
    "permissions": [
      "scripting",
      "activeTab"
    ],
    "background": {
      "service_worker": "background.js"
    },
    "action": {}
  }

background.js

  chrome.action.onClicked.addListener((tab) => {
    chrome.scripting.executeScript({
      target: {tabId: tab.id},
      files: ['content.js'],
    });
  });

content.js

  alert('It worked!');