Skip to content

Commit 381824f

Browse files
committed
Remove debug console statements and release 0.4.2
Strip ~20 console.log/console.error calls from production code and fix README comment about hidden actions.
1 parent e2672c4 commit 381824f

4 files changed

Lines changed: 9 additions & 39 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ module.exports = {
8888
[
8989
"docusaurus-plugin-copy-page-button",
9090
{
91-
// Only show copy and view actions (hide ChatGPT and Claude)
91+
// Only show copy and view actions (hide AI tools)
9292
enabledActions: ['copy', 'view'],
9393
},
9494
],

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "docusaurus-plugin-copy-page-button",
3-
"version": "0.4.1",
3+
"version": "0.4.2",
44
"description": "Docusaurus plugin that adds a copy page button to extract documentation content as markdown for AI tools like ChatGPT, Claude, and Gemini",
55
"main": "src/index.js",
66
"keywords": [

src/CopyPageButton.js

Lines changed: 7 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -328,18 +328,12 @@ export default function CopyPageButton({
328328
};
329329

330330
const extractPageContent = () => {
331-
console.log('Extracting page content...');
332-
333331
const mainContent =
334332
document.querySelector("main article") ||
335333
document.querySelector("main .markdown");
336334

337-
console.log('Found main content element:', !!mainContent);
338335
if (!mainContent) {
339-
console.error('No main content found - looking for alternative selectors');
340-
// Try alternative selectors
341336
const alternatives = document.querySelector("main") || document.querySelector("article") || document.querySelector(".main-wrapper");
342-
console.log('Alternative content element found:', !!alternatives);
343337
if (!alternatives) return "";
344338
}
345339

@@ -354,42 +348,30 @@ export default function CopyPageButton({
354348
// Extract title from first H1 and remove it from content
355349
const firstH1 = clone.querySelector("h1");
356350
const title = firstH1?.textContent.trim() || "Documentation Page";
357-
console.log('Extracted title:', title);
358351
if (firstH1) {
359352
firstH1.remove();
360353
}
361354

362355
const content = convertToMarkdown(clone);
363-
console.log('Converted content length:', content.length);
364-
console.log('Content preview:', content.substring(0, 200));
365-
366356
const currentUrl = window.location.href;
367-
const finalContent = `# ${title}\n\nURL: ${currentUrl}\n\n${content}`;
368-
console.log('Final page content set with length:', finalContent.length);
369-
return finalContent;
357+
return `# ${title}\n\nURL: ${currentUrl}\n\n${content}`;
370358
};
371359

372360
const copyToClipboard = async (text) => {
373-
console.log('copyToClipboard called with text length:', text?.length);
374-
console.log('Text content preview:', text?.substring(0, 100));
375-
376361
// If no content, try to extract it now
377362
if (!text || text.trim() === '') {
378-
console.log('No pageContent available, extracting now...');
379363
const extractedContent = extractPageContent();
380364
if (extractedContent) {
381365
setPageContent(extractedContent);
382366
text = extractedContent;
383367
} else {
384-
console.error('Failed to extract content');
385368
return;
386369
}
387370
}
388-
371+
389372
try {
390373
if (navigator.clipboard && navigator.clipboard.writeText) {
391374
await navigator.clipboard.writeText(text);
392-
console.log('Content copied to clipboard successfully');
393375
} else {
394376
// Fallback for older browsers
395377
const textArea = document.createElement('textarea');
@@ -398,10 +380,9 @@ export default function CopyPageButton({
398380
textArea.select();
399381
document.execCommand('copy');
400382
document.body.removeChild(textArea);
401-
console.log('Content copied to clipboard using fallback method');
402383
}
403384
} catch (err) {
404-
console.error('Failed to copy to clipboard:', err);
385+
// Silently fail
405386
}
406387
};
407388

@@ -414,38 +395,31 @@ export default function CopyPageButton({
414395
Please provide a clear summary and help me understand the key concepts covered in this documentation.`
415396
);
416397
window.open(`${baseUrl}?${queryParam}=${prompt}`, "_blank");
417-
console.log('Opened AI tool with prompt');
418398
} catch (err) {
419-
console.error('Failed to open AI tool:', err);
399+
// Silently fail
420400
}
421401
};
422402

423403
const viewAsMarkdown = () => {
424-
console.log('viewAsMarkdown called with pageContent length:', pageContent?.length);
425-
console.log('PageContent preview:', pageContent?.substring(0, 100));
426-
427404
let contentToView = pageContent;
428-
405+
429406
// If no content, try to extract it now
430407
if (!contentToView || contentToView.trim() === '') {
431-
console.log('No pageContent available, extracting now...');
432408
const extractedContent = extractPageContent();
433409
if (extractedContent) {
434410
setPageContent(extractedContent);
435411
contentToView = extractedContent;
436412
} else {
437-
console.error('Failed to extract content');
438413
return;
439414
}
440415
}
441-
416+
442417
try {
443418
const blob = new Blob([contentToView], { type: "text/plain" });
444419
const url = URL.createObjectURL(blob);
445420
window.open(url, "_blank");
446-
console.log('Opened markdown view');
447421
} catch (err) {
448-
console.error('Failed to open markdown view:', err);
422+
// Silently fail
449423
}
450424
};
451425

src/client.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -376,10 +376,6 @@ if (ExecutionEnvironment.canUseDOM) {
376376
(!articleContent || !articleContent.contains(container)));
377377

378378
if (needsInjection) {
379-
// Log only if we're having to retry (indicates potential issue)
380-
if (recheckCount > 3) {
381-
console.log('[Copy Button] Re-injecting after', recheckCount * 0.5, 'seconds');
382-
}
383379
reliableInjectCopyPageButton();
384380
}
385381

0 commit comments

Comments
 (0)