Poster IDs: Difference between revisions

From Bibliotheca Anonoma
mNo edit summary
No edit summary
 
Line 1: Line 1:
Boards such as /pol/ and /bant/ support unique poster IDs that let you recognize the individual behind posts throughout a thread.
Boards such as /pol/ and /bant/ support unique poster IDs that let you recognize the individual behind posts throughout a thread.


These IDs are displayed with colors on 4chan but colorless on FoolFuuka. We've been able to locate the code computing the color within 4chan's JS extension and offer a simplified Golang version below:
These IDs are displayed with colors on 4chan but colorless on [[FoolFuuka]]. We've been able to locate the code computing the color within 4chan's JS extension{{citation_needed}} and offer a simplified Golang version below:


<pre>
<pre>
Line 32: Line 32:
}
}
</pre>
</pre>
= See also =
* Thread about the exact probability of getting k0t ID and other funny short strings : https://mathchan.org/math/thread/106

Latest revision as of 21:01, 14 September 2022

Boards such as /pol/ and /bant/ support unique poster IDs that let you recognize the individual behind posts throughout a thread.

These IDs are displayed with colors on 4chan but colorless on FoolFuuka. We've been able to locate the code computing the color within 4chan's JS extension[citation needed] and offer a simplified Golang version below:

func IDStyle(s string) string {
      //Initially equals 0
      var hash int64

      //Iterate over bytes in the string
      for _, r := range []byte(s) {
            hash = ((hash << 5) - hash) + int64(r)
      }

      red := (hash >> 24) & 0xFF
      green := (hash >> 16) & 0xFF
      blue := (hash >> 8) & 0xFF

      result := fmt.Sprintf("background-color: rgb(%d, %d, %d);", red, green, blue)

      //Determines how light the color just computed is
      light := float64(red)*0.299+float64(green)*0.587+float64(blue)*0.114 > 125

      if light {
            result += "color: black;"
      } else {
            result += "color: white;"
      }

      //e.g. "background-color: rbg(10, 20, 30); color: white;"
      return result
}

See also[edit]