persepolisdm / Persepolis-WebExtension

WebExtension integration for Persepolis download manager
http://persepolisdm.github.io
GNU General Public License v3.0
73 stars 9 forks source link

Fix Persepolis connection issues with Manifest v3 #57

Open JafarAkhondali opened 4 months ago

khaled-0 commented 4 months ago

Progress image

It seems like persopolis creates / overwrites pdmchromewrapper.json somewhere. And the extension Id's doesn't match For now I've created com.persepolis.pdmchromewrapperv3.json with new extension id

{"name": "com.persepolis.pdmchromewrapperv3", "type": "stdio", "path": "/home/khaled/.config/persepolis_download_manager/persepolis_run_shell", "description": "Integrate Persepolis with chromium using WebExtensions", "allowed_origins": ["chrome-extension://celnpdgacgkldkephdonlhjncjiaifdp/"]}

Changed honsName in backgrund.js to const hostName = 'com.persepolis.pdmchromewrapperv3';

And patched some broken api (dirty fix) to check the connection. It seems to work

https://github.com/persepolisdm/persepolis/blob/658fed8601d6defd79f38923c3e0905b0d8bf63f/persepolis/scripts/browser_integration.py#L158 There must be another way instead of hardcoding the extension id ?? right??

Found a way

edit manifest to include

  "key":"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAoCgWSDIitikIuLvTLERSUeSSRobagH6W9yZNsC+1+3XVX8Ae83ZPGbjuHhb4J2vQzSDfr2TiWeLya2z54JH2KCVTHdr++Mf8xlykobf83/HTu2LcQzI7RPb53KWgGMrEszuRQdxhSeYwogCR6BDQaRqRmBbsAg40VuLI53KtXrvESu3gNtDdIpG/S1EIxK6VnwXL+UXxVmPQxQ0tFyTX5R0tyBdbKAx7UwT9z8fQN4PP4QBHFzU4Pqrln66evdYb5NpZw9RAZxhLW4chk4kK2BMz4Ym10J1yOjvZ4w9MBHJsIn38EJSfYSDWOlUReZNoQXHN4J6UhMQbuWEZO6SbVwIDAQAB",

And the id will be same as current persopolis extension The key is the public key of current extension btw. Got by running chrome.runtime.getManifest().key

JafarAkhondali commented 4 months ago

Hello Khaled, Thanks for your help!

I believe the ID (not sure about the "key") changes with different installations on different systems. The Id that have been hardcoded before, was obtained after install extension from the web store, in the browser. Also, I forgot to mention that the manifest.json here is not required and must be removed. Firefox and chrome have different manifest, only the code is shared. you can see it in: https://github.com/persepolisdm/Persepolis-WebExtension/blob/master/packager.sh

JafarAkhondali commented 4 months ago

If you achieve a stable connection, try to debug other features of extension on both browsers. Like these features:

  1. Automatic download canceling and sending it to Persepolis
  2. (context menu) Download All links
  3. (context menu) Download selected links
khaled-0 commented 4 months ago

Hello Khaled, Thanks for your help!

I believe the ID (not sure about the "key") changes with different installations on different systems. The Id that have been hardcoded before, was obtained after install extension from the web store, in the browser. Also, I forgot to mention that the manifest.json here is not required and must be removed. Firefox and chrome have different manifest, only the code is shared. you can see it in: https://github.com/persepolisdm/Persepolis-WebExtension/blob/master/packager.sh

hey , yeah the key here is for debugging purposes only by including the key, the extension id stays the same as hardcoded in persopolis(the web store's id) This was the problem the native messaging was broken. I doubt there's any other issue about the connection as I've got a pretty stable one. But I'll test and update further along the way. #58

When packaging the extension and uploading it to the store , the key will be same as defined in persopolis without that manifest.json var anyway.

khaled-0 commented 4 months ago

Hey, When you can, please review #58
I'll began cleaning / refactoring some stuffs after your review. Thanks