User talk:Aeroid/CodeNRun.js

Demo Code N Run

edit

Purpose

edit

Allows to execute embedded JavaScript code fragments on Commons pages. A code fragment is activated to become editable and executable by CodeNRun.js. A output textarea is added below the code to capture any text output (e.g. console.log("text")).

This allows for scripts to generate complex text for easy copy & pasting.

Warning

edit

This is using eval() to execute in your browser context!

Install

edit

Add

if (mw.config.get('wgNamespaceNumber') === 6 && /SVG/i.test(mw.config.get('wgTitle').slice(-3))) // SVGedit on SVG files only
	importScript('User:Rillke/SVGedit.js');

to Special:MyPage/common.js

Basic use

edit

de:Hilfe:Syntaxhighlight

var day = new Date("2021-11-16");
var languages = ['en','de','fr','it','es','ca','hr','az','tr','bs','he','el','ja','ko','pl','vi','nl','hsb','nds','bar','fur'];

function t(text, systemLanguage) { console.log( '\t<text' + systemLanguage + '>(' + text + ')</text>' ); }
function l(localex) { t(day.toLocaleString(localex, { dateStyle: "long" }), ' systemLanguage="' + localex + '"' ); }
languages.forEach(l);
t(day.toISOString().substr(0, 10));

Collapsed box

edit
Snippets Case2
console.log("Hello World!");
Return to the user page of "Aeroid/CodeNRun.js".