File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -436,21 +436,22 @@ def process_html(
436436 let rawUrl = editBtn.href.replace('github.com', 'raw.githubusercontent.com');
437437 rawUrl = rawUrl.replace('/blob/', '/').replace('/tree/', '/');
438438
439- try {{
439+ async function getContent() {{
440440 const response = await fetch(rawUrl);
441441 let markdown = await response.text();
442-
443442 if (markdown.startsWith('---')) {{
444443 const frontMatterEnd = markdown.indexOf('\\ n---\\ n', 3);
445- if (frontMatterEnd !== -1) {{
446- markdown = markdown.substring(frontMatterEnd + 5).trim();
447- }}
444+ if (frontMatterEnd !== -1) markdown = markdown.substring(frontMatterEnd + 5).trim();
448445 }}
449-
450446 const title = document.querySelector('h1')?.textContent || document.title;
451- const content = `# ${{title}}\\ n\\ nSource: ${{window.location.href}}\\ n\\ n---\\ n\\ n${{markdown}}`;
447+ return `# ${{title}}\\ n\\ nSource: ${{window.location.href}}\\ n\\ n---\\ n\\ n${{markdown}}`;
448+ }}
452449
453- await navigator.clipboard.writeText(content);
450+ try {{
451+ const clipboardItem = new ClipboardItem({{
452+ 'text/plain': getContent().then(text => new Blob([text], {{ type: 'text/plain' }}))
453+ }});
454+ await navigator.clipboard.write([clipboardItem]);
454455 button.innerHTML = checkIcon + ' Copied!';
455456 setTimeout(() => {{ button.innerHTML = originalHTML; }}, 2000);
456457 }} catch (err) {{
You can’t perform that action at this time.
0 commit comments