Greasy Fork is available in English.

Discussioni » Feedback di Greasy Fork

What is obfuscated code? And on when the code becomes obfuscated?

§
Pubblicato: 14/01/2023

So, the question is which code we can actually call obfuscated?
And which code is obfuscated enough to be not posted on greasefork?

NotYouMod
§
Pubblicato: 14/01/2023
Modificato: 14/01/2023

@StickySkull when it is unreadable of course, for example readable and unreadable code examples:

let _0XFFFFFF = 0XF
let _0XFFFFFE = 0X0

while (_0XFFFFFF > _0XFFFFFE++) {
  console['l' + (({}) + [].join())[0X1] + 'g'](_0XFFFFFE)
}

And readable version:

let a = 15
let b = 0

while (a > b++) {
  console.log(b)
}

This also can be unreadable:

(function f(a, b) {
  let c = 0

  for (let d = 0, e = 20; d < e; d++) {
    a++; b--;
  }

  return [a, b, c, d]
})(10, 10)

Code is obfuscated, until it's hard to read it.

The best thing you can do to prevent creating obfuscated code, is comment your code (write what codes does) and also make long enough variable names to understand what for they are used. (For example, instead of l, use letter, instead of mb, use menuButton / menuBtn etc.)

§
Pubblicato: 14/01/2023

@StickySkull when it is unreadable of course, for example readable and unreadable code examples:

let _0XFFFFFF = 0XF
let _0XFFFFFE = 0X0

while (_0XFFFFFF > _0XFFFFFE++) {
  console['l' + (({}) + [].join())[0X1] + 'g'](_0XFFFFFE)
}

And readable version:

let a = 15
let b = 0

while (a > b++) {
  console.log(b)
}

This also can be unreadable:

(function f(a, b) {
  let c = 0

  for (let d = 0, e = 20; d < e; d++) {
    a++; b--;
  }

  return [a, b, c, d]
})(10, 10)

Code is obfuscated, until it's hard to read it.

The best thing you can do to prevent creating obfuscated code, is comment your code (write what codes does) and also make long enough variable names to understand what for they are used. (For example, instead of l, use letter, instead of mb, use menuButton / menuBtn etc.)

So it depends on how hard it is? How we can check if it's hard or not?
I can write code that you can easy to read with long variable's names (minifcation is legal here tho), without any hex codes, but you will never find out what is this code do.

§
Pubblicato: 15/01/2023

"Code posted to Greasy Fork must not be obfuscated or minified."

Please actually do read the rules
https://greasyfork.org/en/help/code-rules

If your code is not easily understandable by another developer, your script is subject to be deleted, and perhaps your account may be banned if it is an often issue with you.

Sometimes there are dumb devs that don't know much and might say that your script is malicious or whatever, but you can also prove that they are wrong by showing and explaining your code in the report, then if true your script will not be deleted.

§
Pubblicato: 16/01/2023

It's a subjective call by moderators. @NotYou has covered the use of unhelpful variable names. It's not an issue if you use i or other things once in a while, but if a significant portion of the variable and function names are like that, it's a problem.

I'd also include unexpected use of whitespace, like having everything on the same line, or trying to "hide" code by putting a bunch of spaces on each line. Anything that's intended to make the code harder to read.

Pubblica risposta

Accedi per pubblicare una risposta.