The Wikidata ID can be obtained from this API call which returns a JSON like this:
{ "batchcomplete": "", "query": { "pages": { "15580374": { "pageid": 15580374, "ns": 0, "title": "Main Page", "pageprops": { "noeditsection": "", "noexternallanglinks": "a:1:{i:0;s:1:\"*\";}", "notoc": "", "page_image": "Halebopp031197.jpg", "wikibase_item": "Q5296" } } } } }
You need to extract the "wikibase_item" property and display the value (Q5296 in this example) next to the title. The default styling should be similar to the one at Wikidata, but the gadget should allow linking to the actual Wikidata item by setting a variable in JS.