Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Notifications
Mark all as read
Q&A

How to access the visual editor from JavaScript in MediaWiki?

+0
−0

In MediaWiki 1.36.1 with Skin:Timeless, the following JavaScript code doesn't work. I get in browser console:

Your skin is incompatible with VisualEditor.
See https://www.mediawiki.org/wiki/Extension:VisualEditor/Skin_requirements for the requirements.

That's strange because right after installing Visual Editor, when I first came to edit, I was asked if I want to use the source code editor OR the visual editor and when I chose the Visual Editor, it worked fine.

let domain = window.location.host;
let protocol = window.location.protocol;
let h1 = document.querySelector("h1");

window.addEventListener('keydown', function(event) {
    if (event.altKey && event.shiftKey && event.key === 'E') {
        window.location.href = `${protocol}//${domain}/index.php?title=${h1.innerText}&veaction=edit`;
    }
});

Why do I get the above error in console and how to solve it?

Notes

  • I emphasize the veaction=edit instead just action=edit in this code
  • Credit for user:hkotsubo‭ who wrote most of that code
Why does this post require moderator attention?
You might want to add some details to your flag.
Why should this post be closed?

1 comment thread

A workaround I've found (1 comment)

0 answers

Sign up to answer this question »

This community is part of the Codidact network. We have other communities too — take a look!

You can also join us in chat!

Want to advertise this community? Use our templates!

Like what we're doing? Support us! Donate