14

I have a couple of decades experience using Emacs, so the Emacs-like keybindings for text editing on Mac OS X are very nice. Unfortunately, some websites (ahem) choose to override these with Javascript. For example, one of them makes controlB insert the text **strong text**, rather than going back one character.

Is there any way to make Safari ignore Javascript keybindings that try to remap the standard OS X keybindings?

  • I don't know any general way to do that, but you could use GreaseKit to disable the WMD shortcuts. See Is there a way to disable the hotkeys? - Meta Stack Overflow. – Lri Aug 13 '12 at 17:37
  • Thanks for the link! It's frustrating to see that they think it's fine just because people didn't complain enough. (I've been using SE sites for years and I didn't realize I needed to start complaining on day 1 for my voice to be heard.) I'm hesitant to add any web browser extensions, though, since the first part of any web browser issue diagnosis is "disable all extensions". – Ken Aug 13 '12 at 17:53
  • 1
    I'm with Ken. I personally can't count how many times I've had to use "undo" because my hands forgot I was on an SE site :S – ephsmith Aug 19 '12 at 0:42
  • I was going to suggest that you could disable javascript... It fixed your problem, but it created a new one — I could no longer post comments on StackExchange... =P – daviewales Dec 3 '12 at 8:06
  • 1
    Is this question about the site here? or about disabling javascript everywhere? I could move it to our meta as a bug report, but there's already several requests for this site wide. meta.stackexchange.com/questions/3245/… – bmike Apr 30 '13 at 14:31
7
+50

Here is Rob W's script from meta, updated to only block cntrl-* and fixed so that it works with NinjaKit which is a safari extension for running user scripts.

NinjaKit: https://github.com/os0x/NinjaKit

Script:

// ==UserScript==
// @name           Cya WMD shortcuts
// @namespace      Rob W
// @version        1.0
// @include          http://apple.stackexchange.com/*
// @include          http://stackoverflow.com/*
// @include          http://superuser.com/*
// @include          http://meta.superuser.com/*
// @include          http://serverfault.com/*
// @include          http://meta.serverfault.com/*
// @include          http://askubuntu.com/*
// @include          http://meta.askubuntu.com/*
// @include          http://*.stackexchange.com/*
// @include          http://answers.onstartups.com/*
// @include          http://meta.answers.onstartups.com/*
// @include          http://stackapps.com/*
// @run-at         document-end
// @grant          none
// ==/UserScript==
(function () {
    var p = document.getElementById('wmd-input');
    console.log("wmd-input:" + p);
    if (p) {
        p = p.parentNode;

        function ignore(e) {
            if (e.ctrlKey) {
                e.stopPropagation();
            }
        }
        p.addEventListener('keydown', ignore, true);
        p.addEventListener('keypress', ignore, true);
        p.addEventListener('keyup', ignore, true);
    }
})();
1

It's been a while since I've used it, but the Privoxy proxy server has the feature to modify javascript to change behavior. If you're willing to run a proxy server, that is an option.

I did look (though not exhaustively), and didn't see a browser plugin that rewrote content (xml, html, CSS, or javascript) like privoxy does. In Privoxy's web page, look for the js-annoyances filter. That is where you'll find examples of rewriting javascript.

Perhaps there's a more modern implementation in the form of a browser plugin that provides a similar feature, but privoxy used to work fine for this use case.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .