--by pavetr.top/ds if not MENU_DLL then return end local obkak = {} exec_menuaddtab("Chrom Log", function() exec_menuaddbutton("Clear chromium.log", 15, 40, function() obkak.finalPath = obkak.cleanPath(exec_Read(obkak.filePath)) obkak.chromiumLogPath = obkak.finalPath .. "/" .. obkak.chromiumLogFileName if exec_Read(obkak.chromiumLogPath) then obkak.scanAndRemoveLogs(obkak.chromiumLogPath) else exec_notification("chromium.log not found.") end end) exec_menuaddlabel("Script will clear logs on game shutdown", 15, 90, 20, 300, 30) exec_menuaddbutton("Change path", 15, 140, function() Derma_StringRequest( "exechack.cc", "Input new path to Garry's Mod folder:", "", function(text) if text ~= "" and text:match("^[A-Za-z]:\\.*") then local finalPath = obkak.cleanPath(text) obkak.chromiumLogPath = finalPath .. "/" .. obkak.chromiumLogFileName if exec_Read(obkak.chromiumLogPath) then exec_Write(obkak.filePath, text:gsub("\\", "/")) exec_notification("Path updated successfully!") else exec_notification("chromium.log not found at the new path.") end else exec_notification("Invalid path provided.") end end, function() end ) end) exec_menuaddlabel("by farshmak", 15, 380, 13, 100, 30) end) obkak.filePath = "C:/exechack/chromiumlogcleaner.txt" obkak.defaultPath = "C:\\Program Files (x86)\\Steam\\steamapps\\common\\GarrysMod" obkak.unwantedPattern = "exechack.cc" obkak.chromiumLogFileName = "chromium.log" obkak.cleanPath = function(path) if not path then return "" end return path:gsub("\\", "/"):match("^%s*(.-)%s*$") end obkak.isUnwantedLog = function(line) return string.match(line, obkak.unwantedPattern) ~= nil end obkak.scanAndRemoveLogs = function(filePath) local fileContents = exec_Read(filePath) if not fileContents then exec_notification("Chromium log not found.") return end local lines = string.Split(fileContents, "\n") local cleanedLines = {} local deletedCount = 0 for _, line in ipairs(lines) do if not obkak.isUnwantedLog(line) then table.insert(cleanedLines, line) else deletedCount = deletedCount + 1 end end if deletedCount == 0 then exec_notification("No unwanted log entries found.") return end local cleanedFileContents = table.concat(cleanedLines, "\n") local success = exec_Write(filePath, cleanedFileContents) if success then exec_notification("File cleaned successfully. " .. deletedCount .. " log entries deleted.") else exec_notification("Error writing to file: " .. filePath) end local postCleanContents = exec_Read(filePath) if postCleanContents then local postCleanLines = string.Split(postCleanContents, "\n") local postCleanDeletedCount = 0 for _, line in ipairs(postCleanLines) do if obkak.isUnwantedLog(line) then postCleanDeletedCount = postCleanDeletedCount + 1 end end if postCleanDeletedCount == 0 then exec_notification("No unwanted log entries found after cleaning.") end end end obkak.fileContents = exec_Read(obkak.filePath) if not obkak.fileContents or not obkak.fileContents:match("^[A-Za-z]:\\.*") then obkak.cleanedPath = obkak.cleanPath(obkak.fileContents) if not obkak.cleanedPath:match("^[A-Za-z]:/.*") then Derma_StringRequest( "exechack.cc", [[Input path to GarrysMod folder or press OK to apply default: C:\Program Files (x86)\Steam\steamapps\common\GarrysMod]], "", function(text) if text == "" then text = obkak.defaultPath end if text:match("^[A-Za-z]:\\.*") then local finalPath = obkak.cleanPath(text) obkak.chromiumLogPath = finalPath .. "/" .. obkak.chromiumLogFileName if not exec_Read(obkak.chromiumLogPath) then exec_notification("chromium.log not found at the provided path.") return end exec_Write(obkak.filePath, text:gsub("\\", "/")) exec_notification("Path updated successfully!") obkak.scanAndRemoveLogs(obkak.chromiumLogPath) else exec_notification("Invalid path provided.") end end, function() exec_notification([[Not found chromium.log]]) end ) return end exec_Write(obkak.filePath, obkak.cleanedPath) end obkak.finalPath = obkak.cleanPath(obkak.fileContents) obkak.chromiumLogPath = obkak.finalPath .. "/" .. obkak.chromiumLogFileName if not exec_Read(obkak.chromiumLogPath) then exec_notification("Chromium log not found at the specified path.") else obkak.scanAndRemoveLogs(obkak.chromiumLogPath) end hook.Add("ShutDown", "ClearLogsOnShutdown", function() obkak.finalPath = obkak.cleanPath(exec_Read(obkak.filePath)) obkak.chromiumLogPath = obkak.finalPath .. "/" .. obkak.chromiumLogFileName if exec_Read(obkak.chromiumLogPath) then obkak.scanAndRemoveLogs(obkak.chromiumLogPath) else exec_notification("Chromium log not found during shutdown.") end end)