forked from Tiny-Giant/myuserscripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFirefoxFocusFix.user.js
More file actions
20 lines (18 loc) · 858 Bytes
/
FirefoxFocusFix.user.js
File metadata and controls
20 lines (18 loc) · 858 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// ==UserScript==
// @name Firefox Focus Fix
// @namespace http://tinygiant.io
// @version 1.0.0.2
// @description Fixes the recent change implemented by Firefox which places the caret at the end of the text on focus instead of the beginning
// @author @TinyGiant
// @include /^https?:\/\/(.*\.)?(stackexchange.com|stackoverflow.com|serverfault.com|superuser.com|askubuntu.com|stackapps.com|mathoverflow.net)/
// @grant none
// ==/UserScript==
document.body.appendChild(document.createElement('script')).textContent = `(function() {
const oldfocus = HTMLElement.prototype.focus;
HTMLElement.prototype.focus = function() {
oldfocus.call(this);
if (/wmd-input/.test(this.className))
if (this.selectionEnd === this.selectionStart)
this.selectionEnd = 0;
};
})()`;