User:Samwalton9 (WMF)/revertrisk.js

/* example of presenting revert risk score on diff pages */ ( function {	const revId = mw.util.getParamValue( 'oldid' );	if ( revId ) {

fetch('https://api.wikimedia.org/service/lw/inference/v1/models/revertrisk-language-agnostic:predict', {		method: "POST",		body: JSON.stringify({"rev_id": revId, "lang": "en"})		}) .then( function( response ) {			return response.json;		} ) .then( function (inferenceData ) {			const content = document.querySelector( '.mw-body-content' );			const data = document.createElement( 'span' );           const score = inferenceData.output["probabilities"]["true"];			data.innerText = score.toFixed(2);			content.insertBefore(data, content.firstChild);		} ); } } );