Ctrl-N in emacs keybindings for Jupyter notebook in Chrome - google-chrome

I'm using Jupyter notebooks in the Chrome browser. I've installed nbextensions and am using the emacs keybindings. Most keys work as expected, even those that conflict with Chrome shortcuts, like ctrl-P. But ctrl-N still opens a new window. I've tried Shortkeys, with which I can set ctrl-N to "do nothing", but it is not passed through to the notebook. I tried AutoControl Shortcut Manager and have the same problem.
Old answers to this question say that you can't override ctrl-N at all, which is no longer true in the newer versions of Chrome, but how do you stop the default behavior and allow the key to pass through to the page?

You can do this with AutoControl Shortcut Manager by using the SYNTHESIZE INPUT action to send a synthetic Ctrl+N from the inside of the webpage.
That way, the webpage will respond to the shortcut but not the browser.
This is how you do it:
Set Ctrl+N as the trigger
Choose SYNTHESIZE INPUT as the action and enter the keystroke Ctrl+N
Select option Send from the inside of webpage
Now, whenever you press Ctrl+N, Chrome will do nothing, but the webpage will receive the keystroke and will react to it.
Of course, you'd only want to do this on those Jupyter Notebook pages, so make sure you add a URL condition to that trigger.

Related

How to move the "re-frame-10x" window back to the browser tab after being popping out into a new window?

I have been using Clojure, ClojureScript, lein, shadow-cljs, re-frame, reagent, Emacs, and CIDER to work on a Clojure/ClojureScript dynamic web app project.
Usually, I build the project by executing the command cider-jack-in-cljs in Emacs, choosing shadow-cljs, then shadow for REPL type, and, finally, app for the building option.
The application loads in localhost:3005 with a debugging dashboard. Apparently, this UI is called "re-frame-10x":
After clicking on the up-right arrow icon on the top-right:
I managed to pop out the debugging dashboard into a new window in Google Chrome. It was injecting some CSS and hiding a button on the webpage. Hence, I decided to "remove it" by popping-it out.
But, I would like to move it back to the browser tab that has localhost on the address. How to do it?
As suggested by #eugene-pakhomov, it was just closing that window. I must highlight that I had tried that before, the only problem was that there were multiple windows of that type. And all of them need to be closed for the process to work!
Not sure why the program opens multiple windows...

Chrome/Firefox: Disable keyboard shortcuts on websites

I am using Outlook Web Access in Chrome and Firefox. On OS X, the webpage uses the keyboard shortcut Option+S for sending off the email. Unfortunately, on OS X the same shortcut is usually used to type the German Umlaut "ß". Hence, whenever I now try to type a word with that character, the website instead sends off my email. Do you know of any plugin or other means to disable such shortcuts on certain websites? Thanks!
You can tell Firefox to disable all keyboard shortcuts for websites (as well a couple other options). Look at this pref on the about:config page.
permissions.default.shortcuts (default = 0)
The values can be set as follows:
UNKNOWN: Services.perms.UNKNOWN_ACTION [0]
ALLOW: Services.perms.ALLOW_ACTION [1]
BLOCK: Services.perms.DENY_ACTION [2]
PROMPT: Services.perms.PROMPT_ACTION [3]
Note that there may be some undesirable side effects, e.g. my fn+delete macOS System function no longer works to delete the next character after my cursor... maybe there's a workaround for that?
I found this solution here:
https://support.mozilla.org/gl/questions/1241294
More context:
I had a similar problem with Outlook Web App (OWA) in Firefox on Macbook (OSX), where I want to refresh the page with cmd+r but instead OWA would interpret the shortcut as "reply" and pop-up a new window to reply to the selected message instead of simply refreshing the page.
Use an OS level tool, such as Automator, to toggle the keybindings based on the browser URL:
A guide to using OS X’s Automator to create your own software
Webkit/Safari/Firefox/API: Can I programmatically read/extract multiple tabs' URLs?
Is there a way to trigger a Hot Key/Keyboard Shortcut via a Shell Script, a AppleScript or a Automator Workflow?
MacOS, how to delete unused service item in Keyboard Shortcuts

How to disable chrome extensions JS when debugging in devtools?

When I add mouse event breakpoint, devtools always jump into extension's JS.
Is there any way to point to my mouse event code directly?
The only way to disable the script (e.g. to avoid side-effects) is by disabling the extension (for instance, by using incognito mode if the extension is not enabled in incognito mode).
If you don't mind the scripts to run, but want to ignore extension code, then you can use the script blackboxing feature of Chrome's devtools.
If you never develop extensions and aren't interested in stepping through it, then open the settings menu of the devtools, click on Blackboxing and then the "Blackbox content scripts" checkbox:
If you only want to selectively ignore files, then you can also right-click on the source of the file that you want to ignore, and click on the "Blackbox Script" contextmenu option. To remove the pattern, go to the "Blackboxing" settings panel as shown before.
I think the simplest way is to open an incognito window (Ctrl-Shift-N) (or Cmd-Shift-N for mac) and debug in there, because then there will be no extensions loaded (by default).
I know what you mean by this question: when debugging, and doing something simple like pausing execution, you always find it breaks into one of the extension's codes instead of the current webpage's code.
open developer tools, then go to settings and then click on ignore list, and check the checkbox for add content script to ignore list, then add this to the ignore list: ^chrome-extension://
If you're using Google Chrome (or any Chromium-based browsers), simply run a new browser instance with a fresh user's data directory.
On Linux:
google-chrome --user-data-dir=$(mktemp -d)
This way, all extensions will be disabled without having to manually switch off/on them.
I like to use Profiles for that.
While changing into incognito mode might help you to disable most of the extensions, some of them might be allowed and still run. For example I have DarkReader and Ublock enabled in incognito mode.
My favorite workaround is to use a "Guest" profile or to create a profile that you can use for debugging. I think it is easier than creating a Framework Ignore List inside of devtools.
How to create a profile: https://support.google.com/chrome/answer/2364824
Example: My debugging profile
First off you should probably review the tutorial on how to debug chrome extensions here:
http://code.google.com/chrome/extensions/tut_debugging.html
When in doubt, you can always use the debugger keyword directly in the JavaScript code where you want to launch the debugger from, like so:
element.addEventListener("mouseover", function() {
debugger;
// some JS handler code...
});
Depending on if your JS is in a popup, background page, or in a content script, you will need make sure you launch the dev tools from the right place.
For a popup, you need to right click on the extension icon and "Inspect Popup" and then from the JavaScript console you would need to run location.reload(true)
For a background page, you need to go to the extensions settings page, chrome://settings/extensions, turn on developer mode, expand the extension in question and click the background page link.
The content script should be visible directly from the page it is loaded onto.

Assign the Shortcut key for Chrome Extension Option page

How can I assign my Google chrome extension option page with shortcut key.
The following works almost as good as a shortcut,
Go to location bar, press Ctrl+L
Type "ce" OR "cs",
Press Enter.
After setting it up as follows,
What I do is, I set them up as search engines on
chrome://settings/searchEngines
Name - Shortcut - URL Chrome Extensions - ce - chrome://extensions/
Name - Shortcut - URL Chrome Settings - cs - chrome://settings/
http://productforums.google.com/forum/#!topic/chrome/hqYtz15LrgQ
Hope this helps!
Currently there is no better way other than injecting content script to all pages with keypress listener. As you would imagine this approach not only isn't very effective, but wouldn't work on some pages (chrome://newtab would be the most annoying one).
Unless assigning a shortcut to your options page is crucial, I wouldn't bother doing it.
I think the options page is meant to be open only from the extension control panel links. However, to solve the shortcut part of the problem you can use the new commands API which will free you from having javascript listeners injected on every page. The shortcuts will work even if you don't have a page loaded in your tab.
You could use this autohotkey script:
#IfWinActive, ahk_class Chrome_WidgetWin_1 ; Shortcut functions only on Chrome
^q::Send, ^t chrome://extensions/ {enter} ; functioning script
#IfWinActive
The second line is the script and means that if you press Ctrl+q (^ stays for Crtl) the script opens a new Tab (Ctrl+t), type the address (chrome://extensions/) and press enter.
You can change the shortcut key changing what is before the ::.
Then I suggest you to put the file .exe in the startup folder.

accessing a chrome extension from outside the browser

Is it possible to access a Chrome Extension from outside the browser?
I would like to be able to run a command from my text editor (MacVim) that refreshes the page on which I am working. From reading the Chrome Extension documentation it looks like I could try something really hack-y, like opening a page that uses Chrome message passing to refresh another page, but there does not seem to be a strait-forward way to do this.
I am running Mac OS X. I've tried the shell command:
$ open <url>
But that opens a new tab every time in Chrome, so this doesn't help when I'm using the developer tools
You are right, there is no straight forward solution.
Your hacky approach is the simplest way to go. Only instead of messaging I would put a tab creation listener into background page, and when a tab with some special URL is created (http://example.com/?do=refresh) - close it and refresh the next selected tab. You will see new tab flickering, but that's as good as it gets.
You can also look into using WebSocket API, for which you would need to write a server side app (which you need to call from your editor somehow). Not sure how this all might turn out.