Firstly thank you for your mod! It's really needed by Factorio!
Replace all these entity/item/recipies with one single "Down Binning chest".
Target quality is determined by the quality of the chest itself.
As for the custom qualities... the following part
local quality_level = {
["normal"] = 0,
["uncommon"] = 1,
["rare"] = 2,
["epic"] = 3,
["legendary"] = 5
}
can be replaced by iterating over "prototypes.quality" and sorting them by "level".
https://lua-api.factorio.com/latest/classes/LuaPrototypes.html
https://lua-api.factorio.com/latest/classes/LuaQualityPrototype.html
I'm thinking about implementing it myself, but I don't think we all really need two mods of mostly the same idea on the mods portal...