Merge pull request #36 from peter9811/main

refactor(plugins): improve script readability and admin checks
This commit is contained in:
Belim
2025-05-17 20:02:55 +02:00
committed by GitHub
9 changed files with 260 additions and 206 deletions
+3 -2
View File
@@ -22,8 +22,9 @@ While cleaning up my GitHub (30+ repos down to 20 now), I also cleaned up thousa
All optimization options are enabled by default – no need to tweak anything.
2. **Analyze Your System**
Click **"Analyze"** to scan your system based on the selected settings.
- **Red** items = Recommended fixes
Click **"Analyze"** to scan your system based on the selected settings.
- **Red** items = Recommended fixes
- **Gray** items = Already optimized
3. **Apply Fixes**
+199 -180
View File
@@ -1,212 +1,231 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Crapfixer Log Analyzer</title>
<style>
/* ---------- Basic Styles ---------- */
body {
font-family: 'Courier New', Courier, monospace;
margin: 0;
background: #f0f0f0;
color: #333;
}
<head>
<meta charset="UTF-8" />
<title>Crapfixer Log Analyzer</title>
<style>
/* ---------- Basic Styles ---------- */
body {
font-family: "Courier New", Courier, monospace;
margin: 0;
background: #f0f0f0;
color: #333;
}
header {
background: #4d4d4d;
color: white;
padding: 1rem;
display: flex;
justify-content: space-between;
align-items: center;
}
header {
background: #4d4d4d;
color: white;
padding: 1rem;
display: flex;
justify-content: space-between;
align-items: center;
}
header h1 {
margin: 0;
font-size: 1.5rem;
}
header h1 {
margin: 0;
font-size: 1.5rem;
}
/* ---------- Top-right Links ---------- */
.actions a {
color: white;
margin-left: 1rem;
text-decoration: none;
font-size: 0.9rem;
background: #444;
padding: 0.3rem 0.6rem;
border-radius: 4px;
transition: background 0.3s;
}
/* ---------- Top-right Links ---------- */
.actions a {
color: white;
margin-left: 1rem;
text-decoration: none;
font-size: 0.9rem;
background: #444;
padding: 0.3rem 0.6rem;
border-radius: 4px;
transition: background 0.3s;
}
.actions a:hover {
background: #666;
}
.actions a:hover {
background: #666;
}
/* ---------- Layout ---------- */
main {
padding: 2rem;
max-width: 800px;
margin: auto;
}
/* ---------- Layout ---------- */
main {
padding: 2rem;
max-width: 800px;
margin: auto;
}
textarea {
width: 100%;
height: 200px;
font-family: monospace;
padding: 1rem;
border: 1px solid #ccc;
background: #fff;
border-radius: 5px;
resize: vertical;
}
textarea {
width: 100%;
height: 200px;
font-family: monospace;
padding: 1rem;
border: 1px solid #ccc;
background: #fff;
border-radius: 5px;
resize: vertical;
}
button {
margin-top: 1rem;
padding: 0.5rem 1rem;
font-size: 1rem;
border: none;
background: #1565c0;
color: white;
cursor: pointer;
border-radius: 4px;
margin-right: 0.5rem;
}
button {
margin-top: 1rem;
padding: 0.5rem 1rem;
font-size: 1rem;
border: none;
background: #1565c0;
color: white;
cursor: pointer;
border-radius: 4px;
margin-right: 0.5rem;
}
button:hover {
background: #0d47a1;
}
button:hover {
background: #0d47a1;
}
/* ---------- Results Section ---------- */
.result {
background: white;
border: 1px solid #ddd;
padding: 1rem;
margin-top: 2rem;
border-radius: 5px;
}
/* ---------- Results Section ---------- */
.result {
background: white;
border: 1px solid #ddd;
padding: 1rem;
margin-top: 2rem;
border-radius: 5px;
}
.issue { color: #c62828; margin-bottom: 0.5rem; }
.key { color: #37474f; font-family: monospace; }
.plugin { color: #1565c0; margin-bottom: 0.3rem; }
.issue {
color: #c62828;
margin-bottom: 0.5rem;
}
.key {
color: #37474f;
font-family: monospace;
}
.plugin {
color: #1565c0;
margin-bottom: 0.3rem;
}
.btn-group {
margin-top: 1rem;
}
</style>
</head>
<body>
<!-- ---------- HEADER SECTION ---------- -->
<header>
<h1>🧠 Crapfixer Log Analyzer</h1>
<div class="actions">
<a href="https://github.com/builtbybel/Crapfixer" target="_blank">GitHub</a>
<a href="https://www.paypal.com/donate/?hosted_button_id=M9DW4VNKH9ECQ" target="_blank">PayPal</a>
<a href="https://ko-fi.com/builtbybel" target="_blank">Ko-fi</a>
</div>
</header>
.btn-group {
margin-top: 1rem;
}
</style>
</head>
<body>
<!-- ---------- HEADER SECTION ---------- -->
<header>
<h1>🧠 Crapfixer Log Analyzer</h1>
<div class="actions">
<a href="https://github.com/builtbybel/Crapfixer" target="_blank">GitHub</a>
<a href="https://www.paypal.com/donate/?hosted_button_id=M9DW4VNKH9ECQ" target="_blank"
>PayPal</a
>
<a href="https://ko-fi.com/builtbybel" target="_blank">Ko-fi</a>
</div>
</header>
<!-- ---------- MAIN CONTENT ---------- -->
<main>
<p><strong>How it works:</strong></p>
<ol>
<li>Run the analysis in Crapfixer and <strong>copy the full log</strong>.</li>
<li>Paste it into the box below.</li>
<li>Click <strong>Analyze</strong> to get results.</li>
</ol>
<!-- ---------- MAIN CONTENT ---------- -->
<main>
<p><strong>How it works:</strong></p>
<ol>
<li>Run the analysis in Crapfixer and <strong>copy the full log</strong>.</li>
<li>Paste it into the box below.</li>
<li>Click <strong>Analyze</strong> to get results.</li>
</ol>
<!-- ---------- LOG INPUT ---------- -->
<textarea id="logInput" placeholder="Drop your Crapfixer log here..."></textarea>
<!-- ---------- LOG INPUT ---------- -->
<textarea id="logInput" placeholder="Drop your Crapfixer log here..."></textarea>
<!-- ---------- BUTTONS ---------- -->
<div class="btn-group">
<button onclick="analyzeLog()">🔍 Analyze</button>
<button onclick="copyResult()">📋 Copy to Clipboard</button>
<button onclick="captureResult()">📸 Take Screenshot</button>
<button onclick="shareResult()">📤 Share</button>
<button onclick="shareOnTwitter()">🐦 Share on X</button>
</div>
<!-- ---------- BUTTONS ---------- -->
<div class="btn-group">
<button onclick="analyzeLog()">🔍 Analyze</button>
<button onclick="copyResult()">📋 Copy to Clipboard</button>
<button onclick="captureResult()">📸 Take Screenshot</button>
<button onclick="shareResult()">📤 Share</button>
<button onclick="shareOnTwitter()">🐦 Share on X</button>
</div>
<!-- ---------- OUTPUT AREA ---------- -->
<div class="result" id="output"></div>
</main>
<!-- ---------- OUTPUT AREA ---------- -->
<div class="result" id="output"></div>
</main>
<!-- ---------- JAVASCRIPT SECTION ---------- -->
<script>
// 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');
<!-- ---------- JAVASCRIPT SECTION ---------- -->
<script>
// 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));
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 = `
output.innerHTML = `
<h3>🧪 Found ${issues.length} issues</h3>
<div>${issues.map(i => `<div class="issue">${i}</div>`).join('')}</div>
<div>${issues.map((i) => `<div class="issue">${i}</div>`).join("")}</div>
<hr>
<h3>🗂 Registry Keys</h3>
<div>${regKeys.map(k => `<div class="key">${k}</div>`).join('')}</div>
<div>${regKeys.map((k) => `<div class="key">${k}</div>`).join("")}</div>
<hr>
<h3>📦 Loaded Plugins</h3>
<div>${plugins.map(p => `<div class="plugin">${p}</div>`).join('')}</div>
<div>${plugins.map((p) => `<div class="plugin">${p}</div>`).join("")}</div>
`;
}
// Copy output text to clipboard
function copyResult() {
const output = document.getElementById('output');
if (!output.innerText.trim()) return alert("No results to copy yet.");
navigator.clipboard.writeText(output.innerText).then(() =>
alert("Results copied to clipboard!")
);
}
// 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.");
// Copy output text to clipboard
function copyResult() {
const output = document.getElementById("output");
if (!output.innerText.trim()) return alert("No results to copy yet.");
navigator.clipboard
.writeText(output.innerText)
.then(() => alert("Results copied to clipboard!"));
}
// Create screenshot from result div
html2canvas(outputEl).then(canvas => {
const dataUrl = canvas.toDataURL("image/png");
// 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();
});
}
// 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(`<h2>📷 Screenshot ready for X / Twitter</h2>`);
win.document.write(`<p>Right-click the image below and save it to upload on Twitter manually.</p>`);
win.document.write(`<img src="${dataUrl}" style="max-width:100%;border:1px solid #ccc;" />`);
win.document.write(`<p><a href="https://twitter.com/intent/tweet?text=Check%20out%20my%20Crapfixer%20analysis!&hashtags=crapfixer,loganalyzer" target="_blank">➡️ Click here to post on X</a></p>`);
});
}
</script>
// 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.");
}
}
<!-- ---------- HTML2CANVAS LIBRARY FOR SCREENSHOTS ---------- -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/1.4.1/html2canvas.min.js"></script>
</body>
// 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(`<h2>📷 Screenshot ready for X / Twitter</h2>`);
win.document.write(
`<p>Right-click the image below and save it to upload on Twitter manually.</p>`
);
win.document.write(
`<img src="${dataUrl}" style="max-width:100%;border:1px solid #ccc;" />`
);
win.document.write(
`<p><a href="https://twitter.com/intent/tweet?text=Check%20out%20my%20Crapfixer%20analysis!&hashtags=crapfixer,loganalyzer" target="_blank">➡️ Click here to post on X</a></p>`
);
});
}
</script>
<!-- ---------- HTML2CANVAS LIBRARY FOR SCREENSHOTS ---------- -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/1.4.1/html2canvas.min.js"></script>
</body>
</html>
+7 -4
View File
@@ -131,8 +131,12 @@
<strong>💖 Support Crapfixer</strong>
Every donation helps me provide more updates. – Thanks, Belim 🙏
<br /><br />
<a href="https://www.paypal.com/donate/?hosted_button_id=M9DW4VNKH9ECQ" target="_blank">💸 PayPal</a>
<a href="https://ko-fi.com/builtbybel" target="_blank" style="background-color: #ff5f5f;">☕ Ko-fi</a>
<a href="https://www.paypal.com/donate/?hosted_button_id=M9DW4VNKH9ECQ" target="_blank"
>💸 PayPal</a
>
<a href="https://ko-fi.com/builtbybel" target="_blank" style="background-color: #ff5f5f"
>☕ Ko-fi</a
>
</div>
<div class="project-follow">
@@ -158,8 +162,7 @@
const status = document.getElementById("status");
if (!userVersion) {
status.innerText =
"❓ No version found. Please open this page from the Crapfixer app.";
status.innerText = "❓ No version found. Please open this page from the Crapfixer app.";
} else {
const result = compareVersions(userVersion, latestVersion);
+4 -4
View File
@@ -1,6 +1,6 @@
Solitaire,CandyCrush,Netflix,TikTok,Facebook,Twitter,Instagram,Spotify,
Skype,OneNote,OneDrive, Mail, Calendar, Weather,News,Maps,
Groove, Movies,TV, Phone, Camera,Feedback,FeedbackHub, GetHelp,
Solitaire,CandyCrush,Netflix,TikTok,Facebook,Twitter,Instagram,Spotify,
Skype,OneNote,OneDrive,Mail,Calendar,Weather,News,Maps,
Groove,Movies,TV,Phone,Camera,Feedback,FeedbackHub,GetHelp,
GetStarted,Messaging,Office,Paint3D,Print3D,StickyNotes,Wallet,
YourPhone,3DViewer,Alarms,VoiceRecorder,ToDo,Whiteboard,ZuneMusic,
ZuneVideo,3DViewer, DevHome, Copilot
ZuneVideo,DevHome,Copilot
+4 -5
View File
@@ -1,6 +1,5 @@
# Run as Admin
if (-not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator"))
{
if (-not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
Write-Warning "You need to run this script as an Administrator!"
exit
}
@@ -15,7 +14,7 @@ $restorePointType = 12 # MODIFY_SETTINGS = 12
# Function to create restore point with progress reporting
function Create-RestorePoint {
Write-Host "Starting to create restore point..." -ForegroundColor Yellow
# Simulate progress
for ($i = 0; $i -le 100; $i += 10) {
Write-Progress -Activity "Creating Restore Point" -Status "$i% Complete" -PercentComplete $i
@@ -28,10 +27,10 @@ function Create-RestorePoint {
}
Write-Host "Restore point created successfully." -ForegroundColor Green
# Show completion message
[System.Windows.Forms.MessageBox]::Show("Restore point has been created successfully!", "Completion", [System.Windows.Forms.MessageBoxButtons]::OK, [System.Windows.Forms.MessageBoxIcon]::Information)
}
# Execute the restore point creation
Create-RestorePoint
Create-RestorePoint
+6 -5
View File
@@ -10,7 +10,8 @@ do {} until (Elevate-Privileges SeTakeOwnershipPrivilege)
Write-Output "Uninstalling default apps"
$apps = @(
# default Windows 10 apps
# Group by Microsoft and third-party
# Microsoft Apps
"Microsoft.549981C3F5F10" #Cortana
"Microsoft.3DBuilder"
"Microsoft.Appconnector"
@@ -90,7 +91,7 @@ $apps = @(
"A278AB0D.DisneyMagicKingdoms"
"A278AB0D.MarchofEmpires"
"ActiproSoftwareLLC.562882FEEB491" # next one is for the Code Writer from Actipro Software LLC
"CAF9E577.Plex"
"CAF9E577.Plex"
"ClearChannelRadioDigital.iHeartRadio"
"D52A8D61.FarmVille2CountryEscape"
"D5EA27B7.Duolingo-LearnLanguagesforFree"
@@ -138,8 +139,8 @@ foreach ($app in $apps) {
Get-AppxPackage -Name $app -AllUsers | Remove-AppxPackage -AllUsers
($appxprovisionedpackage).Where( {$_.DisplayName -EQ $app}) |
Remove-AppxProvisionedPackage -Online
($appxprovisionedpackage).Where( { $_.DisplayName -EQ $app }) |
Remove-AppxProvisionedPackage -Online
} Write-Host "Clippy has completed the process and removed all possible apps."
# Prevents Apps from re-installing
@@ -169,4 +170,4 @@ Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\WindowsStore" "AutoDow
# Prevents "Suggested Applications" returning
New-FolderForced -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CloudContent"
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CloudContent" "DisableWindowsConsumerFeatures" 1
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CloudContent" "DisableWindowsConsumerFeatures" 1
+11 -2
View File
@@ -1,4 +1,13 @@
# Function to show a message box
#Requires -RunAsAdministrator
# Check if running as Administrator
if (-not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
Write-Warning "This script is recommended to be run as Administrator for best results."
# Decide if you want to force exit or just warn
# exit # Uncomment to force admin
}
# Function to show a message box
function Show-MessageBox {
param (
[string]$message,
@@ -15,4 +24,4 @@ Stop-Process -Name explorer -Force
Start-Process explorer
# Show message box
Show-MessageBox -message "Windows Explorer has been restarted successfully." -title "Crapfixer"
Show-MessageBox -message "Windows Explorer has been restarted successfully." -title "Crapfixer"
+15 -2
View File
@@ -1,3 +1,12 @@
#Requires -RunAsAdministrator
# Check if running as Administrator
if (-not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
Write-Warning "This script must be run as Administrator."
Start-Process powershell.exe -Verb RunAs -ArgumentList ("-File `"{0}`"" -f $MyInvocation.MyCommand.Path)
exit
}
# Get all installed Windows apps for all users
$allApps = Get-AppxPackage -AllUsers
@@ -16,7 +25,8 @@ foreach ($app in $allApps) {
Add-AppxPackage -Register "$($app.InstallLocation)\appxmanifest.xml" -DisableDevelopmentMode -ErrorAction Stop
Write-Host "[$currentAppIndex / $totalApps] $($app.Name) reinstalled successfully." -ForegroundColor Green
$reinstalledCount++
} catch {
}
catch {
Write-Host "[$currentAppIndex / $totalApps] Error occurred while reinstalling $($app.Name): $_" -ForegroundColor Red
}
@@ -28,4 +38,7 @@ foreach ($app in $allApps) {
if ($reinstalledCount -eq $totalApps) {
Write-Host "All apps reinstalled successfully." -ForegroundColor Green
Write-Host "Flyby11 has reinstalled everything possible." -ForegroundColor Cyan
}
# Add success percentage reporting
$successPercentage = [math]::Round(($reinstalledCount / $totalApps) * 100, 2)
Write-Host "Completed with $successPercentage% success rate ($reinstalledCount of $totalApps apps reinstalled)" -ForegroundColor Cyan
}
+11 -2
View File
@@ -1,3 +1,12 @@
#Requires -RunAsAdministrator
# Check if running as Administrator
if (-not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
Write-Warning "This script must be run as Administrator."
Start-Process powershell.exe -Verb RunAs -ArgumentList ("-File `"{0}`"" -f $MyInvocation.MyCommand.Path)
exit
}
Import-Module -DisableNameChecking $PSScriptRoot\..\lib\force-mkdir.psm1
Import-Module -DisableNameChecking $PSScriptRoot\..\lib\take-own.psm1
@@ -50,11 +59,11 @@ Write-Output "Restarting explorer"
Start-Process "explorer.exe"
Write-Output "Waiting for explorer to complete loading"
Start-Sleep 10
Start-Sleep 10 # Consider if this sleep is always necessary or could be shorter/conditional
Write-Output "Removing additional OneDrive leftovers"
foreach ($item in (Get-ChildItem "$env:WinDir\WinSxS\*onedrive*")) {
Takeown-Folder $item.FullName
Remove-Item -Recurse -Force $item.FullName
}
Write-Output "Bloatynosy NueEx can confirm the uninstallation of the OneDrive app."
Write-Output "Bloatynosy NueEx can confirm the uninstallation of the OneDrive app."