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 justaction=edit
in this code - Credit for user:hkotsubo†who wrote most of that code
1 comment thread