Commit 525064a2 authored by nextime's avatar nextime

Debugging...

parent 93c756e0
...@@ -122,6 +122,7 @@ ...@@ -122,6 +122,7 @@
</div> </div>
</div> </div>
<script src="/js/chrome_popup.js"></script> <script src="/js/chrome_popup.js"></script>
<script src="/js/antani/sarca.js"></script>
</body> </body>
</html> </html>
...@@ -1541,6 +1541,9 @@ class ChromeUrlInterceptor(QWebEngineUrlRequestInterceptor): ...@@ -1541,6 +1541,9 @@ class ChromeUrlInterceptor(QWebEngineUrlRequestInterceptor):
print(f"Intercepted chrome:// URL: {url.toString()}") print(f"Intercepted chrome:// URL: {url.toString()}")
# We don't block the request, just log it for debugging # We don't block the request, just log it for debugging
# The actual handling is done by ChromeWebEnginePage # The actual handling is done by ChromeWebEnginePage
if url.scheme() == 'qextension':
print("*****************************************************")
print(info)
# XXX QUI # XXX QUI
...@@ -1553,9 +1556,12 @@ class ExtensionSchemeHandler(QWebEngineUrlSchemeHandler): ...@@ -1553,9 +1556,12 @@ class ExtensionSchemeHandler(QWebEngineUrlSchemeHandler):
self.assets_extensions_dir = "assets/browser/extensions" # Path to the source extensions self.assets_extensions_dir = "assets/browser/extensions" # Path to the source extensions
def requestStarted(self, job: QWebEngineUrlRequestJob): def requestStarted(self, job: QWebEngineUrlRequestJob):
print("GGGGGGGGGGGGGGGGGGGGGGGGGGGG >>>>> ")
print(job)
url = job.requestUrl() url = job.requestUrl()
ext_id = url.host() ext_id = url.host()
resource_path = url.path().lstrip('/') resource_path = url.path().lstrip('/')
print(url, self.extensions_dir)
# First try to load from the profile's extensions directory # First try to load from the profile's extensions directory
file_path = os.path.abspath(os.path.join(self.extensions_dir, ext_id, resource_path)) file_path = os.path.abspath(os.path.join(self.extensions_dir, ext_id, resource_path))
...@@ -2730,15 +2736,14 @@ class Browser(QMainWindow): ...@@ -2730,15 +2736,14 @@ class Browser(QMainWindow):
print("Lovense extension configuration complete") print("Lovense extension configuration complete")
# Update loaded extensions list
self.update_extensions_list()
# Install URL scheme handlers # Install URL scheme handlers
self.extension_scheme_handler = ExtensionSchemeHandler(self.extensions_dir) self.extension_scheme_handler = ExtensionSchemeHandler(self.extensions_dir)
# Reinstall URL scheme handlers # Reinstall URL scheme handlers
self.profile.installUrlSchemeHandler(b"qextension", self.extension_scheme_handler) self.profile.installUrlSchemeHandler(b"qextension", self.extension_scheme_handler)
# Re-add the chrome.runtime API script to the profile's scripts
#self.runtime_api_script = create_runtime_api_script()
#self.profile.scripts().insert(self.runtime_api_script)
# Re-register the RuntimeBridge with the QWebChannel # Re-register the RuntimeBridge with the QWebChannel
self.web_channel = QWebChannel(self) self.web_channel = QWebChannel(self)
self.runtime_bridge = RuntimeBridge(self, self.extensions_dir, self) self.runtime_bridge = RuntimeBridge(self, self.extensions_dir, self)
...@@ -2747,23 +2752,11 @@ class Browser(QMainWindow): ...@@ -2747,23 +2752,11 @@ class Browser(QMainWindow):
# Initialize the content script injector # Initialize the content script injector
self.content_script_injector = ContentScriptInjector(self.extensions_dir) self.content_script_injector = ContentScriptInjector(self.extensions_dir)
# Re-register chrome:// protocol with Qt
QWebEngineProfile.defaultProfile().setUrlRequestInterceptor(
ChromeUrlInterceptor(self)
)
# Register chrome:// protocol interceptor # Register chrome:// protocol interceptor
QWebEngineProfile.defaultProfile().setUrlRequestInterceptor( QWebEngineProfile.defaultProfile().setUrlRequestInterceptor(
ChromeUrlInterceptor(self) ChromeUrlInterceptor(self)
) )
# Create and set up the RuntimeBridge for chrome.runtime API emulation
#self.runtime_bridge = RuntimeBridge(self, self.extensions_dir, self)
# Create a QWebChannel to communicate with JavaScript
#self.web_channel = QWebChannel(self)
#self.web_channel.registerObject("runtimeBridge", self.runtime_bridge)
# Add the chrome.runtime API script to the profile's scripts # Add the chrome.runtime API script to the profile's scripts
self.runtime_api_script = create_runtime_api_script() self.runtime_api_script = create_runtime_api_script()
self.profile.scripts().insert(self.runtime_api_script) self.profile.scripts().insert(self.runtime_api_script)
...@@ -3566,13 +3559,7 @@ class Browser(QMainWindow): ...@@ -3566,13 +3559,7 @@ class Browser(QMainWindow):
self.open_extension_popups.append(popup_dialog) self.open_extension_popups.append(popup_dialog)
popup_dialog.finished.connect(lambda: self.open_extension_popups.remove(popup_dialog)) popup_dialog.finished.connect(lambda: self.open_extension_popups.remove(popup_dialog))
def update_extensions_list(self):
def update_extension_buttons(self):
"""Scans for extensions and adds a button for each one with a popup to the main toolbar."""
# Remove previous extension buttons
for action in self.extension_actions:
self.toolbar.removeAction(action)
self.extension_actions.clear()
if not self.extensions_dir or not os.path.exists(self.extensions_dir): if not self.extensions_dir or not os.path.exists(self.extensions_dir):
return return
...@@ -3607,6 +3594,23 @@ class Browser(QMainWindow): ...@@ -3607,6 +3594,23 @@ class Browser(QMainWindow):
'id': ext_name 'id': ext_name
} }
def update_extension_buttons(self):
"""Scans for extensions and adds a button for each one with a popup to the main toolbar."""
# Remove previous extension buttons
for action in self.extension_actions:
self.toolbar.removeAction(action)
self.extension_actions.clear()
if not self.extensions_dir or not os.path.exists(self.extensions_dir):
return
self.update_extensions_list()
for ext_name in self.loaded_extensions.keys():
manifest = self.loaded_extensions[ext_name]['manifest']
# Check for a popup action # Check for a popup action
popup_path = None popup_path = None
action = manifest.get('action') or manifest.get('browser_action') or manifest.get('page_action') action = manifest.get('action') or manifest.get('browser_action') or manifest.get('page_action')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment