User:DannyS712/Readonly.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
This user script seems to have a documentation page at User:DannyS712/Readonly. |
//Copied from [[User:FR30799386/readonly.js]]
$.when( mw.loader.using( 'mediawiki.util' ), $.ready ).then( function () {
if(mw.config.get('wgNamespaceNumber')<0)
{
return;
}
if (typeof(Storage) !== "undefined") {
console.log('User:DannyS712/Readonly.js says : localStorage found!😊');
try{
var music= function(clickEvent){
if ( clickEvent ) {
clickEvent.preventDefault();
}
mw.storage.session.set( 'script', 'ReadOnly' );
window.location.href =mw.util.getUrl(mw.config.get('wgPageName'),{action:'edit'});
};
if(mw.config.get('wgAction')=='edit'||mw.config.get('wgAction')=='submit')
{
if(mw.storage.session.get('script')=='ReadOnly')
{
document.getElementById('wpTextbox1').setAttribute('readonly', 'readonly');
mw.util.addCSS('.editOptions{display:none;}'+'#editpage-specialchars *{display:none;}');
mw.storage.session.remove( 'script' );
}
}
else{
mw.util.addPortletLink('p-cactions','#','Forced view source','ca-readonly', 'Make text-area read-only', '6');
$('#ca-readonly').click(music);
}
}catch(e){
console.log('User:DannyS712/Readonly.js has thrown the following error : ');
console.log(
'\t' + e.name + ' message: ' + e.message +
( e.at ? ' at: ' + e.at : '') +
( e.text ? ' text: ' + e.text : '')
);
console.log('If the script stops working, please report it to User talk:DannyS712');
}
}
else{
mw.notify($( '<span><a href="//en.wikipedia.org/wiki/User:DannyS712/Readonly.js">User:DannyS712/Readonly.js</a> is unable to function properly due to incompatible browser specifications. Please upgrade to one of the browsers listed <a href="//caniuse.com/#feat=namevalue-storage">here</a> <span style="color:green">(in green)</span> to run the script.</span>' ),{ autoHide: false,type:'warn'});
}
} );