If you want to try the App Inventor side,
Do you know how to use FOR EACH loops?
If you do, create two nested FOR EACH loops, one for the line (y) and the other for the column (x)
Then check each position the loops give you for the color you want to replace. If that x,y = the color you are looking for, draw a pixel in that same position with the new color.
If you don't know how to do that, please learn more basic App Inventor 2 things before trying to do more advanced things.
I don't know anything about JavaScript, so I can't help with that.