Pamaké:MGA73/common.js
Pidangan
Catet: Sanggeus nyimpen, anjeun kudu narabas singgahan panyungsi anjeun pikeun nempo parobahanana.
- Firefox/Safari: Tahan Shift bari ngaklik Reload, atawa pencét boh Ctrl-F5 atawa Ctrl-R (⌘-R dina Mac)
- Google Chrome: Pencét Ctrl-Shift-R (⌘-Shift-R dina Mac)
- Internet Explorer: Tahan Ctrl bari ngaklik Refresh, atawa pencét Ctrl-F5
- Opera: Indit ka Menu → Settings (Opera → Preferences di Mac) tuluy ka Privacy & security → Clear browsing data → Cached images and files.
$(document).ready(function() {
// Only run this script on File pages
if (mw.config.get('wgNamespaceNumber') === 6) {
// Function to check for Commons duplication and extract the filename
function getCommonsFilename() {
// Locate the duplicates section
var duplicatesSection = $('#mw-imagepage-section-duplicates');
// Check if the duplicates section exists
if (duplicatesSection.length) {
// Find the link to the Commons file
var commonsLink = duplicatesSection.find('a.external');
if (commonsLink.length) {
// Extract the filename from the link text
var commonsFilename = commonsLink.text().replace("Gambar:", "").trim();
return commonsFilename;
}
}
return null;
}
// Get the Commons filename if it exists
var commonsFilename = getCommonsFilename();
if (commonsFilename) {
// Create the "Add NowCommons" button
var addNowCommonsLink = $('<a>')
.text('Add NowCommons')
.attr('href', '#')
.css({
'cursor': 'pointer',
'color': '#0645AD',
'margin-left': '10px',
})
.click(function(event) {
event.preventDefault();
// Redirect to the edit page with NowCommons marker
var editUrl = mw.util.getUrl(mw.config.get('wgPageName'), { action: 'edit', nowcommons: commonsFilename });
window.location.href = editUrl;
});
// Add the link to the page (e.g., next to the edit button)
$('#ca-edit').after(addNowCommonsLink);
}
// Automatically insert the NowCommons template and edit summary if the page is in edit mode
var urlParams = new URLSearchParams(window.location.search);
if (mw.config.get('wgAction') === 'edit' && urlParams.has('nowcommons')) {
var commonsFilename = urlParams.get('nowcommons');
var nowCommonsTemplate = '{{IlaharKiwari|' + commonsFilename + '}}';
var editBox = $('#wpTextbox1');
var currentText = editBox.val();
editBox.val(nowCommonsTemplate + '\n' + currentText);
// Set the edit summary
$('#wpSummary').val('Adding NowCommons template for file duplicated on Commons (' + commonsFilename + ')');
}
}
});