Skip to content

Create common.js#3

Open
KGerring wants to merge 1 commit into
mainfrom
KGerring-patch-1
Open

Create common.js#3
KGerring wants to merge 1 commit into
mainfrom
KGerring-patch-1

Conversation

@KGerring
Copy link
Copy Markdown
Owner

@KGerring KGerring commented Dec 6, 2025

Summary by Sourcery

New Features:

  • Add a common.js entry point that centralizes loading of numerous user scripts and gadgets for Wikidata editing.

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented Dec 6, 2025

Reviewer's Guide

Adds a new common.js file that aggregates and loads a large set of user scripts and gadgets from Wikidata using importScript and mw.loader.load, effectively centralizing custom tooling setup for the user.

Sequence diagram for loading user gadgets via common_js

sequenceDiagram
    actor User
    participant Browser
    participant MediaWiki_Server
    participant Common_js
    participant User_Scripts_Aggregate

    User->>Browser: Open Wikidata page
    Browser->>MediaWiki_Server: Request page and user scripts
    MediaWiki_Server-->>Browser: HTML + common_js reference
    Browser->>Common_js: Execute common_js

    Common_js->>MediaWiki_Server: importScript User_Vvekbv_recoin_id_js
    MediaWiki_Server-->>Browser: Response with recoin_id_js
    Common_js->>MediaWiki_Server: mw_loader_load ScriptInstaller_js
    MediaWiki_Server-->>Browser: Response with ScriptInstaller_js

    Common_js->>User_Scripts_Aggregate: importScript and mw_loader_load multiple gadgets
    User_Scripts_Aggregate-->>Browser: Register UI enhancements and tools

    Browser-->>User: Enhanced Wikidata interface with loaded gadgets
Loading

File-Level Changes

Change Details Files
Introduce a new common.js that bulk-loads many Wikidata user scripts and gadgets for enhanced editing and tooling.
  • Create common.js with no prior content
  • Use importScript to reference numerous user-specific gadgets and helper scripts hosted on Wikidata
  • Use mw.loader.load with raw JavaScript URLs to load additional tools and utilities
  • Include duplicate and overlapping loaders for some scripts (e.g., labelcollect, classification, quickpresets, relateditems) and both URL-based and importScript-based variants
  • Mix scripts that appear to be user-personal setups (e.g., other users’ common.js/global.js) into this aggregated loader file
common.js

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there - I've reviewed your changes - here's some feedback:

  • There are multiple duplicate loads of the same scripts (e.g., thirdpartyformatters, labelcollect, metaclass-check, WikidataComplete, relateditems, etc. via both mw.loader.load and importScript); consider consolidating to a single import per script to avoid redundant network requests and potential double‑execution.
  • Some loader URLs appear inconsistent or malformed (for example the Luca.favorido/linkypop.js line lacks the ?title=...&action=raw&ctype=... pattern used elsewhere); it would be good to standardize and verify each mw.loader.load URL to ensure they resolve correctly.
  • Given the very large number of scripts loaded unconditionally, you may want to group related imports and gate some of them behind feature checks or conditions to reduce page load overhead and make future maintenance easier.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- There are multiple duplicate loads of the same scripts (e.g., `thirdpartyformatters`, `labelcollect`, `metaclass-check`, `WikidataComplete`, `relateditems`, etc. via both `mw.loader.load` and `importScript`); consider consolidating to a single import per script to avoid redundant network requests and potential double‑execution.
- Some loader URLs appear inconsistent or malformed (for example the `Luca.favorido/linkypop.js` line lacks the `?title=...&action=raw&ctype=...` pattern used elsewhere); it would be good to standardize and verify each `mw.loader.load` URL to ensure they resolve correctly.
- Given the very large number of scripts loaded unconditionally, you may want to group related imports and gate some of them behind feature checks or conditions to reduce page load overhead and make future maintenance easier.

## Individual Comments

### Comment 1
<location> `common.js:40` </location>
<code_context>
+
+mw.loader.load( '//www.wikidata.org/w/index.php?title=User%3AData-Complete-Gadget%2FWikidataComplete.js&action=raw&ctype=text%2Fjavascript' ); 
+
+mw.loader.load('//www.wikidata.org/wiki/User:Luca.favorido/linkypop.js&action=raw&ctype=text/javascript');
+importScript('User:Pigsonthewing/vector.js'); //Linkback: [[User:Pigsonthewing/vector.js]] 
+importScript('User:TomT0m/LexToWiktionary.js'); //Linkback: [[User:TomT0m/LexToWiktionary.js]] 
</code_context>

<issue_to_address>
**issue (bug_risk):** The `linkypop.js` loader URL is malformed and likely won’t load correctly.

This call differs from the others: it uses `/wiki/User:.../linkypop.js&action=raw...` instead of the `w/index.php?title=...&action=raw&ctype=text/javascript` pattern, and is missing the `?` before the query string. Please switch it to the standard `w/index.php?title=User%3ALuca.favorido%2Flinkypop.js&action=raw&ctype=text%2Fjavascript` form or confirm that the current URL actually returns the raw JS as intended.
</issue_to_address>

### Comment 2
<location> `common.js:45` </location>
<code_context>
+importScript('User:TomT0m/LexToWiktionary.js'); //Linkback: [[User:TomT0m/LexToWiktionary.js]] 
+importScript('User:TomT0m/queries.js'); //Linkback: [[User:TomT0m/queries.js]]
+importScript('User:Pigsonthewing/common.js'); //Linkback: [[User:Pigsonthewing/common.js]] 
+importScript('User:Vvekbv/recoin id.js'); //Linkback: [[User:Vvekbv/recoin id.js]]
+importScript('User:Magnus Manske/wd edit.js'); //Linkback: [[User:Magnus Manske/wd edit.js]]]
+importScript('User:JonnyJD/consistency check.js'); //Linkback: [[User:JonnyJD/consistency check.js]] 
</code_context>

<issue_to_address>
**issue (bug_risk):** The `recoin id.js` path looks inconsistent with the earlier `recoin_id.js` import and may be a typo.

Here you import `User:Vvekbv/recoin id.js` (with a space), whereas earlier you import `User:Vvekbv/recoin_id.js`. If the underscore version is the intended title, this will fail to load; if both pages exist, you’ll load two different scripts. Please standardize on the correct page name.
</issue_to_address>

### Comment 3
<location> `common.js:143` </location>
<code_context>
+importScript('User:The-erinaceous-one/Gadget-relateditems.js'); //Linkback: [[User:The-erinaceous-one/Gadget-relateditems.js]] Added by Script installer
+importScript('User:Lockal/Gadget-relateditems.js'); //Linkback: [[User:Lockal/Gadget-relateditems.js]] Added by Script installer
+importScript('User:Magnus Manske/missing props.js'); //Linkback: [[User:Magnus Manske/missing props.js]] Added by Script installer
+importScript('User:Husky/thirdpartyformatters.js'); //Linkback: [[User:Husky/thirdpartyformatters.js]] Added by Script installer
+importScript('User:Magnus Manske/wdutil.js'); //Linkback: [[User:Magnus Manske/wdutil.js]] Added by Script installer
+importScript('User:Magnus Manske/wikidata useful.js'); //Linkback: [[User:Magnus Manske/wikidata useful.js]] Added by Script installer
</code_context>

<issue_to_address>
**suggestion (bug_risk):** Several scripts appear to be loaded more than once, which is unnecessary and may cause side effects.

For example, `User:Husky/thirdpartyformatters.js` is imported both near the top and bottom, and there are multiple imports of labelcollect/classification variants. These duplicates can cause functions to be redefined or event handlers attached multiple times, leading to subtle bugs and slower page loads. Please deduplicate so each script is imported only once.

Suggested implementation:

```javascript
importScript('User:The-erinaceous-one/Gadget-relateditems.js'); //Linkback: [[User:The-erinaceous-one/Gadget-relateditems.js]] Added by Script installer

```

1. Search the rest of `common.js` for any additional occurrences of:
   - `importScript('User:Husky/thirdpartyformatters.js');`
   - labelcollect/classification-related scripts (e.g., `labelcollect`, `labelcollect-classification` variants).
2. For each script that appears multiple times, decide on a single canonical import location (typically near the top or grouped with similar tools) and remove all other duplicate `importScript`/`mw.loader.load` calls.
3. Ensure that each logical script (by page title, e.g., `User:Foo/bar.js`) is imported exactly once across the entire file, regardless of whether it uses `importScript` or `mw.loader.load`.
</issue_to_address>

### Comment 4
<location> `common.js:54-63` </location>
<code_context>
+//Script to warn about conflicting superclasses on instance/subclass statements
</code_context>

<issue_to_address>
**suggestion (bug_risk):** You’re loading the conflicting superclass script twice via different mechanisms/paths.

You load `User:JesseW/conflicting_superclass_warnings.js` via `mw.loader.load(...)` and later `User:JesseW/conflicting superclass warnings.js` via `importScript(...)`. If these refer to the same script (or duplicated code under different titles), it will run twice, which can cause duplicate initialization and event handlers. Please consolidate to a single canonical import.

Suggested implementation:

```javascript

```

1. Ensure that the other occurrence of this script (likely `importScript('User:JesseW/conflicting superclass warnings.js');`) remains in the file and serves as the single canonical import.
2. If you prefer the underscore form as canonical (`conflicting_superclass_warnings.js`), update that remaining `importScript(...)` call to use that exact title, e.g.:
   `importScript('User:JesseW/conflicting_superclass_warnings.js');`
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread common.js

mw.loader.load( '//www.wikidata.org/w/index.php?title=User%3AData-Complete-Gadget%2FWikidataComplete.js&action=raw&ctype=text%2Fjavascript' );

mw.loader.load('//www.wikidata.org/wiki/User:Luca.favorido/linkypop.js&action=raw&ctype=text/javascript');
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (bug_risk): The linkypop.js loader URL is malformed and likely won’t load correctly.

This call differs from the others: it uses /wiki/User:.../linkypop.js&action=raw... instead of the w/index.php?title=...&action=raw&ctype=text/javascript pattern, and is missing the ? before the query string. Please switch it to the standard w/index.php?title=User%3ALuca.favorido%2Flinkypop.js&action=raw&ctype=text%2Fjavascript form or confirm that the current URL actually returns the raw JS as intended.

Comment thread common.js
importScript('User:TomT0m/LexToWiktionary.js'); //Linkback: [[User:TomT0m/LexToWiktionary.js]]
importScript('User:TomT0m/queries.js'); //Linkback: [[User:TomT0m/queries.js]]
importScript('User:Pigsonthewing/common.js'); //Linkback: [[User:Pigsonthewing/common.js]]
importScript('User:Vvekbv/recoin id.js'); //Linkback: [[User:Vvekbv/recoin id.js]]
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (bug_risk): The recoin id.js path looks inconsistent with the earlier recoin_id.js import and may be a typo.

Here you import User:Vvekbv/recoin id.js (with a space), whereas earlier you import User:Vvekbv/recoin_id.js. If the underscore version is the intended title, this will fail to load; if both pages exist, you’ll load two different scripts. Please standardize on the correct page name.

Comment thread common.js
importScript('User:The-erinaceous-one/Gadget-relateditems.js'); //Linkback: [[User:The-erinaceous-one/Gadget-relateditems.js]] Added by Script installer
importScript('User:Lockal/Gadget-relateditems.js'); //Linkback: [[User:Lockal/Gadget-relateditems.js]] Added by Script installer
importScript('User:Magnus Manske/missing props.js'); //Linkback: [[User:Magnus Manske/missing props.js]] Added by Script installer
importScript('User:Husky/thirdpartyformatters.js'); //Linkback: [[User:Husky/thirdpartyformatters.js]] Added by Script installer
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (bug_risk): Several scripts appear to be loaded more than once, which is unnecessary and may cause side effects.

For example, User:Husky/thirdpartyformatters.js is imported both near the top and bottom, and there are multiple imports of labelcollect/classification variants. These duplicates can cause functions to be redefined or event handlers attached multiple times, leading to subtle bugs and slower page loads. Please deduplicate so each script is imported only once.

Suggested implementation:

importScript('User:The-erinaceous-one/Gadget-relateditems.js'); //Linkback: [[User:The-erinaceous-one/Gadget-relateditems.js]] Added by Script installer
  1. Search the rest of common.js for any additional occurrences of:
    • importScript('User:Husky/thirdpartyformatters.js');
    • labelcollect/classification-related scripts (e.g., labelcollect, labelcollect-classification variants).
  2. For each script that appears multiple times, decide on a single canonical import location (typically near the top or grouped with similar tools) and remove all other duplicate importScript/mw.loader.load calls.
  3. Ensure that each logical script (by page title, e.g., User:Foo/bar.js) is imported exactly once across the entire file, regardless of whether it uses importScript or mw.loader.load.

Comment thread common.js
Comment on lines +54 to +63
//Script to warn about conflicting superclasses on instance/subclass statements
mw.loader.load('//www.wikidata.org/w/index.php?title=User:JesseW/conflicting_superclass_warnings.js&action=raw&ctype=text/javascript'); // [[User:JesseW/conflicting_superclass_warnings.js]]

importScript('User:YMS/labelcollect2.js'); //Linkback: [[User:YMS/labelcollect2.js]] Added by Script installer

importScript('User:TomT0m/classification/sandbox.js'); //Linkback: [[User:TomT0m/classification/sandbox.js]] Added by Script installer
importScript('User:Lectrician1/metaclass-check.js'); //Linkback: [[User:Lectrician1/metaclass-check.js]] Added by Script installer
importScript('User:Daniel Mietchen/wikidp.js'); //Linkback: [[User:Daniel Mietchen/wikidp.js]] Added by Script installer
importScript('User:Wd-Ryan/quickpresets settings.js'); //Linkback: [[User:Wd-Ryan/quickpresets settings.js]] Added by Script installer
importScript('User:Fnielsen/EntityShape.js'); //Linkback: [[User:Fnielsen/EntityShape.js]] Added by Script installer
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (bug_risk): You’re loading the conflicting superclass script twice via different mechanisms/paths.

You load User:JesseW/conflicting_superclass_warnings.js via mw.loader.load(...) and later User:JesseW/conflicting superclass warnings.js via importScript(...). If these refer to the same script (or duplicated code under different titles), it will run twice, which can cause duplicate initialization and event handlers. Please consolidate to a single canonical import.

Suggested implementation:

  1. Ensure that the other occurrence of this script (likely importScript('User:JesseW/conflicting superclass warnings.js');) remains in the file and serves as the single canonical import.
  2. If you prefer the underscore form as canonical (conflicting_superclass_warnings.js), update that remaining importScript(...) call to use that exact title, e.g.:
    importScript('User:JesseW/conflicting_superclass_warnings.js');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant