I'm aware of the licencing issue about my post might raise here, but it's Apple and their policies are philosophically contestable. So, for the common good & research :
Safari JS reader source: https://github.com/amumu/safari-reader-js
How to get the latest version from Safari is explained in the README.
If you really want an open source Version, user the other posts, they're all good.
Cheers.