Skip to content

Commit

Permalink
fix(StorySeed): text cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
noaione committed Oct 23, 2024
1 parent d574d73 commit ca75cd2
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 10 deletions.
2 changes: 1 addition & 1 deletion index.json
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@
"imageURL": "https://github.com/shosetsuorg/extensions/raw/dev/icons/TravisTranslations.png",
"id": 4302,
"lang": "en",
"ver": "2.1.1",
"ver": "2.1.2",
"libVer": "1.0.0",
"md5": ""
}
Expand Down
47 changes: 38 additions & 9 deletions src/en/StorySeedling.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- {"id":4302,"ver":"2.1.1","libVer":"1.0.0","author":"N4O","dep":["dkjson>=1.0.1","Multipartd>=1.0.0","WPCommon>=1.0.3"]}
-- {"id":4302,"ver":"2.1.2","libVer":"1.0.0","author":"N4O","dep":["dkjson>=1.0.1","Multipartd>=1.0.0","WPCommon>=1.0.3"]}

local json = Require("dkjson");
local Multipartd = Require("Multipartd");
Expand Down Expand Up @@ -216,6 +216,23 @@ local function caesarCipher(str, key)
end))
end

local function isFuckingGarbage(text)
-- "Copyrighted sentence owned by Story Seedling", lol lmao even, kys.
if WPCommon.contains(cleanText:lower(), "storyseedling") then
return true
end
if WPCommon.contains(text:lower(), "story seedling") then
return true
end
if WPCommon.contains(text:lower(), "storyseedling.com") then
return true
end
if WPCommon.contains(text:lower(), "travis translation") then
return true
end
return false
end

local function getPassage(chapterURL)
local chap = requestPassageInformation(chapterURL)

Expand All @@ -229,19 +246,31 @@ local function getPassage(chapterURL)
local spanData = chap:select("span")
map(spanData, function (v)
local style = v:attr("class")
local text = v:text()
local rawText = v:text()

-- clean space
text = text:gsub("^%s*(.-)%s*$", "%1")
local cleanText = rawText:gsub("^%s*(.-)%s*$", "%1")
style = style:gsub("^%s*(.-)%s*$", "%1")
-- if text == style then
-- -- useless piece of shit
-- v:remove()
-- return
-- end
if cleanText == style then
-- useless piece of shit
v:remove()
return
end

if cleanText:lower() == "pbclevtugrq fragrapr bjarq ol fgbel frrqyvat" or "pbclevtugrq fragrapr bjarq ol fgbelfrrqyvat" then
v:remove()
return
end

-- check if starts with cls and 21 characters
if rawText:sub(1, 3) == "cls" and rawText:len() == 21 then
v:remove()
return
end

-- unrot
v:text(caesarCipher(text, -13))
local unrot = caesarCipher(rawText, 13)
v:text(unrot)
end)

return pageOfElem(chap, true)
Expand Down

0 comments on commit ca75cd2

Please sign in to comment.