@gxp-dev/tools 2.0.63 → 2.0.64

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (182) hide show
  1. package/README.md +32 -31
  2. package/bin/gx-devtools.js +74 -54
  3. package/bin/lib/cli.js +23 -21
  4. package/bin/lib/commands/add-dependency.js +366 -325
  5. package/bin/lib/commands/assets.js +137 -139
  6. package/bin/lib/commands/build.js +169 -174
  7. package/bin/lib/commands/datastore.js +181 -183
  8. package/bin/lib/commands/dev.js +127 -131
  9. package/bin/lib/commands/extensions.js +147 -149
  10. package/bin/lib/commands/extract-config.js +73 -67
  11. package/bin/lib/commands/index.js +12 -12
  12. package/bin/lib/commands/init.js +342 -240
  13. package/bin/lib/commands/publish.js +69 -75
  14. package/bin/lib/commands/socket.js +69 -69
  15. package/bin/lib/commands/ssl.js +14 -14
  16. package/bin/lib/constants.js +10 -24
  17. package/bin/lib/tui/App.tsx +761 -705
  18. package/bin/lib/tui/components/AIPanel.tsx +191 -171
  19. package/bin/lib/tui/components/CommandInput.tsx +394 -343
  20. package/bin/lib/tui/components/GeminiPanel.tsx +175 -151
  21. package/bin/lib/tui/components/Header.tsx +23 -21
  22. package/bin/lib/tui/components/LogPanel.tsx +244 -220
  23. package/bin/lib/tui/components/TabBar.tsx +50 -48
  24. package/bin/lib/tui/components/WelcomeScreen.tsx +126 -71
  25. package/bin/lib/tui/index.tsx +37 -39
  26. package/bin/lib/tui/services/AIService.ts +518 -462
  27. package/bin/lib/tui/services/ExtensionService.ts +140 -129
  28. package/bin/lib/tui/services/GeminiService.ts +367 -337
  29. package/bin/lib/tui/services/ServiceManager.ts +344 -322
  30. package/bin/lib/tui/services/SocketService.ts +168 -168
  31. package/bin/lib/tui/services/ViteService.ts +88 -88
  32. package/bin/lib/tui/services/index.ts +47 -22
  33. package/bin/lib/utils/ai-scaffold.js +291 -280
  34. package/bin/lib/utils/extract-config.js +157 -140
  35. package/bin/lib/utils/files.js +82 -86
  36. package/bin/lib/utils/index.js +7 -7
  37. package/bin/lib/utils/paths.js +34 -34
  38. package/bin/lib/utils/prompts.js +194 -169
  39. package/bin/lib/utils/ssl.js +79 -81
  40. package/browser-extensions/README.md +0 -1
  41. package/browser-extensions/chrome/background.js +244 -237
  42. package/browser-extensions/chrome/content.js +32 -29
  43. package/browser-extensions/chrome/devtools.html +7 -7
  44. package/browser-extensions/chrome/devtools.js +19 -19
  45. package/browser-extensions/chrome/inspector.js +802 -767
  46. package/browser-extensions/chrome/manifest.json +71 -63
  47. package/browser-extensions/chrome/panel.html +674 -636
  48. package/browser-extensions/chrome/panel.js +722 -712
  49. package/browser-extensions/chrome/popup.html +586 -543
  50. package/browser-extensions/chrome/popup.js +282 -244
  51. package/browser-extensions/chrome/rules.json +1 -1
  52. package/browser-extensions/chrome/test-chrome.html +216 -136
  53. package/browser-extensions/chrome/test-mixed-content.html +284 -189
  54. package/browser-extensions/chrome/test-uri-pattern.html +221 -198
  55. package/browser-extensions/firefox/README.md +9 -6
  56. package/browser-extensions/firefox/background.js +221 -218
  57. package/browser-extensions/firefox/content.js +55 -52
  58. package/browser-extensions/firefox/debug-errors.html +386 -228
  59. package/browser-extensions/firefox/debug-https.html +153 -105
  60. package/browser-extensions/firefox/devtools.html +7 -7
  61. package/browser-extensions/firefox/devtools.js +23 -20
  62. package/browser-extensions/firefox/inspector.js +802 -767
  63. package/browser-extensions/firefox/manifest.json +68 -68
  64. package/browser-extensions/firefox/panel.html +674 -636
  65. package/browser-extensions/firefox/panel.js +722 -712
  66. package/browser-extensions/firefox/popup.html +572 -535
  67. package/browser-extensions/firefox/popup.js +281 -236
  68. package/browser-extensions/firefox/test-gramercy.html +170 -125
  69. package/browser-extensions/firefox/test-imports.html +59 -55
  70. package/browser-extensions/firefox/test-masking.html +231 -140
  71. package/browser-extensions/firefox/test-uri-pattern.html +221 -198
  72. package/dist/tui/App.d.ts +1 -1
  73. package/dist/tui/App.d.ts.map +1 -1
  74. package/dist/tui/App.js +154 -150
  75. package/dist/tui/App.js.map +1 -1
  76. package/dist/tui/components/AIPanel.d.ts.map +1 -1
  77. package/dist/tui/components/AIPanel.js +42 -35
  78. package/dist/tui/components/AIPanel.js.map +1 -1
  79. package/dist/tui/components/CommandInput.d.ts +1 -1
  80. package/dist/tui/components/CommandInput.d.ts.map +1 -1
  81. package/dist/tui/components/CommandInput.js +92 -62
  82. package/dist/tui/components/CommandInput.js.map +1 -1
  83. package/dist/tui/components/GeminiPanel.d.ts.map +1 -1
  84. package/dist/tui/components/GeminiPanel.js +37 -30
  85. package/dist/tui/components/GeminiPanel.js.map +1 -1
  86. package/dist/tui/components/Header.d.ts.map +1 -1
  87. package/dist/tui/components/Header.js +1 -1
  88. package/dist/tui/components/Header.js.map +1 -1
  89. package/dist/tui/components/LogPanel.d.ts +1 -1
  90. package/dist/tui/components/LogPanel.d.ts.map +1 -1
  91. package/dist/tui/components/LogPanel.js +26 -24
  92. package/dist/tui/components/LogPanel.js.map +1 -1
  93. package/dist/tui/components/TabBar.d.ts +2 -2
  94. package/dist/tui/components/TabBar.d.ts.map +1 -1
  95. package/dist/tui/components/TabBar.js +11 -11
  96. package/dist/tui/components/TabBar.js.map +1 -1
  97. package/dist/tui/components/WelcomeScreen.d.ts.map +1 -1
  98. package/dist/tui/components/WelcomeScreen.js +6 -6
  99. package/dist/tui/components/WelcomeScreen.js.map +1 -1
  100. package/dist/tui/index.d.ts.map +1 -1
  101. package/dist/tui/index.js +8 -8
  102. package/dist/tui/index.js.map +1 -1
  103. package/dist/tui/services/AIService.d.ts +2 -2
  104. package/dist/tui/services/AIService.d.ts.map +1 -1
  105. package/dist/tui/services/AIService.js +165 -125
  106. package/dist/tui/services/AIService.js.map +1 -1
  107. package/dist/tui/services/ExtensionService.d.ts +1 -1
  108. package/dist/tui/services/ExtensionService.d.ts.map +1 -1
  109. package/dist/tui/services/ExtensionService.js +33 -26
  110. package/dist/tui/services/ExtensionService.js.map +1 -1
  111. package/dist/tui/services/GeminiService.d.ts +1 -1
  112. package/dist/tui/services/GeminiService.d.ts.map +1 -1
  113. package/dist/tui/services/GeminiService.js +87 -76
  114. package/dist/tui/services/GeminiService.js.map +1 -1
  115. package/dist/tui/services/ServiceManager.d.ts +3 -3
  116. package/dist/tui/services/ServiceManager.d.ts.map +1 -1
  117. package/dist/tui/services/ServiceManager.js +72 -58
  118. package/dist/tui/services/ServiceManager.js.map +1 -1
  119. package/dist/tui/services/SocketService.d.ts.map +1 -1
  120. package/dist/tui/services/SocketService.js +32 -32
  121. package/dist/tui/services/SocketService.js.map +1 -1
  122. package/dist/tui/services/ViteService.d.ts.map +1 -1
  123. package/dist/tui/services/ViteService.js +26 -28
  124. package/dist/tui/services/ViteService.js.map +1 -1
  125. package/dist/tui/services/index.d.ts +6 -6
  126. package/dist/tui/services/index.d.ts.map +1 -1
  127. package/dist/tui/services/index.js +6 -6
  128. package/dist/tui/services/index.js.map +1 -1
  129. package/mcp/gxp-api-server.js +83 -81
  130. package/package.json +109 -93
  131. package/runtime/PortalContainer.vue +258 -234
  132. package/runtime/dev-tools/DevToolsModal.vue +153 -155
  133. package/runtime/dev-tools/LayoutSwitcher.vue +144 -140
  134. package/runtime/dev-tools/MockDataEditor.vue +456 -433
  135. package/runtime/dev-tools/SocketSimulator.vue +379 -371
  136. package/runtime/dev-tools/StoreInspector.vue +517 -455
  137. package/runtime/dev-tools/index.js +5 -5
  138. package/runtime/fallback-layouts/PrivateLayout.vue +2 -2
  139. package/runtime/fallback-layouts/PublicLayout.vue +2 -2
  140. package/runtime/fallback-layouts/SystemLayout.vue +2 -2
  141. package/runtime/gxpStringsPlugin.js +159 -134
  142. package/runtime/index.html +17 -19
  143. package/runtime/main.js +24 -22
  144. package/runtime/mock-api/auth-middleware.js +15 -15
  145. package/runtime/mock-api/image-generator.js +46 -46
  146. package/runtime/mock-api/index.js +55 -55
  147. package/runtime/mock-api/response-generator.js +116 -105
  148. package/runtime/mock-api/route-generator.js +107 -84
  149. package/runtime/mock-api/socket-triggers.js +94 -93
  150. package/runtime/mock-api/spec-loader.js +79 -80
  151. package/runtime/package.json +3 -0
  152. package/runtime/server.js +68 -68
  153. package/runtime/stores/gxpPortalConfigStore.js +204 -186
  154. package/runtime/stores/index.js +2 -2
  155. package/runtime/vite-inspector-plugin.js +858 -707
  156. package/runtime/vite-source-tracker-plugin.js +132 -113
  157. package/runtime/vite.config.js +191 -139
  158. package/scripts/launch-chrome.js +41 -41
  159. package/scripts/pack-chrome.js +38 -39
  160. package/socket-events/AiSessionMessageCreated.json +17 -17
  161. package/socket-events/SocialStreamPostCreated.json +23 -23
  162. package/socket-events/SocialStreamPostVariantCompleted.json +22 -22
  163. package/template/.claude/agents/gxp-developer.md +100 -99
  164. package/template/.claude/settings.json +7 -7
  165. package/template/AGENTS.md +30 -23
  166. package/template/GEMINI.md +20 -20
  167. package/template/README.md +70 -53
  168. package/template/app-manifest.json +2 -4
  169. package/template/configuration.json +10 -10
  170. package/template/default-styling.css +1 -1
  171. package/template/index.html +18 -20
  172. package/template/main.js +24 -22
  173. package/template/src/DemoPage.vue +415 -362
  174. package/template/src/Plugin.vue +76 -85
  175. package/template/src/stores/index.js +3 -3
  176. package/template/src/stores/test-data.json +164 -172
  177. package/template/theme-layouts/AdditionalStyling.css +50 -50
  178. package/template/theme-layouts/PrivateLayout.vue +8 -12
  179. package/template/theme-layouts/PublicLayout.vue +8 -12
  180. package/template/theme-layouts/SystemLayout.vue +8 -12
  181. package/template/vite.extend.js +45 -0
  182. package/template/vite.config.js +0 -409
@@ -1,229 +1,387 @@
1
- <!DOCTYPE html>
1
+ <!doctype html>
2
2
  <html>
3
- <head>
4
- <title>Debug Proxy Errors</title>
5
- <style>
6
- body { font-family: Arial, sans-serif; padding: 20px; max-width: 1000px; }
7
- .section { margin: 20px 0; padding: 20px; border: 2px solid #ddd; border-radius: 8px; }
8
- .error { border-color: #dc3545; background: #fff5f5; }
9
- .success { border-color: #28a745; background: #f8fff8; }
10
- .warning { border-color: #ffc107; background: #fffbf0; }
11
- .info { border-color: #17a2b8; background: #f0f9ff; }
12
- .code { background: #e9ecef; padding: 8px; font-family: monospace; margin: 8px 0; word-break: break-all; }
13
- .results { background: #f5f5f5; padding: 10px; margin: 10px 0; border-radius: 4px; max-height: 300px; overflow-y: auto; }
14
- button { padding: 10px 15px; margin: 5px; cursor: pointer; background: #007bff; color: white; border: none; border-radius: 4px; }
15
- .error-btn { background: #dc3545; }
16
- .success-btn { background: #28a745; }
17
- table { width: 100%; border-collapse: collapse; margin: 10px 0; }
18
- th, td { border: 1px solid #ddd; padding: 8px; text-align: left; }
19
- th { background: #f8f9fa; }
20
- </style>
21
- </head>
22
- <body>
23
- <h1>🐛 Debug Proxy Errors</h1>
24
-
25
- <div class="section error">
26
- <h2>❌ Common Firefox Errors</h2>
27
- <table>
28
- <tr>
29
- <th>Error</th>
30
- <th>Meaning</th>
31
- <th>Common Causes</th>
32
- </tr>
33
- <tr>
34
- <td><code>ns_binding_aborted</code></td>
35
- <td>Network request was cancelled</td>
36
- <td>Redirect loops, Invalid redirects, Extension conflicts</td>
37
- </tr>
38
- <tr>
39
- <td><code>ns_error_corrupted_content</code></td>
40
- <td>Content corruption or invalid response</td>
41
- <td>Header issues, CORS problems, Content-encoding conflicts</td>
42
- </tr>
43
- <tr>
44
- <td><code>ns_error_net_reset</code></td>
45
- <td>Connection was reset</td>
46
- <td>Server rejection, Proxy server issues</td>
47
- </tr>
48
- </table>
49
- </div>
50
-
51
- <div class="section warning">
52
- <h2>⚠️ Quick Fixes</h2>
53
- <ol>
54
- <li><strong>Check for redirect loops:</strong> Make sure your redirect target doesn't match your pattern</li>
55
- <li><strong>Use redirect mode first:</strong> Disable "Mask URL" to test basic functionality</li>
56
- <li><strong>Test with simple domains:</strong> Try redirecting to a known working server first</li>
57
- <li><strong>Check proxy server:</strong> Ensure your target server can handle the requests</li>
58
- </ol>
59
- </div>
60
-
61
- <div class="section info">
62
- <h2>🔍 Diagnostic Tests</h2>
63
- <button onclick="checkExtensionStatus()">Check Extension Status</button>
64
- <button onclick="testSimpleRedirect()">Test Simple Redirect</button>
65
- <button onclick="testProblematicURL()">Test Problematic URL</button>
66
- <button onclick="analyzeRules()">Analyze Rules for Loops</button>
67
- <button class="error-btn" onclick="clearLogs()">Clear Logs</button>
68
- <div id="diagnosticResults" class="results"></div>
69
- </div>
70
-
71
- <div class="section success">
72
- <h2>✅ Troubleshooting Steps</h2>
73
- <div id="troubleshootingSteps">
74
- <h3>Step 1: Verify Extension State</h3>
75
- <button onclick="runTroubleshootingStep(1)">Run Step 1</button>
76
- <div id="step1Results" class="results"></div>
77
-
78
- <h3>Step 2: Test Without Masking</h3>
79
- <button onclick="runTroubleshootingStep(2)">Run Step 2</button>
80
- <div id="step2Results" class="results"></div>
81
-
82
- <h3>Step 3: Check for Redirect Loops</h3>
83
- <button onclick="runTroubleshootingStep(3)">Run Step 3</button>
84
- <div id="step3Results" class="results"></div>
85
- </div>
86
- </div>
87
-
88
- <script>
89
- function log(elementId, message, type = 'info') {
90
- const element = document.getElementById(elementId);
91
- const timestamp = new Date().toLocaleTimeString();
92
- const icon = type === 'error' ? '❌' : type === 'success' ? '✅' : type === 'warning' ? '⚠️' : 'ℹ️';
93
- element.innerHTML += `<div>${timestamp} ${icon} ${message}</div>`;
94
- }
95
-
96
- function clearLogs() {
97
- const logElements = ['diagnosticResults', 'step1Results', 'step2Results', 'step3Results'];
98
- logElements.forEach(id => {
99
- const element = document.getElementById(id);
100
- if (element) element.innerHTML = '';
101
- });
102
- }
103
-
104
- async function checkExtensionStatus() {
105
- log('diagnosticResults', 'Checking extension status...');
106
-
107
- try {
108
- if (typeof browser === 'undefined') {
109
- log('diagnosticResults', 'Browser API not available - extension not loaded', 'error');
110
- return;
111
- }
112
-
113
- const state = await browser.runtime.sendMessage({ action: 'getState' });
114
- log('diagnosticResults', `Extension enabled: ${state.enabled}`, 'success');
115
- log('diagnosticResults', `Number of rules: ${state.rules.length}`, 'info');
116
-
117
- state.rules.forEach((rule, index) => {
118
- log('diagnosticResults', `Rule ${index + 1}: ${rule.pattern} → ${rule.redirect} (Mask: ${rule.maskUrl || false})`, 'info');
119
- });
120
-
121
- } catch (error) {
122
- log('diagnosticResults', `Extension communication failed: ${error.message}`, 'error');
123
- }
124
- }
125
-
126
- async function testSimpleRedirect() {
127
- log('diagnosticResults', 'Testing simple redirect with known good server...');
128
-
129
- try {
130
- // Test with a simple, reliable endpoint
131
- const response = await fetch('https://httpbin.org/get?test=simple');
132
- const data = await response.json();
133
- log('diagnosticResults', `Simple test successful: ${response.status}`, 'success');
134
- log('diagnosticResults', `Response URL: ${data.url}`, 'info');
135
- } catch (error) {
136
- log('diagnosticResults', `Simple test failed: ${error.message}`, 'error');
137
- log('diagnosticResults', 'This suggests a configuration issue with your rules', 'warning');
138
- }
139
- }
140
-
141
- async function testProblematicURL() {
142
- log('diagnosticResults', 'Testing the problematic gramercy.cloud URL...');
143
-
144
- const testUrl = 'https://hilton-pop-art-cytz-dani-martin-hueg.gramercy.cloud/uploads/assets/test.png';
145
-
146
- try {
147
- const response = await fetch(testUrl);
148
- log('diagnosticResults', `Gramercy test: ${response.status} ${response.statusText}`, 'success');
149
- } catch (error) {
150
- log('diagnosticResults', `Gramercy test failed: ${error.message}`, 'error');
151
-
152
- if (error.message.includes('ns_binding_aborted')) {
153
- log('diagnosticResults', '→ Likely cause: Redirect loop or invalid redirect target', 'warning');
154
- } else if (error.message.includes('ns_error_corrupted_content')) {
155
- log('diagnosticResults', '→ Likely cause: Header modification issues or server response problems', 'warning');
156
- }
157
- }
158
- }
159
-
160
- async function analyzeRules() {
161
- log('diagnosticResults', 'Analyzing rules for potential problems...');
162
-
163
- try {
164
- const state = await browser.runtime.sendMessage({ action: 'getState' });
165
- const rules = state.rules;
166
-
167
- if (rules.length === 0) {
168
- log('diagnosticResults', 'No rules configured', 'warning');
169
- return;
170
- }
171
-
172
- // Check for redirect loops
173
- rules.forEach((rule, index) => {
174
- const pattern = new RegExp(rule.pattern, 'i');
175
-
176
- // Check if redirect target matches the pattern
177
- if (pattern.test(rule.redirect)) {
178
- log('diagnosticResults', `⚠️ LOOP DETECTED: Rule ${index + 1} redirects to a domain that matches its own pattern!`, 'error');
179
- log('diagnosticResults', ` Pattern: ${rule.pattern}`, 'error');
180
- log('diagnosticResults', ` Redirect: ${rule.redirect}`, 'error');
181
- }
182
-
183
- // Check if redirect target matches other patterns
184
- rules.forEach((otherRule, otherIndex) => {
185
- if (index !== otherIndex) {
186
- const otherPattern = new RegExp(otherRule.pattern, 'i');
187
- if (otherPattern.test(rule.redirect)) {
188
- log('diagnosticResults', `⚠️ CHAIN DETECTED: Rule ${index + 1} redirects to domain that matches Rule ${otherIndex + 1}`, 'warning');
189
- }
190
- }
191
- });
192
- });
193
-
194
- log('diagnosticResults', 'Rule analysis complete', 'success');
195
-
196
- } catch (error) {
197
- log('diagnosticResults', `Rule analysis failed: ${error.message}`, 'error');
198
- }
199
- }
200
-
201
- async function runTroubleshootingStep(step) {
202
- const resultId = `step${step}Results`;
203
-
204
- switch (step) {
205
- case 1:
206
- log(resultId, 'Verifying extension state...');
207
- await checkExtensionStatus();
208
- break;
209
-
210
- case 2:
211
- log(resultId, 'Testing redirect mode (non-masking)...');
212
- log(resultId, '1. Disable all "Mask URL" checkboxes in extension popup', 'info');
213
- log(resultId, '2. Disable "URL Masking Mode" toggle', 'info');
214
- log(resultId, '3. Try your request again', 'info');
215
- log(resultId, '4. If it works, the issue is with masking mode', 'warning');
216
- break;
217
-
218
- case 3:
219
- log(resultId, 'Checking for redirect loops...');
220
- await analyzeRules();
221
- break;
222
- }
223
- }
224
-
225
- // Auto-run extension check on page load
226
- window.addEventListener('load', checkExtensionStatus);
227
- </script>
228
- </body>
229
- </html>
3
+ <head>
4
+ <title>Debug Proxy Errors</title>
5
+ <style>
6
+ body {
7
+ font-family: Arial, sans-serif;
8
+ padding: 20px;
9
+ max-width: 1000px;
10
+ }
11
+ .section {
12
+ margin: 20px 0;
13
+ padding: 20px;
14
+ border: 2px solid #ddd;
15
+ border-radius: 8px;
16
+ }
17
+ .error {
18
+ border-color: #dc3545;
19
+ background: #fff5f5;
20
+ }
21
+ .success {
22
+ border-color: #28a745;
23
+ background: #f8fff8;
24
+ }
25
+ .warning {
26
+ border-color: #ffc107;
27
+ background: #fffbf0;
28
+ }
29
+ .info {
30
+ border-color: #17a2b8;
31
+ background: #f0f9ff;
32
+ }
33
+ .code {
34
+ background: #e9ecef;
35
+ padding: 8px;
36
+ font-family: monospace;
37
+ margin: 8px 0;
38
+ word-break: break-all;
39
+ }
40
+ .results {
41
+ background: #f5f5f5;
42
+ padding: 10px;
43
+ margin: 10px 0;
44
+ border-radius: 4px;
45
+ max-height: 300px;
46
+ overflow-y: auto;
47
+ }
48
+ button {
49
+ padding: 10px 15px;
50
+ margin: 5px;
51
+ cursor: pointer;
52
+ background: #007bff;
53
+ color: white;
54
+ border: none;
55
+ border-radius: 4px;
56
+ }
57
+ .error-btn {
58
+ background: #dc3545;
59
+ }
60
+ .success-btn {
61
+ background: #28a745;
62
+ }
63
+ table {
64
+ width: 100%;
65
+ border-collapse: collapse;
66
+ margin: 10px 0;
67
+ }
68
+ th,
69
+ td {
70
+ border: 1px solid #ddd;
71
+ padding: 8px;
72
+ text-align: left;
73
+ }
74
+ th {
75
+ background: #f8f9fa;
76
+ }
77
+ </style>
78
+ </head>
79
+ <body>
80
+ <h1>🐛 Debug Proxy Errors</h1>
81
+
82
+ <div class="section error">
83
+ <h2>❌ Common Firefox Errors</h2>
84
+ <table>
85
+ <tr>
86
+ <th>Error</th>
87
+ <th>Meaning</th>
88
+ <th>Common Causes</th>
89
+ </tr>
90
+ <tr>
91
+ <td><code>ns_binding_aborted</code></td>
92
+ <td>Network request was cancelled</td>
93
+ <td>Redirect loops, Invalid redirects, Extension conflicts</td>
94
+ </tr>
95
+ <tr>
96
+ <td><code>ns_error_corrupted_content</code></td>
97
+ <td>Content corruption or invalid response</td>
98
+ <td>Header issues, CORS problems, Content-encoding conflicts</td>
99
+ </tr>
100
+ <tr>
101
+ <td><code>ns_error_net_reset</code></td>
102
+ <td>Connection was reset</td>
103
+ <td>Server rejection, Proxy server issues</td>
104
+ </tr>
105
+ </table>
106
+ </div>
107
+
108
+ <div class="section warning">
109
+ <h2>⚠️ Quick Fixes</h2>
110
+ <ol>
111
+ <li>
112
+ <strong>Check for redirect loops:</strong> Make sure your redirect
113
+ target doesn't match your pattern
114
+ </li>
115
+ <li>
116
+ <strong>Use redirect mode first:</strong> Disable "Mask URL" to test
117
+ basic functionality
118
+ </li>
119
+ <li>
120
+ <strong>Test with simple domains:</strong> Try redirecting to a known
121
+ working server first
122
+ </li>
123
+ <li>
124
+ <strong>Check proxy server:</strong> Ensure your target server can
125
+ handle the requests
126
+ </li>
127
+ </ol>
128
+ </div>
129
+
130
+ <div class="section info">
131
+ <h2>🔍 Diagnostic Tests</h2>
132
+ <button onclick="checkExtensionStatus()">Check Extension Status</button>
133
+ <button onclick="testSimpleRedirect()">Test Simple Redirect</button>
134
+ <button onclick="testProblematicURL()">Test Problematic URL</button>
135
+ <button onclick="analyzeRules()">Analyze Rules for Loops</button>
136
+ <button class="error-btn" onclick="clearLogs()">Clear Logs</button>
137
+ <div id="diagnosticResults" class="results"></div>
138
+ </div>
139
+
140
+ <div class="section success">
141
+ <h2>✅ Troubleshooting Steps</h2>
142
+ <div id="troubleshootingSteps">
143
+ <h3>Step 1: Verify Extension State</h3>
144
+ <button onclick="runTroubleshootingStep(1)">Run Step 1</button>
145
+ <div id="step1Results" class="results"></div>
146
+
147
+ <h3>Step 2: Test Without Masking</h3>
148
+ <button onclick="runTroubleshootingStep(2)">Run Step 2</button>
149
+ <div id="step2Results" class="results"></div>
150
+
151
+ <h3>Step 3: Check for Redirect Loops</h3>
152
+ <button onclick="runTroubleshootingStep(3)">Run Step 3</button>
153
+ <div id="step3Results" class="results"></div>
154
+ </div>
155
+ </div>
156
+
157
+ <script>
158
+ function log(elementId, message, type = "info") {
159
+ const element = document.getElementById(elementId)
160
+ const timestamp = new Date().toLocaleTimeString()
161
+ const icon =
162
+ type === "error"
163
+ ? "❌"
164
+ : type === "success"
165
+ ? "✅"
166
+ : type === "warning"
167
+ ? "⚠️"
168
+ : "ℹ️"
169
+ element.innerHTML += `<div>${timestamp} ${icon} ${message}</div>`
170
+ }
171
+
172
+ function clearLogs() {
173
+ const logElements = [
174
+ "diagnosticResults",
175
+ "step1Results",
176
+ "step2Results",
177
+ "step3Results",
178
+ ]
179
+ logElements.forEach((id) => {
180
+ const element = document.getElementById(id)
181
+ if (element) element.innerHTML = ""
182
+ })
183
+ }
184
+
185
+ async function checkExtensionStatus() {
186
+ log("diagnosticResults", "Checking extension status...")
187
+
188
+ try {
189
+ if (typeof browser === "undefined") {
190
+ log(
191
+ "diagnosticResults",
192
+ "Browser API not available - extension not loaded",
193
+ "error",
194
+ )
195
+ return
196
+ }
197
+
198
+ const state = await browser.runtime.sendMessage({
199
+ action: "getState",
200
+ })
201
+ log(
202
+ "diagnosticResults",
203
+ `Extension enabled: ${state.enabled}`,
204
+ "success",
205
+ )
206
+ log(
207
+ "diagnosticResults",
208
+ `Number of rules: ${state.rules.length}`,
209
+ "info",
210
+ )
211
+
212
+ state.rules.forEach((rule, index) => {
213
+ log(
214
+ "diagnosticResults",
215
+ `Rule ${index + 1}: ${rule.pattern} ${rule.redirect} (Mask: ${rule.maskUrl || false})`,
216
+ "info",
217
+ )
218
+ })
219
+ } catch (error) {
220
+ log(
221
+ "diagnosticResults",
222
+ `Extension communication failed: ${error.message}`,
223
+ "error",
224
+ )
225
+ }
226
+ }
227
+
228
+ async function testSimpleRedirect() {
229
+ log(
230
+ "diagnosticResults",
231
+ "Testing simple redirect with known good server...",
232
+ )
233
+
234
+ try {
235
+ // Test with a simple, reliable endpoint
236
+ const response = await fetch("https://httpbin.org/get?test=simple")
237
+ const data = await response.json()
238
+ log(
239
+ "diagnosticResults",
240
+ `Simple test successful: ${response.status}`,
241
+ "success",
242
+ )
243
+ log("diagnosticResults", `Response URL: ${data.url}`, "info")
244
+ } catch (error) {
245
+ log(
246
+ "diagnosticResults",
247
+ `Simple test failed: ${error.message}`,
248
+ "error",
249
+ )
250
+ log(
251
+ "diagnosticResults",
252
+ "This suggests a configuration issue with your rules",
253
+ "warning",
254
+ )
255
+ }
256
+ }
257
+
258
+ async function testProblematicURL() {
259
+ log(
260
+ "diagnosticResults",
261
+ "Testing the problematic gramercy.cloud URL...",
262
+ )
263
+
264
+ const testUrl =
265
+ "https://hilton-pop-art-cytz-dani-martin-hueg.gramercy.cloud/uploads/assets/test.png"
266
+
267
+ try {
268
+ const response = await fetch(testUrl)
269
+ log(
270
+ "diagnosticResults",
271
+ `Gramercy test: ${response.status} ${response.statusText}`,
272
+ "success",
273
+ )
274
+ } catch (error) {
275
+ log(
276
+ "diagnosticResults",
277
+ `Gramercy test failed: ${error.message}`,
278
+ "error",
279
+ )
280
+
281
+ if (error.message.includes("ns_binding_aborted")) {
282
+ log(
283
+ "diagnosticResults",
284
+ "→ Likely cause: Redirect loop or invalid redirect target",
285
+ "warning",
286
+ )
287
+ } else if (error.message.includes("ns_error_corrupted_content")) {
288
+ log(
289
+ "diagnosticResults",
290
+ "→ Likely cause: Header modification issues or server response problems",
291
+ "warning",
292
+ )
293
+ }
294
+ }
295
+ }
296
+
297
+ async function analyzeRules() {
298
+ log("diagnosticResults", "Analyzing rules for potential problems...")
299
+
300
+ try {
301
+ const state = await browser.runtime.sendMessage({
302
+ action: "getState",
303
+ })
304
+ const rules = state.rules
305
+
306
+ if (rules.length === 0) {
307
+ log("diagnosticResults", "No rules configured", "warning")
308
+ return
309
+ }
310
+
311
+ // Check for redirect loops
312
+ rules.forEach((rule, index) => {
313
+ const pattern = new RegExp(rule.pattern, "i")
314
+
315
+ // Check if redirect target matches the pattern
316
+ if (pattern.test(rule.redirect)) {
317
+ log(
318
+ "diagnosticResults",
319
+ `⚠️ LOOP DETECTED: Rule ${index + 1} redirects to a domain that matches its own pattern!`,
320
+ "error",
321
+ )
322
+ log("diagnosticResults", ` Pattern: ${rule.pattern}`, "error")
323
+ log("diagnosticResults", ` Redirect: ${rule.redirect}`, "error")
324
+ }
325
+
326
+ // Check if redirect target matches other patterns
327
+ rules.forEach((otherRule, otherIndex) => {
328
+ if (index !== otherIndex) {
329
+ const otherPattern = new RegExp(otherRule.pattern, "i")
330
+ if (otherPattern.test(rule.redirect)) {
331
+ log(
332
+ "diagnosticResults",
333
+ `⚠️ CHAIN DETECTED: Rule ${index + 1} redirects to domain that matches Rule ${otherIndex + 1}`,
334
+ "warning",
335
+ )
336
+ }
337
+ }
338
+ })
339
+ })
340
+
341
+ log("diagnosticResults", "Rule analysis complete", "success")
342
+ } catch (error) {
343
+ log(
344
+ "diagnosticResults",
345
+ `Rule analysis failed: ${error.message}`,
346
+ "error",
347
+ )
348
+ }
349
+ }
350
+
351
+ async function runTroubleshootingStep(step) {
352
+ const resultId = `step${step}Results`
353
+
354
+ switch (step) {
355
+ case 1:
356
+ log(resultId, "Verifying extension state...")
357
+ await checkExtensionStatus()
358
+ break
359
+
360
+ case 2:
361
+ log(resultId, "Testing redirect mode (non-masking)...")
362
+ log(
363
+ resultId,
364
+ '1. Disable all "Mask URL" checkboxes in extension popup',
365
+ "info",
366
+ )
367
+ log(resultId, '2. Disable "URL Masking Mode" toggle', "info")
368
+ log(resultId, "3. Try your request again", "info")
369
+ log(
370
+ resultId,
371
+ "4. If it works, the issue is with masking mode",
372
+ "warning",
373
+ )
374
+ break
375
+
376
+ case 3:
377
+ log(resultId, "Checking for redirect loops...")
378
+ await analyzeRules()
379
+ break
380
+ }
381
+ }
382
+
383
+ // Auto-run extension check on page load
384
+ window.addEventListener("load", checkExtensionStatus)
385
+ </script>
386
+ </body>
387
+ </html>