Skip to content

Commit

Permalink
perf: remove bannedCode checking
Browse files Browse the repository at this point in the history
it was pretty easy to bypass as mixaz proved in #3 anyway
  • Loading branch information
KraXen72 committed Apr 21, 2022
1 parent 561a2d7 commit e90db57
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 18 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

> Use userscripts at your own risk, the author(s) of this client are not responsible for any damage done with userscripts because the user is the author of the script.
> Enabling any userscript you don't trust and know how it works is NOT RECOMMENDED
> Any userscripts that modify the game's canvas (Renderer) are NOT ALLOWED and WILL NOT RUN (sky color script, etc)
> Any userscripts that modify the game's canvas (Renderer) are NOT ALLOWED
## contributing
- you have to have `git`, `nodejs` and `npm` installed.
Expand Down
17 changes: 1 addition & 16 deletions app/src/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ ipcRenderer.on('preloadSettings', (event, preferences, version, filedir) => {

ipcRenderer.on('preloadUserscriptPath', (event, recieved_userscriptPath: string) => {
userscriptPath = recieved_userscriptPath
//feel free to add more code
const bannedCode = ["renderer", "reflect", "Reflect", "Renderer", "skyCol", "this._renderer", "game.renderer", "game.renderer.setClearColor"]

userscriptPathTracker = path.resolve(userscriptPath, "tracker.json")
userscripts = fs.readdirSync(userscriptPath, {withFileTypes: true})
Expand All @@ -64,19 +62,6 @@ ipcRenderer.on('preloadUserscriptPath', (event, recieved_userscriptPath: string)

return {name: name, fullpath, content}
})
.filter(userscript => {
if (bannedCode.some(bc => userscript.content.includes(bc))) {
console.log(
`%c[cs] %cdidn't run %c'${userscript.name.toString()}' %cbecause it attempts to modify the game's renderer. Try renaming some variables/text if this is a false positive.`,
"color: lightblue; font-weight: bold;",
"color: red;", "color: lightgreen;", "color: white;"
)
return false
} else {
return true
}

})
let tracker: userscriptTracker = {}
userscripts.forEach(u => tracker[u.name] = false)
Object.assign(tracker, JSON.parse(fs.readFileSync(userscriptPathTracker, {encoding: "utf-8"})))
Expand Down Expand Up @@ -195,7 +180,7 @@ function UpdateSettingsTabs(activeTab: number, hookSearch = true) {
// "Enable userscript support. place .js files in Documents/Crankshaft/scripts",
// "Use userscripts at your own risk, the author(s) of this client are not responsible for any damage done with userscripts because the user is the author of the script.",
// "Enabling any userscript you don't trust and know how it works is NOT RECOMMENDED",
// "Any userscripts that modify the game's canvas (Renderer) are NOT ALLOWED and WILL NOT RUN (sky color script, etc)"
// "Any userscripts that modify the game's canvas (Renderer) are NOT ALLOWED
// ].join("\n")

//safety: 0: ok setting/recommended, 1: ok but not recommended, 2: not recommended but go ahead, 3: experimental, 4: experimental and unstable
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "crankshaft",
"version": "1.2.1",
"version": "1.3.0",
"description": "Crankshaft Krunker Client by KraXen72",
"main": "./app/main.js",
"scripts": {
Expand Down

0 comments on commit e90db57

Please sign in to comment.