User:Abcboy/common.js
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Press Ctrl-F5.
if (mw.config.get('wgNamespaceNumber') == 6 && mw.config.get('wgAction') == 'view') { mw.loader.load('//tools.wmflabs.org/imagemapedit/ime.js'); } function escapeAstral() { var t = document.getElementById('wpTextbox1').value; var s = t.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g) || []; if (s.length > 0) { for (var i = 0; i < s.length; i++) { t = t.replace(new RegExp(s[i]), '&#x' + ((s[i].charCodeAt(0) - 0xD800) * 0x400 + s[i].charCodeAt(1) - 0xDC00 + 0x10000).toString(16) + ';'); } document.getElementById('wpTextbox1').value = t; } } if (mw.config.get('wgAction') == 'edit' || mw.config.get('wgAction') == 'submit') { $(function () { document.querySelector('#wpSaveWidget > input').addEventListener('click', escapeAstral, true); document.querySelector('#wpPreviewWidget > input').addEventListener('click', escapeAstral, true); document.querySelector('#wpDiffWidget > input').addEventListener('click', escapeAstral, true); }); }