User:Lagewi/properties.js
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Press Ctrl-F5.
(function () {
if (!mw.config.exists('wbEntityId')) {
return;
}
const limit = 5000;
$('.wikibase-statementgroupview').each(function (i, element) {
const property = $(element).data('property-id');
const $br = $(document.createElement('br'));
const $small = $(document.createElement('small'));
const $a = $(document.createElement('a'));
const query = `SELECT ?o ?oLabel WHERE {
?o wdt:${property} [].
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} LIMIT ${limit}`;
$a.attr('href', 'https://query.wikidata.org/embed.html#' + encodeURIComponent(query));
$a.text('entities with this property');
$small.append('List ', $a);
$(element).find('.wikibase-statementgroupview-property-label').append($br, $small);
$(element).find('.wikibase-statementview').each(function (j, element) {
const statement = $(element).attr('id').replace('$', '-');
const $div = $(document.createElement('div'));
const $small = $(document.createElement('small'));
const $a = $(document.createElement('a'));
const query = `SELECT ?o ?oLabel WHERE {
?o wdt:${property}/^ps:${property} wds:${statement}.
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} LIMIT ${limit}`;
$a.attr('href', 'https://query.wikidata.org/embed.html#' + encodeURIComponent(query));
$a.text('entities with this claim');
$small.append('List ', $a);
$div.append($small);
$(element).find('.wikibase-statementview-mainsnak .wikibase-snakview-value-container').append($div);
});
});
})();