User:Suyash.dwivedi/userscripts/AddDerivativeSources

Wiki's Lazy Coders

Add Derivative Sources

AddDerivativeSources is a gadget-like script that simplifies the process of citing original source files for derivative works on Wikimedia Commons. It adds a UI button that automates wikitext editing and gallery creation.

Installation

To use this script, add the following line to your common.js page:

// Add Derivative Sources Button
mw.loader.load('https://commons.wikimedia.org/wiki/User:Suyash.dwivedi/userscripts/AddDerivativeSources.js?action=raw&ctype=text/javascript');

How to use

  1. Navigate to any File: page.
  2. Look for the Source row in the File Information table.
  3. Click the blue + Add derivative sources button.
  4. Enter the names of the source files (e.g., File:Example.jpg) in the popup dialog.
  5. Click Update. The script will automatically:
    • Fetch the current page content.
    • Format the sources into a <gallery>.
    • Insert or update the ==Source files== section.
    • Save the page with a minor edit summary.

Features

  • Dynamic Inputs: New input fields appear automatically as you type.
  • Smart Replacement: Automatically detects {{own}} and replaces it with the proper source gallery.
  • Duplicate Prevention: If a gallery already exists, it merges new files without creating duplicates.
  • Mobile Friendly: Designed to work across modern browsers.

Created by Suyash Dwivedi | Updated on: 8 January 2026

Category:User scripts#AddDerivativeSources Category:Wikimedia Commons tools#AddDerivativeSources
Category:User scripts Category:Wikimedia Commons tools