I am trying to make a bookmarklet to Chrome extension converter that makes MV3 extensions. I cant get the extension to run the code when clicked. It just gives the default popup for extensions.
This is the relevant part of my code:
json = """
{
"name": "%s",
"description": "%s",
"version": "1.0",
"manifest_version": 3,
"minimum_chrome_version": "120",
"background": {
"serviceworker": "main.js"
},
"permissions": [
"userScripts",
"activeTab"
],
"host_permissions": [
"*://*/*"
]
}
""" % ( name, description)
mainjs = """
chrome.action.onClicked.addListener((tab) => {
target: {tabId: tab.id},
async chrome.userScripts.register({
id: 'bookmarklet',
matches: ['*://*/*'],
js: [{ file: 'user-script.js' }]
});
});
"""
with open('manifest.json', 'w') as manifest:
manifest.write(json)
with open('main.js', 'w') as main:
main.write(mainjs)
with open('user-script.js', 'w') as us:
us.write(code)
I've tried changing various parts of mainjs but nothing has worked.