Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Work around Scratchpad issue.

  • Loading branch information...
commit 3ea1b4ac7260763ad06b784394eefae166fdc069 1 parent 6ec3139
@arantius arantius authored
Showing with 30 additions and 0 deletions.
  1. +1 −0  chrome.manifest
  2. +29 −0 content/scratchpad-overlay.xul
View
1  chrome.manifest
@@ -21,5 +21,6 @@ overlay about:addons chrome://greasemonkey/content/addons4-overlay.xul
overlay chrome://greasemonkey/content/install.xul chrome://greasemonkey/content/closewindow.xul
overlay chrome://greasemonkey/content/options.xul chrome://greasemonkey/content/closewindow.xul
overlay chrome://greasemonkey/content/newscript.xul chrome://greasemonkey/content/closewindow.xul
+overlay chrome://browser/content/scratchpad.xul chrome://greasemonkey/content/scratchpad-overlay.xul
locale greasemonkey en-US locale/en-US/
View
29 content/scratchpad-overlay.xul
@@ -0,0 +1,29 @@
+<?xml version="1.0"?>
+
+<overlay id="greasemonkey-browser-overlay"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+>
+
+<script type="application/x-javascript">
+// If we're opening a user script, put the cursor at the top.
+// Workaround for #1708 ; remove when http://bugzil.la/843597 is fixed.
+window.addEventListener('load', function() {
+ var args = window.arguments;
+ if (!args) return;
+ if (!(args[0] instanceof Ci.nsIDialogParamBlock)) return;
+ args = args[0].GetString(1);
+ if (!args) return;
+ args = JSON.parse(args);
+ if (!args.filename) return;
+ if (!args.filename.match(/\.user\.js$/)) return;
+ function moveCursorToTop() {
+ // Retry via timeout until initialization is complete.
+ if (!Scratchpad.initialized) return setTimeout(moveCursorToTop, 50);
+ // Then move the cursor to the top.
+ Scratchpad.selectRange(0, 0);
+ }
+ moveCursorToTop();
+}, true);
+</script>
+
+</overlay>
Please sign in to comment.
Something went wrong with that request. Please try again.