User:Polygnotus/Scripts/Claude4.js: Difference between revisions

Content deleted Content added
No edit summary
No edit summary
 
(9 intermediate revisions by the same user not shown)
Line 30:
<button id="claude-proofread-btn" ${!this.apiKey ? 'style="display:none"' : ''}>Proofread Article</button>
<button id="claude-change-key-btn" ${!this.apiKey ? 'style="display:none"' : ''}>Change Key</button>
<button id="claude-clear-btn" ${!this.currentResults ? 'style="display:none"' : ''}>Clear Results</button>
</div>
<div id="claude-results">
Line 188 ⟶ 187:
#ca-claude a:hover {
text-decoration: underline !important;
}
/* Universal theme compatibility - target only the main containers */
body.claude-sidebar-visible {
margin-right: ${this.sidebarWidth} !important;
}
/* Target only the outermost containers to avoid stacking margins */
body.claude-sidebar-visible .mw-page-container,
body.claude-sidebar-visible #globalWrapper {
margin-right: 0 !important;
padding-right: ${this.sidebarWidth} !important;
box-sizing: border-box !important;
}
/* For fixed/absolute positioned elements like headers */
body.claude-sidebar-visible .vector-header,
body.claude-sidebar-visible .vector-sticky-header,
body.claude-sidebar-visible #mw-head {
right: ${this.sidebarWidth} !important;
width: calc(100% - ${this.sidebarWidth}) !important;
}
Line 220 ⟶ 198:
/* Hidden state styles */
body.claude-sidebar-hidden #claude-proofreader-sidebar {
display: none;
}
body.claude-sidebar-hidden #ca-claude {
display: list-item !important;
}
/* Reset margins when sidebar is hidden */
body:not(.claude-sidebar-visible) {
margin-right: 0 !important;
}
body:not(.claude-sidebar-visible) .mw-page-container,
body:not(.claude-sidebar-visible) #globalWrapper {
margin-right: 0 !important;
padding-right: 0 !important;
}
body:not(.claude-sidebar-visible) .vector-header,
body:not(.claude-sidebar-visible) .vector-sticky-header,
body:not(.claude-sidebar-visible) #mw-head {
right: 0 !important;
width: 100% !important;
}
`;
Line 255 ⟶ 217:
}
createClaudeTab() {
// Only create tab if we're in the main article namespace (namespace 0)
if (typeof mw !== 'undefined' && mw.config.get('wgNamespaceNumber') >=== 0) {
// Create the Claude tab
const claudeTab = document.createElement('li');
claudeTab.id = 'ca-claude';
claudeLinkclaudeTab.textContentclassName = 'Claudemw-list-item';
const claudeLink = document.createElement('a');
claudeLink.href = '#';
claudeLink.title = 'Proofread with Claude AI';
claudeLink.textContent = 'Claude';
claudeLink.addEventListener('click', (e) => {
e.preventDefault();
this.showSidebar();
});
const claudeSpan = document.createElement('span');
claudeSpan.textContent = 'Claude';
claudeLink.appendChild(claudeSpan);
claudeTab.appendChild(claudeLink);
Line 334 ⟶ 300:
style.setAttribute('data-claude-proofreader', 'true');
style.textContent = `
body.claude/* Vector 2022 theme -sidebar-visible {comprehensive approach */
body.claude-sidebar-visible .mw-page-container, {
margin-right: ${this.sidebarWidth} !important;
box-sizing: border-box !important;
}
body.claude-sidebar-visible .mw-page-container,
body.claude/* Vector 2022 -sidebar-visible #globalWrappermain content wrapper {*/
body.claude-sidebar-visible #.mw-headpage-container-inner {
margin-right: 0 !important;
padding-right: ${this.sidebarWidth}0 !important;
boxmax-sizingwidth: border-boxnone !important;
}
/* ResetVector margins2022 when- sidebarcontent is hiddenarea */
body.claude-sidebar-visible .vectormw-stickycontent-header,container {
max-width: calc(100% - ${this.sidebarWidth})none !important;
margin-right: 0 !important;
}
/* Vector 2022 - article content */
body.claude-sidebar-visible .mw-body {
paddingmargin-right: ${this.sidebarWidth}0 !important;
marginmax-rightwidth: 0none !important;
}
/* Vector 2022 - main content */
body.claude-sidebar-visible .vector-header,#content {
margin-right: ${this.sidebarWidth}0 !important;
marginmax-rightwidth: 0none !important;
}
}
/* Legacy Vector and other themes */
body.claude-sidebar-visible #globalWrapper {
margin-right: ${this.sidebarWidth} !important;
paddingbox-rightsizing: 0 !importantborder-box;
}
}
/* Header adjustments */
body.claude-sidebar-visible .vector-header,
body.claude-sidebar-visible .vector-sticky-header,
Line 348 ⟶ 343:
right: ${this.sidebarWidth} !important;
width: calc(100% - ${this.sidebarWidth}) !important;
rightbox-sizing: 0 !importantborder-box;
}
`;
Line 374 ⟶ 370:
}
adjustMainContent() {
// Only apply layout changes when sidebar is actually visible
if (this.isVisible) {
document.body.classList.add('claude-sidebar-visible');
Line 394 ⟶ 391:
document.getElementById('claude-proofread-btn').addEventListener('click', () => {
this.proofreadArticle();
});
document.getElementById('claude-clear-btn').addEventListener('click', () => {
this.clearResults();
});
}
Line 417 ⟶ 411:
localStorage.removeItem('claude_current_results');
this.updateOutput('');
document.getElementById('claude-clear-btn').style.display = 'none';
this.updateStatus('Results cleared. Ready to proofread.');
}
Line 434 ⟶ 427:
outputEl.textContent = content;
}
// Store results and show clear button
if (content) {
this.currentResults = content;
localStorage.setItem('claude_current_results', content);
document.getElementById('claude-clear-btn').style.display = 'inline-block';
}
}