MediaWiki:Common.js: Difference between revisions
Knowlepedia (talk | contribs) No edit summary Tag: Manual revert |
Knowlepedia (talk | contribs) No edit summary |
||
Line 73: | Line 73: | ||
}); | }); | ||
$(document).ready(function () { | |||
$(document).ready(function() { | // Auto-tag NeedsReview | ||
if (mw.config.get("wgAction") === "edit" || mw.config.get("wgAction") === "submit") { | if (mw.config.get("wgAction") === "edit" || mw.config.get("wgAction") === "submit") { | ||
var userGroups = mw.config.get( | var userGroups = mw.config.get("wgUserGroups") || []; | ||
if (userGroups.includes( | if (userGroups.includes("user") && !userGroups.includes("approver") && !userGroups.includes("sysop")) { | ||
var $wpTextbox1 = $( | var $wpTextbox1 = $("#wpTextbox1"); | ||
if ($wpTextbox1.length | |||
if ($wpTextbox1.length) { | |||
var currentText = $wpTextbox1.val(); | |||
// Add NeedsReview if not present | |||
if (!currentText.includes("{{NeedsReview}}")) { | |||
currentText = "{{NeedsReview}}\n" + currentText; | |||
} | |||
// Add Notability if it's a new page and not already added | |||
var isNewPage = mw.config.get("wgIsArticle") === false; | |||
if (isNewPage && !currentText.includes("{{Notability")) { | |||
currentText = "{{Notability|reason=Please add reliable sources.|by=" + mw.config.get("wgUserName") + "|date=" + new Date().toLocaleString('default', { month: 'long', year: 'numeric' }) + "}}\n" + currentText; | |||
} | |||
// Set updated text | |||
$wpTextbox1.val(currentText); | |||
} | } | ||
} | } | ||
} | } | ||
// Meta description injection (SEO) | |||
var desc = $('meta[name="knowlepedia-desc"]').attr( | var desc = $('meta[name="knowlepedia-desc"]').attr("content"); | ||
if (desc) { | if (desc) { | ||
$('head').append('<meta name="description" content="' + desc + '">'); | $('head').append('<meta name="description" content="' + desc + '">'); | ||
} | } | ||
}); | }); | ||