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
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

How to access the visual editor from JavaScript in MediaWiki?

+1
−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 »