User:MC10/stubtagtab.js: Difference between revisions

Content deleted Content added
remove link?
use .text(), clean up
Line 2:
// Enhancements made on requests by [[User:Alai]] and [[User:jj137]].
// ([[User:ais523/stubtagtab2.js]])
// Edited version [[User:MC10/stubtagtab.js]]
// <source lang="javascript">
$(function () {
if (mw.config.get("wgNamespaceNumber") === 0 && mw.config.get("wgAction") === "view") {
if (document.getElementById("ca-edit")) mw.util.addPortletLink('p-cactions', 'javascript:stubtagtab()', 'Stub', 'ca-stubtag', 'Add a stub tag to this page', '');
}
if (___location.href.indexOf("&autoaddstubtag=") !== -1 && document.getElementById('wpTextbox1') != null) {
var x = decodeURIComponent(___location.href.split("&autoaddstubtag=")[1]);
if (x.indexOf("-stub") === -1) x += "-stub";
document.getElementById('wpTextbox1').value += "\n{" + "{" + x + "}}"; // add to the end of the article
document.getElementById('wpSummary').value = "Tagging with {" + "{" + x + "}} using [[WP:US/S|user scripts]]";
document.getElementById('wpPreview').click();
}
});
 
function stubtagtab() {
Line 36 ⟶ 24:
index = link.indexOf("Template:")
if (index === -1) {
$(this).childrentext().clone().wrap('<div>').parent().html();
} else {
$(this).attr("href", mw.config.get("wgServer") + mw.config.get("wgScript") + "?title=" + encodeURIComponent(mw.config.get("wgPageName"))
Line 54 ⟶ 42:
}
 
$(function () {
// </source> <!--[[Category:Wikipedia scripts]]-->
if (mw.config.get("wgNamespaceNumber") === 0 && mw.config.get("wgAction") === "view") {
if (document.getElementById("ca-edit")) mw.util.addPortletLink('p-cactions', 'javascript:stubtagtab()', 'Stub', 'ca-stubtag', 'Add a stub tag to this page', '');
}
if (___location.href.indexOf("&autoaddstubtag=") !== -1 && document.getElementById('wpTextbox1') != null) {
var x = decodeURIComponent(___location.href.split("&autoaddstubtag=")[1]);
if (x.indexOf("-stub") === -1) x += "-stub";
document.getElementById('wpTextbox1').value += "\n{" + "{" + x + "}}"; // add to the end of the article
document.getElementById('wpSummary').value = "Tagging with {" + "{" + x + "}} using [[WP:US/S|user scripts]]";
document.getElementById('wpPreview').click();
}
});
 
// </source> <!--[[Category:Wikipedia scripts]]-->