// read text from clipboard
async function pasteResult() {
try {
const text = await navigator.clipboard.readText();
if (!text) {
alert("Clipboard is empty");
return;
}
document.getElementById("logInput").value = text;
analyzeLog(); // analyze directly!
} catch (err) {
alert("No access to clipboard " + err);
}
}
// Analyze the pasted log and extract issues, registry keys, and plugin info
function analyzeLog() {
const log = document.getElementById("logInput").value;
const output = document.getElementById("output");
const lines = log.split("\n");
const issues = lines.filter((line) => line.startsWith("โ"));
const regKeys = lines.filter((line) => line.includes("HKEY_") || line.includes("โค"));
const plugins = lines.filter((line) => line.match(/Plugin ready: .*\.ps1/i));
output.innerHTML = `
๐งช Found ${issues.length} issues
${issues.map((i) => `
${i}
`).join("")}
๐ Registry Keys
${regKeys.map((k) => `
${k}
`).join("")}
๐ฆ Loaded Plugins
${plugins.map((p) => `
${p}
`).join("")}
`;
}
// Save screenshot of the output section
function captureResult() {
html2canvas(document.getElementById("output")).then((canvas) => {
const link = document.createElement("a");
link.download = "CrapFixer-results.png";
link.href = canvas.toDataURL();
link.click();
});
}
// Native share (for mobile browsers)
function shareResult() {
const text = document.getElementById("output").innerText;
if (navigator.share) {
navigator
.share({
title: "CrapFixer Analysis Results",
text: text,
})
.catch((err) => console.log("Share failed:", err));
} else {
alert("Sharing is not supported by your browser.");
}
}
// Share the result as an image on Twitter/X
function shareOnTwitter() {
const outputEl = document.getElementById("output");
if (!outputEl.innerText.trim()) return alert("No results to share yet.");
// Create screenshot from result div
html2canvas(outputEl).then((canvas) => {
const dataUrl = canvas.toDataURL("image/png");
// Convert image to base64 string (can't upload directly to Twitter)
// Instead, show preview and user uploads manually via prompt
const win = window.open();
win.document.write(`๐ท Screenshot ready for X / Twitter
`);
win.document.write(
`Right-click the image below and save it to upload on Twitter manually.
`
);
win.document.write(
`
`
);
win.document.write(
`โก๏ธ Click here to post on X
`
);
});
}