Content deleted Content added
DemonDays64 (talk | contribs) Names |
DemonDays64 (talk | contribs) Add note about regex |
||
(43 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):
// 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.
mw.loader.using('mediawiki.util', function () {
var pageBeforeEdit;
var modifiedPage;
var previousSummary;
//add a tab on the left
var dumbQuotesLink = mw.util.addPortletLink("p-tb", "#", "Dumb quotes", "t-dumb-quotes", "Convert curly to straight quotes");
editPage();
function runRegex(regex, thingToRegex) {
▲ $(scriptLink).click(function (event) {
}
▲ event.preventDefault();
document.editform.wpMinoredit.checked = isMinor;▼
document.editform.wpSummary.value = summary;▼
};
}
▲ modifiedPage = modifiedPage.replace(regex.find, regex.replace);
}
▲ var regexObject = {
previousSummary = document.editform.wpSummary.value;
▲ find: findRegex,
if (previousSummary !== "") {
▲ replace: replace
if (!previousSummary.includes(summary)) {
document.editform.wpSummary.value = document.editform.wpSummary.value + " | " + summary;
▲ runRegex(regexObject);
}
}
else {
}
}
if(typeof doaction !== 'undefined') doaction("diff");
▲ document.editform.wpTextbox1.value = modifiedPage;
}
pageBeforeEdit
modifiedPage = pageBeforeEdit;
▲ makeAndRunRegex(singleQuoteRegex, /(‘|’)/g, "'");
▲ makeAndRunRegex(doubleQuoteRegex, /(“|”)/g, '"');
}
▲ doEdit();
});
▲ setEditSummary("Replaced smart quotes with dumb. Error? [[User talk:DemonDays64|Tell me]].", true);
▲ showDiff();
▲ });
});
|