Content deleted Content added
DemonDays64 (talk | contribs) Changes? |
DemonDays64 (talk | contribs) Add note about regex |
||
(50 intermediate revisions by 2 users not shown) | |||
Line 1:
// See the documentation! Hope you like the script :-)
// NOTE: Uses a regex feature implemented fairly recently in some browsers (https://caniuse.com/?search=Lookbehind):
mw.loader.using( 'mediawiki.util', function () {▼
// Chrome: 10/2017 | Firefx: 6/2020 | Edge: 1/2020 | Safari: 3/2023 | Opera: 11/2017
// If running older browsers I believe it will work normally except that it will modify File links. The previous versions did not have this feature and used widely-supported Regex.
var pageBeforeEdit;
var previousSummary;
var dumbQuotesLink =
▲ $(dumbQuotesLink).click( function ( event ) {
editPage();
▲ event.preventDefault();
function runRegex(regex, thingToRegex) {
modifiedPage =
function setEditSummary(){▼
document.editform.wpMinoredit.checked = true;▼
}
function setDumbQuotes(){▼
function makeAndRunRegex(findRegex, replace) {
var
};▼
runRegex(regexObject, modifiedPage);
document.editform.wpTextbox1.value = modifiedPage;▼
}
if (previousSummary !== "") {
if (!previousSummary.includes(summary)) {
document.editform.wpSummary.value = document.editform.wpSummary.value + " | " + summary;
}
}
else {
▲ replace: '"'
}
▲ var originalPage = document.editform.wpTextbox1.value;
▲ var modifiedPage = originalPage;
▲ modifiedPage = modifiedPage.replace(singleQuoteRegex.find, singleQuoteRegex.replace);
▲ document.editform.wpTextbox1.value = modifiedPage;
▲ document.editform.diff();
}
function showDiff() {
▲} );
if(typeof doaction !== 'undefined') doaction("diff");
}
function editPage() {
pageBeforeEdit = document.editform.wpTextbox1.value;
modifiedPage = pageBeforeEdit;
makeAndRunRegex(/(?<!File:[^\]]*[^\]]*)(‘|’)/g, "'");
makeAndRunRegex(/(?<!File:[^\]]*[^\]]*)(“|”)/g, '"');
doEdit();
setEditSummary("Replaced curly quotes with straight with [[User:DemonDays64/Scripts/Dumb quotes.js|script]] per [[MOS:CQ]].", true);
showDiff();
}
});
});
|