You can just check the URL
If URL contains /post then its a post
If URL contains /page then its a page
If URL contains anything else then its a page thats in the root like contact and etc.
Thats all that you need to do.
You can even go with specific pages or posts just put in the URL thats needed.
Keep us updated on your widget :)
I am interested in it too!
Have a good day,