I found a snippet of code that should fetch the web3 provider from MetaMask here or write a warning message to the dev console.
I unsuccessfully tried to get it to run buy opening a file in my browser that has the following lines of code:
This writes to the console 'No web3'. I am definitely logged in to MetaMask, which is showing my balance on the main net.
Question: Why does this not work and how to I get it to work?