subject-f / guyamoe

Kaguya Manga Reader Website
https://guya.moe
GNU Affero General Public License v3.0
462 stars 66 forks source link

Meta tags, FoolSlide API. #35

Closed funkyhippo closed 4 years ago

funkyhippo commented 4 years ago

Gonna just leave this one in for posterity.

raw_data_regex = re.search(r'(?:var _0x3320=)(?P<array>[\d\D]+?)(?:;[\d\D]+?_0x3320,)(?P<shuffle>[\d\D]+)(?:\)\);)(?:[\d\D]+\]\(\([\d\D]+?\?)(?P<iftrue>[\d\D]+?)(?:\:)(?P<iffalse>[\d\D]+?)(?:\)[\d\D]+?\+)(?P<addition>[\d\D]+?)(?:\)[\d\D]+?-)(?P<subtraction>[\d\D]+?)(?:\))', resp.text)
raw_data = raw_data_regex.group("array")
shuffle = int(raw_data_regex.group("shuffle"), 16)
if_true = int(raw_data_regex.group("iftrue"), 16)
if_false = int(raw_data_regex.group("iffalse"), 16)
add_unconditionally = int(raw_data_regex.group("addition"), 16)
sub_unconditionally = int(raw_data_regex.group("subtraction"), 16)
b64 = json.loads(raw_data.replace("\'", "\""))
b64 = b64[1] if b64[0] == "fromCharCode" else b64[0]
tmp = []
for c in b64:
  # Only run the deobfuscator if it's a character
  if c.isalpha():
    n = if_true if c <= "Z" else if_false
    c = ord(c) + add_unconditionally
    tmp.append(chr(c) if n >= c else chr(c - sub_unconditionally))
  else:
    tmp.append(c)
  decoded = json.loads(base64.b64decode("".join(tmp)))

I see through your bullshit, JB.

Anyway, they have an API that's very bare but works for getting chapter pages, so that monstrosity is now 2 lines.

Also, meta tag changes and cache timing changes for the pages.