Two changes: one bug fix, and the script is now configurable.
Bugfix: I fixed a bug that made the script load the wrong mode when an anchor link was present in the URL (e.g. #some-section
): the script would add ?action=edit
to the URL, which became #some-section?action=edit
which is not how you load the edit page. It would just switch to non-mobile, but not edit.
Config: There are now 3 boolean constants (true
or false
) at the top of the script to configure its behavior.
I also took the opportunity to clean up the code and make it more resilient to this kind of issue in the future; it's now always rebuilding the URL from its core components rather than using string manipulation.