fix: Add error handling for script injection and improve logging for URL mappings
This commit is contained in:
parent
0eba82b8af
commit
4011f46ab7
2 changed files with 69 additions and 36 deletions
|
|
@ -2,29 +2,30 @@
|
|||
// Prevents browser drag for ALT+drag, hands off to Qt for file drag
|
||||
|
||||
(function() {
|
||||
if (window.__webdrop_intercept_injected) return;
|
||||
window.__webdrop_intercept_injected = true;
|
||||
try {
|
||||
if (window.__webdrop_intercept_injected) return;
|
||||
window.__webdrop_intercept_injected = true;
|
||||
|
||||
// Intercept mode enabled
|
||||
var INTERCEPT_ENABLED = true;
|
||||
// Intercept mode enabled
|
||||
var INTERCEPT_ENABLED = true;
|
||||
|
||||
console.log('%c[WebDrop Intercept] Script loaded - INTERCEPT_ENABLED=' + INTERCEPT_ENABLED, 'background: #2196F3; color: white; font-weight: bold; padding: 4px 8px;');
|
||||
|
||||
var currentDragUrl = null;
|
||||
var angularDragHandlers = [];
|
||||
var originalAddEventListener = EventTarget.prototype.addEventListener;
|
||||
var listenerPatchActive = true;
|
||||
|
||||
// Capture Authorization token from XHR requests
|
||||
window.capturedAuthToken = null;
|
||||
var originalXHRSetRequestHeader = XMLHttpRequest.prototype.setRequestHeader;
|
||||
XMLHttpRequest.prototype.setRequestHeader = function(header, value) {
|
||||
if (header === 'Authorization' && value.startsWith('Bearer ')) {
|
||||
window.capturedAuthToken = value;
|
||||
console.log('[Intercept] Captured auth token');
|
||||
}
|
||||
return originalXHRSetRequestHeader.apply(this, arguments);
|
||||
};
|
||||
console.log('%c[WebDrop Intercept] Script loaded - INTERCEPT_ENABLED=' + INTERCEPT_ENABLED, 'background: #2196F3; color: white; font-weight: bold; padding: 4px 8px;');
|
||||
|
||||
var currentDragUrl = null;
|
||||
var angularDragHandlers = [];
|
||||
var originalAddEventListener = EventTarget.prototype.addEventListener;
|
||||
var listenerPatchActive = true;
|
||||
|
||||
// Capture Authorization token from XHR requests
|
||||
window.capturedAuthToken = null;
|
||||
var originalXHRSetRequestHeader = XMLHttpRequest.prototype.setRequestHeader;
|
||||
XMLHttpRequest.prototype.setRequestHeader = function(header, value) {
|
||||
if (header === 'Authorization' && value.startsWith('Bearer ')) {
|
||||
window.capturedAuthToken = value;
|
||||
console.log('[Intercept] Captured auth token');
|
||||
}
|
||||
return originalXHRSetRequestHeader.apply(this, arguments);
|
||||
};
|
||||
|
||||
// ============================================================================
|
||||
// PART 1: Intercept Angular's dragstart listener registration
|
||||
|
|
@ -189,4 +190,8 @@
|
|||
|
||||
console.log('%c[WebDrop Intercept] Ready! ALT-drag will use Qt file drag.',
|
||||
'background: #4CAF50; color: white; font-weight: bold; padding: 4px 8px;');
|
||||
} catch(e) {
|
||||
console.error('[WebDrop Intercept] FATAL ERROR in bridge script:', e);
|
||||
console.error('[WebDrop Intercept] Stack:', e.stack);
|
||||
}
|
||||
})();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue