User:Adamw/DraftTopic.js

// Forked from User:EpochFail/DraftTopic.js

ORES_HOST = "https://ores.wikimedia.org"; MIN_PROBA = 0.05;

var get_and_render_categories = function{ var revId = mw.config.get('wgRevisionId'), url = ORES_HOST + "/v3/scores/enwiki/" + revId + "/drafttopic", parserOutputNode = $('.mw-parser-output'), render_categories = function(data){ //console.log(["rendering", data]) var catProba = data.enwiki.scores[revId].drafttopic.score.probability; for (var cat in catProba) { //console.log(cat) if (catProba.hasOwnProperty(cat)) { var proba = catProba[cat]; //console.log([cat, proba]) if(proba > MIN_PROBA){ //console.log([cat, proba]) parserOutputNode.prepend(cat + "(" + Math.round(proba*100)/100 + ") "); }				}			}		};	$.ajax(url, {		success: render_categories.bind(this),       error: function(jqxmlhr, status, error){console.log(status + ": " + error)}	}); };

get_and_render_categories;