Jump to content

User:JPxG/signpost-filetools.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by JPxG (talk | contribs) at 23:40, 9 June 2024 (oopsies). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
$( function() {
    if( (window.location.href.indexOf( "File:" ) >= 0 ) || (window.location.href.indexOf( "File%3A" ) >= 0 )) {
    	var res = document.getElementsByClassName("fileInfo")[0].innerHTML.replaceAll(/ pixels.*/g, "").replaceAll("(","").replaceAll("SVG file, nominally","").replaceAll(" ","").split("×");
    	// should produce [width, height].
    	var size = int((int(res[0])/int(res[1])) * 301);
    	
    	// Put this in a div.
    	var newDiv = document.createElement('div');
    	newDiv.class = "signpost-filetools";
    	newDiv.innerHTML = String(size);
    	document.getElementsByClassName("mw-filepage-resolutioninfo")[0].appendChild(newDiv);

    } // if page title has "File:" in it
} );