Surfingkeys: Error found in settings: ReferenceError: Normal is not defined

Error details

Seeing this error when Surfingkeys tries to load on any page with the following config. I haven’t made any changes to my config recently so I’m inclined to believe it’s related to the Chrome version. I actually run Firefox and Chrome and things are still working well in Firefox for me with the same config.

Error found in settings: ReferenceError: Normal is not defined

https://raw.githubusercontent.com/rjhilgefort/dotfiles-2020/main/config/surfingkeys/config.js

SurfingKeys: 1.0.0

Browser: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36

URL: * (any)

Context

Went to any we page.

image

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 8
  • Comments: 16 (3 by maintainers)

Most upvoted comments

almost all of my personal js setting functions: unmap, cmap, map are erroring with undefined since today

I’m getting something similar, but Error found in settings: ReferenceError: mapkey is not defined instead. The extension seems to work normally after dismissing the banner, but since the banner has to be dismissed on every page, it makes SurfingKeys unusable and I have to disable it 😦

I’m using Normal.insertJS and Normal.jumpVIMark. Is there another way to access these?

Also broke for me: runtime.updateHistory

Thanks

Sounds like the issue I presented is expected to have been removed with 1.0 so I’m going to close the issue. I’ve got my config updated to be compliant with 1.0 (thanks @rosshadden) if anyone is curious about the transition (see history of the file).

https://github.com/rjhilgefort/dotfiles-2020/blob/main/config/surfingkeys/config.js

Only remaining issue for me is I don’t know how to get 1.0 installed on Firefox. It appears to still be behind. @brookhong can I install it manually or is there a release planned for Firefox? https://addons.mozilla.org/en-US/firefox/addon/surfingkeys_ff/

insertJS is a bit intrusive for third-party sites, do you have any strong reason for that?

A bunch of the things I do with insertJS can be done with any script injector extension, but the real magic for me is to connect these things to the shortcuts I create in SK.

I use it for many many useful things, one of which is copying HTML as markdown - it requires injecting a library (turndown) from a CDN + running custom code in the context of the window.

// in visual mode copy as markdown
vmapkey("m", "yank html as markdown", getSelectionAsMarkdown);
// in normal mode selection as markdown
mapkey("ymk", "yank html as markdown", getSelectionAsMarkdown);

I would really want to get insertJS back! I don’t understand what makes it intrusive, there have always been script injectors.

And why would you use jumpVIMark in your own function?

One of my most used features actually. I store all my marks in uppercase.

When I’m choosing a mark, if I press the lowercase key, it’ll open the mark in a new tab or focus it if the tab already exists. If I press the uppercase character, it’ll always open the current tab, even if same url already exists. For numbered marks, it always opens a new tab.

I highly prefer this flow. This is my script:

mapkey("`", "#10Jump to global mark (uppercase: this tab)", function (mark) {
  if (mark === "`") {
    Front.openOmnibar({ type: "VIMarks" });
    return;
  }
  let upper = mark.toUpperCase();
  let newTab = upper !== mark || mark.match(/[0-9]/);
  RUNTIME(
    "getSettings",
    {
      key: "marks",
    },
    function (response) {
      // console.log(response);
      var markInfo = response.settings.marks[upper];
      if (markInfo) {
        if (newTab) {
           Normal.jumpVIMark(upper);
        } else {
            window.open(markInfo.url, newTab ? "_blank" : "_self");
        }
      } else {
        Front.showBanner(`No mark of: ${mark}`);
      }
    }
  );
});

Also why about runtime.updateHistory?

Oh, this I also like to tell people about.

On search engines, I append the search query to links: #qss=my+query+words

Then on the actual search result page, I pull it out of the url, and pre-populate the search, split by pipe:

runtime.updateHistory('find', origSearch.replace(/\+/g, '|'));

Then I just have to press ‘n’ and I’m searching efficiently…

I tried to find other ways, tried using Visual.visualEnter, I actually want to put the search terms there but not actually search… I dug deep into the source code to find updateHistory 😃

Sorry for the confusion, Normal is not a public API now, using it directly in your settings is not recommended even before 1.0 released(though it is still mentioned in README, sorry again for not having it updated), and there is no chance to add it back to public API, please update your settings to remove it.

@brookhong Thanks for the reply, any recommendation on what I can use instead?

Sorry for the confusion, Normal is not a public API now, using it directly in your settings is not recommended even before 1.0 released(though it is still mentioned in README, sorry again for not having it updated), and there is no chance to add it back to public API, please update your settings to remove it.

Similar issue. It appears that any custom config now fails. The error I’m getting is Error found in settings: ReferenceError: map is not defined.

This is when there is only one line in the custom config.