Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

User:SD0001/private-sandbox.js

    From Wikipedia, the free encyclopedia
    <User:SD0001
    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 theappropriate village pump.
    This codewill be executed when previewing this page.
    Documentation for thisuser script can be added atUser:SD0001/private-sandbox.
    Note: After saving, you have to bypass your browser's cache to see the changes.Google Chrome,Firefox,Microsoft Edge andSafari: Hold down the⇧ Shift key and click theReload toolbar button. For details and instructions about other browsers, seeWikipedia:Bypass your cache.
    /** * Deprecated. 2020-10-04. * I recommend use of the "Wikitext" extension[1] in [[Visual Studio Code]], * which brings in the reliability and stability of the local file system * while allowing previews and syntax highlightening. The "sandboxes" are files * on your system so you can make as many as you want! * * This script causes the saved sandbox text to be exported on evey page load. * * [1]: https://marketplace.visualstudio.com/items?itemName=RoweWilsonFrederiskHolme.wikitext * *//** * Creates a private sandbox for you, accessible at [[Special:PrivateSandbox]] * Useful for things like drafting evidence for ArbCom/ANI, which are better * done privately but not off-wiki because you want to be able to preview. */$.when($.ready,mw.loader.using(['mediawiki.user','mediawiki.api'])).then(function(){if(mw.config.get('wgPageName')!=='Special:PrivateSandbox'&&mw.config.get('wgPageName')!=='Special:BlankPage/PrivateSandbox'){return;}document.title='Private sandbox';$('#firstHeading').text('Private sandbox');varapi=newmw.Api();$('#mw-content-text').empty().append($('<div>').attr('id','ps-preview'),$('<textarea>').val(mw.user.options.get('userjs-pvt-sandbox')).attr({id:'ps-textarea',cols:80,rows:25,tabindex:1,accesskey:','}).css({'margin':'20px 0 10px 0','font-family':mw.user.options.get('editfont')}),$('<button>').text('Save').click(function(){$('#ps-status').text('Saving').css('color','blue');vartext=$('#ps-textarea').val();api.saveOption('userjs-pvt-sandbox',text).then(function(){$('#ps-status').empty();$('#ps-lastsaved').text('Last saved at '+newDate().toLocaleString());mw.user.options.set('userjs-pvt-sandbox',text);},function(err){$('#ps-status').text('Failed to save: ',err).css('color','red');});}),$('<button>').text('Preview').click(function(){$('#ps-status').text('Retrieving preview').css('color','blue');vartext=$('#ps-textarea').val();api.post({action:'parse',text:text,title:'PrivateSandbox',prop:'text|categorieshtml',disableeditsection:'1',formatversion:'2'}).then(function(json){$('#ps-status').empty();$('#ps-preview').html(json.parse.text+json.parse.categorieshtml);},function(err){$('#ps-status').text('Failed to fetch preview: ',err).css('color','red');});}).css({'padding-left':'5px'}),$('<div>').attr('id','ps-status'),$('<div>').attr('id','ps-lastsaved'));window.onbeforeunload=function(e){if($('#ps-textarea').val()!==mw.user.options.get('userjs-pvt-sandbox')){e.returnValue='Your changes have not been saved';returne.returnValue;}};});
    Retrieved from "https://en.wikipedia.org/w/index.php?title=User:SD0001/private-sandbox.js&oldid=981820400"

    [8]ページ先頭

    ©2009-2025 Movatter.jp