Skip to content

About

nextpage extension for firefox, chrome and the new edge.

Topics

Resources

Stars

20 stars

Watchers

3 watching

Forks

Repository files navigation

Rewrite nextpage add-on using WebExtensions

Privacy Policy

see ./privacy-policy.rst or on the page you download this add-on.

Credit

Icon made by Freepik from www.flaticon.com

notes

how to install the extension

For Firefox, https://addons.mozilla.org/en-US/firefox/addon/nextpage/

For Chrome, https://chrome.google.com/webstore/detail/nextpage/njgkgdihapikidfkbodalicplflciggb?hl=en

For the new Edge (based on chromium), https://microsoftedge.microsoft.com/addons/detail/bdgjidjidpokocijgeefmliejkkjannk

You can also search “nextpage” in Firefox/Chrome/Edge add-on/extension site.

WebExtensions documents

Chrome Extension documents

Developer’s Guide - Google Chrome https://developer.chrome.com/extensions/devguide

JavaScript APIs - Google Chrome https://developer.chrome.com/extensions/api_index

chrome.commands - Google Chrome https://developer.chrome.com/extensions/commands

Message Passing - Google Chrome https://developer.chrome.com/extensions/messaging

how to test web extension on localhost?

how to build extension for distribution?

just run make

This will create zip files that you can upload to firefox/chrome developer page.

test pages

Scrapy 1.6.0 documentation https://docs.scrapy.org/en/latest/intro/overview.html debian install manual: http://www.debian.org/releases/stable/amd64/ emacs manual: http://www.gnu.org/software/emacs/manual/html_node/emacs/Commands.html#Commands freebsd handbook: https://docs.freebsd.org/en/books/handbook/ boost library: https://www.boost.org/doc/libs/1_66_0/doc/html/array.html bing search result: https://www.bing.com/search?q=debian&qs=n&form=QBLH&sp=-1&pq=debian&sc=8-2&sk=&cvid=B56E4A93A3C4496DA0D9B031F698D9FA Elastic doc https://www.elastic.co/guide/en/elasticsearch/reference/current/common-options.html PostgreSQL: Documentation: 9.6: Constraints https://www.postgresql.org/docs/9.6/static/ddl-constraints.html servant documentation https://docs.servant.dev/ bilibili video site search: https://search.bilibili.com/all?keyword=hehe&from_source=banner_search lapack Guide http://www.netlib.org/lapack/lug/node5.html

add-on distribution agreement

Firefox Add-on Distribution Agreement - Mozilla | MDN https://developer.mozilla.org/en-US/Add-ons/AMO/Policy/Agreement Add-on Policies - Mozilla | MDN https://developer.mozilla.org/en-US/Add-ons/AMO/Policy/Reviews App Developer Agreement | Microsoft Docs https://docs.microsoft.com/en-us/legal/windows/agreements/app-developer-agreement

how to publish a new version?

  • update version in ./src/manifest-chrome.json ./src/manifest-firefox.json
  • build extension, run make
  • test locally.
  • publish nextpage-chrome.zip and nextpage-firefox.zip to web store or dev hub.

distribution URL

Firefox Developer Hub https://addons.mozilla.org/en-US/developers/

Chrome Webstore Developer Dashboard https://chrome.google.com/webstore/developer/dashboard click existing item > left hand side, Build > Package > rhs “Upload new package” button

// 2022-08-29 really bad UI design. old UI is easier to find where to upload new pkg.

Microsoft Edge https://partner.microsoft.com/en-us/dashboard/microsoftedge/overview

  • select the extension
  • Packages > click “Replace” link
  • Extension overview > click new version’s Publish button to trigger review

in user config, how to add new command for user to bind?

  • update config file parser in options.js, namely VALID_COMMANDS
  • update command interpreter in nextpage.js, namely runUserCommand
    • add command implementation in nextpage.js
  • update “Available commands:” in ./src/usage.html

dev notes

how to test extension on firefox android?

  • make sure “adb devices” can list your mobile device. install firefox from play store.
  • install web-ext.

    mozilla/web-ext: A command line tool to help build, run, and test web extensions https://github.com/mozilla/web-ext

    cnpm i -g web-ext asdf reshim nodejs web-ext –version 9.2.0

  • see ./run-on-firefox-android.sh to run on your own device, update the android device ID in that command.

how to update default user key bindings?

  • in src/nextpage.js, update let bindings = {
  • in src/options.js, update var bindings = {
  • in src/options.js, update const DEFAULT_CONFIG_TEXT =
  • in src/usage.html, document supported keys and commands if there is anything new.

waiting

2018-04-04 known problem: in chrome, Ctrl and Alt hotkeys are not supported in bind config.

in chrome, C-c etc doesn’t trigger a keypress event. in order to use these keys, you need to use commands system. https://developer.chrome.com/extensions/commands I don’t know whether hotkey key events are exposed in other ways.

2017-10-18 in add-on website, config file help URL is down.

2017-10-19 zh_CN’s messages.json is not read by firefox.

not sure why.

todos

2026-01-19 the user preferences page text looks tiny on chrome. what’s wrong?

2026-01-19 publish 3.2.0 on edge.

2026-01-19 update intro text on all platforms.

2025-11-14 translate the extension to more languages.

  • title
  • description
  • preferences UI
  • user guide html

2023-07-04 make preferences window support dark-mode if browser theme is dark-mode.

2023-07-04 I would like to add a context menu item to copy-title-and-url,

especially when hotkey is disabled on the page. is that possible?

in user config, you can enable this menu item by (enable-context-menu ‘copy-title-and-url)

2019-03-07 make getNextPageLink() function usable in browser dev tools.

e.g. let np = (function() {…})(); np.linkToString(np.getNextPageLink());

2017-10-19 send notification when next page link is not found.

see example here: webextensions-examples/background-script.js at master · mdn/webextensions-examples https://github.com/mdn/webextensions-examples/blob/master/notify-link-clicks-i18n/background-script.js

2021-04-28 mouse-2 (middle button) bindings won’t work in new edge in windows.

middle button triggers auto scroll in edge in windows. nextpage doesn’t get the event.

https://developer.mozilla.org/en-US/docs/Web/API/Element/auxclick_event press middle button on the example here doesn’t work either.

done

2026-01-19 first release to firefox android.

2017-10-19 test it on android. is there a swipe event I can bind to?

add a right arrow button on url bar, also add menu item.

  • 2026-01-19 this is implemented and tested in v3.2.0

2026-01-19 on touch device, when scroll to page bottom, also try to goto next page.

  • only do this on 2nd scroll?

    is that too complicated?

    how about just let user swipe left?

    it’s more natural to swipe up though.

  • cc47: on touch device, when user try to swipe up when page isAtBottom(), run gotoNextPageMaybe(). I already added default key binding for “<swipe-up>”. you implement the rest. @src/nextpage.js

    cc47: 1. currently <swipe-up> is detected, but it didn’t trigger go to next page. check whether isAtBottom() works on firefox android.

    1. you should also update the check for

    elementIsHorizontallyScrollable(), it should only apply when the current touch is swipe-left/right.

    for vertical swipe-up, also check if the element at point is vertically scrollable. auto skip the key processing if it is.

  • added log. confirmed it’s isAtBottom() bug on firefox android.

    window.scrollY 5424.7001953125

    window.scrollMaxY 5488

    try use a percentage for delta.

    (gain 5424 5488)”64.0 1.2%” diff is 64.

    [window.scrollY,window.scrollMaxY]

    when not at bottom, it’s [window.scrollY,window.scrollMaxY] Array [ 5421.86669921875, 5488 ]

    can I use document’s scrollY, not window’s.

    document.scrollY no such property.

    cc47: on firefox android, when page is already scrolled to bottom, window.scrollY is 5424.7001953125 window.scrollMaxY is 5488

    why there is such a large delta? I expect them to be very close. how to check whether page is already scrolled to bottom on firefox android?

    ----

    [window.innerHeight + window.scrollY, document.documentElement.scrollHeight]

    cc47: how do I get scrollHeight? both window.scrollHeight and document.scrollHeight are undefined?

    should be document.documentElement.scrollHeight

    it works.

    when not at bottom: [window.innerHeight + window.scrollY, document.documentElement.scrollHeight] Array [ 6167.86669921875, 6234 ]

    when at bottom: [window.innerHeight + window.scrollY, document.documentElement.scrollHeight] Array [ 6234.7001953125, 6234 ]

    // both firefox and chrome use old chrome’s code path. it works on firefox android.

2026-01-19 google search in China/HK region on firefox android failed to go to next page.

it can’t find next page link.

text is 更多搜索结果

  • git log –grep google
  • fixed.
  • what is that text in US region? “More search results”
  • I also added German language. support for other language is not added.

2026-01-19 duplicated default user config in options.js and nextpage.js

  • WONTFIX I do need js modules to share code between options.js and nextpage.js

    see if I can integrate js modules just for the default user config object.

    cc new session, plan mode: cc47: do you notice the default user keybindings config is duplicated in @src/nextpage.js and @src/options.js, I would like to eliminate this dup code. what is the best way to handle this? can I use javascript modules?

    ---- you can add a shared config.js and load the file in both js files. keep current IIFE pattern.

    you can refactore to ES6 modules.

    ----

    cc47: if possible, I would like to refactor some code, so I can copy & paste code to run in browser js console, such as the code that can return nextpage link or previous page link. would using ES6 module help on this? when using IIFE pattern, some function defined in inner js objects can not easily be shared.

    cc47: most of the functions I want to run in js console (regular browser js console, not content script js console) can work in both extension code env and page env. i.e. I detect which document to look for elements. don’t worry about the execution environment. only worry about code structure reusability.

    cc plan: ~/.claude/plans/breezy-floating-wombat.md

    cc47: > Manifest V2 doesn’t natively support ES6 modules in content_scripts.

    in this case, show me a small snippet what the js file structure will look like in @src/nextpage.js after switching to ES6 module. I feel like I may not like it.

    cc47: okay. I don’t like this. it’s not recommended to pollute window object for extension code.

    let’s go back and just keep current IIFE pattern. add a shared config.js file and load the file in both js files.

  • cc47: 1. why not use “const” for the two variable in config.js?
    1. why options.js uses “Object.assign” to assign the value?

    // good explanation.

    cc47: okay. so if I define the variable in config.js, it will leak to binding to global namespace. I don’t want that. extension guideline doesn’t recommend doing that unless it is strictly needed to avoid conflicts between other people’s extension code.

    can you think of another way to do it without polluting the global namespace?

    ----

    there is no good way of doing it. I will just duplicate the code.

    I can use a build time tool to update the code at the same time. or DONE just add a comment in the code.

  • problems

2025-11-14 gh issue Extension Icon Click Support #62

  • click extension icon should go to nextpage. let user config which command to run when user click the icon.

    (bind “icon-click” ‘nextpage) ; this is the default (bind “icon-click” ‘copy-title-and-url)

  • make click work. then add customize support.

    when you define your own popup or action, the default click action is override.

  • gpt: can I capture icon click event in content_script? I don’t want to introduce background script.

    nope. you have to use bg script or service worker.

    I need to break goto-nextpage function to a library/module, so both content script and service worker script can import the same code.

    //this requires quite a lot of work.

  • 2025-11-27 I think another way is to add an option to add a floating prev page, next page button on the page. on touch device, you can toggle that in preferences and get the buttons.

    if I can capture swipe gesture event, that is the best. enable that by default. then also release the firefox extension for mobile/android.

    swipe to right > prev page swipe to left > next page

    cc47: firefox extension, in a page script, how to add event handler for touch device swipe left & swipe right gesture?

  • 2026-01-18

    ● User answered Claude’s questions: · Should the implementation support vertical swipe gestures (up/down) in addition to horizontal swipes (left/right)? Vertical swipes could map to scroll-up/scroll-down commands. → Horizontal only (left/right) · Should the swipe threshold be configurable by users, or use a fixed value (50px)? → Fixed threshold (50px) · How should the implementation handle page scrolling during swipe detection? → Allow scrolling

    cp ~/.claude/plans/sprightly-tinkering-snowflake.md ./dev-docs/adding-swipe-support.md

  • problems
    • does Emacs support swipe events? what’s the key notation for touch events?

      Touchscreen Events (GNU Emacs Lisp Reference Manual) https://www.gnu.org/software/emacs/manual//html_node/elisp/Touchscreen-Events.html

      //there is no key notation there.

    • how do I test the code? I don’t have a touch screen device other than my phone.

      should I just build the android extension?

      search: can I load temporary add-on on firefox android?

      How to load a temporary extension on Firefox for android? - Add-ons - Mozilla Discourse https://discourse.mozilla.org/t/how-to-load-a-temporary-extension-on-firefox-for-android/144442

      mozilla/web-ext: A command line tool to help build, run, and test web extensions https://github.com/mozilla/web-ext

      cnpm i -g web-ext asdf reshim nodejs web-ext –version 9.2.0

      https://extensionworkshop.com/documentation/develop/web-ext-command-reference/#web-ext-run

      web-ext –help

      adb devices

      cd ~/projects/firefox/nextpage-we/build/firefox/ web-ext run –target=firefox-android –android-device 99211FFBA006CW

      it works. nextpage extension is installed on firefox on my android device (pixel4xl).

    • FIXED default user config settings are not updated in preferences page.
    • FIXED swipe works. left/right is reversed.
    • when scroll on a div that does support scroll, it should not goto next/prev page. similar to when user type hotkey in text input control.

      plan mode

      cc47: when user type hotkey like “n” in HTML text input control, how is the key ignored by the code? @src/nextpage.js

      cc47: when user swipe left or right on a div that natively support scrolling, such as a code block on a blog post, do not trigger nextpage runUserCommand. similar to the userIsTyping() check, there should be a userIsScrolling() check.

      cp ~/.claude/plans/sprightly-tinkering-snowflake.md ./dev-docs/adding-swipe-support.md

      cc47: I renamed the function to elementIsHorizontallyScrollable, update the function to match the feature implied by the new name.

      cc47: before this change, swipe always trigger runUserCommand. after this change, swipe can not trigger runUserCommand at all. check what is wrong. also, how to see console log on firefox android?

      FIXED default user config in src/options.js is not updated. when any user customization is added, default swipe bindings are gone.

      update default user config in src/options.js as well.

    • cc47: on horizontal scrolling object, even when user already scroll to the end, still do not allow runUserCommand. this gives better UX.
    • some page still fail.

      python requests pkg doc. quick start page. scroll on Make a request, 2nd code block.

      (page link is https://docs.python-requests.org/en/latest/user/quickstart/#make-a-request )

      it should not go to next page. but it does.

      test this function: elementIsHorizontallyScrollable(touchTargetElement)

      it’s a <pre> tag. scroll overflow. use in console. let element = temp0; let style = window.getComputedStyle(element); let overflowX = style.overflowX; let isOverflowScrollable = (overflowX === ‘auto’ || overflowX === ‘scroll’); let hasScrollableContent = (element.scrollWidth > element.clientWidth); isOverflowScrollable && hasScrollableContent

      it returns true.

      gpt: on phone, when I touch the same element and swipe left or right. when touch is detected on <PRE>, the scrollable detection works. when touch is detected on <SPAN>, the scrollable detection didn’t work.

      here is the code block element:

      <pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">r</span> <span class="o">=</span> <span class="n">requests</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'https://api.github.com/events'</span><span class="p">)</span>
      </pre>
              

      so to make the detection work, I guess other than the current element, we should also check whether the parent element and grandparent element is scrollable?

      — now it works. I like cc47 (glm-4.7).

2025-11-14 https://eu.startpage.com/ next page not working in German locale #61

  • try this. LANG=de_DE.UTF-8 ~/bin/chrome –user-data-dir=”$HOME/.config/google-chrome-local” https://eu.startpage.com/

    no. I can’t reproduce this issue.

  • in startpage web search settings startpage language: Deutsch

    yes. I can confirm the bug. now next button is in Germany, and fail in nextpage. Weiter

    <button tabindex=”0” class=”css-ocm99y” type=”submit” data-testid=”pagination-button” role=”link”>Weiter</button>

    that’s easy to fix. update the regex.

  • also add support for some other languages. gpt: can you show me most popular “next” or “next page” phrase in most popular languages across the globe?

2025-11-14 do not activate nextpage on one-kvm web UI.

test page https://192.168.2.17/ also ignore on pi-kvm, iLO, iDrac and other IPMI web UI.

2023-12-22 fix issue #60 www.google.com should click on “More Results”

2023-07-04 distribute on AMO gives a warning about Manifest V3

Manifest V3 compatibility warning

Firefox is adding support for manifest version 3 (MV3) extensions in Firefox 109.0, however, older versions of Firefox are only compatible with manifest version 2 (MV2) extensions. We recommend uploading Manifest V3 extensions as self-hosted for now to not break compatibility for your users.

For more information about the MV3 extension roll-out or self-hosting MV3 extensions, visit https://mzl.la/3hIwQXX

  • well. if firefox doesn’t retire MV2, I will stay in MV2.

2023-07-04 switch to manifest v3.

2023-07-04 fix github issue #50, add command for scroll-up and scroll-down

增加向上、向下滚屏的功能,允许用户定义快捷键 #50 sylecn/ff-nextpage#50

  • Window: scrollBy() method - Web APIs | MDN https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollBy

    scroll down one page window.scrollBy(0, window.innerHeight);

    window.scrollBy({top: window.innerHeight, behavior: “instant”});

    scroll up one page window.scrollBy(0, -window.innerHeight);

    window.scrollBy({top: -window.innerHeight, behavior: “instant”});

    window.scrollBy({top: -window.innerHeight, behavior: “auto”}); // auto is slower.

    page down, page up seems faster. I don’t need smooth here.

  • so just add two actions. no default bindings.

    scroll-up scroll-down

  • also add previous-page-maybe, scroll-up if not at top, previous-page otherwise.

2023-02-14 nextpage support prefetch

Link prefetching FAQ - HTTP | MDN https://developer.mozilla.org/en-US/docs/Web/HTTP/Link_prefetching_FAQ

<link>: The External Resource Link element - HTML: HyperText Markup Language | MDN https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#attributes firefox doesn’t support link prefetch?

  • prefetch is supported by all 3. prerender is supported by chrome.
  • put this feature behind a flag. disabled by default.

    (enable-prefetch) (enable-prerender)

    <link rel=”prefetch” href=”/images/big.jpeg” /> <link rel=”prerender” href=”/page/2” >

    when to add these elements to DOM? after page load. just add in nextpage.js load time, if feature is enabled.

  • create a test page to test this feature. https://nextpage.emacsos.com/prefetch-test/1 https://nextpage.emacsos.com/prefetch-test/2 https://nextpage.emacsos.com/prefetch-test/3

    put a lot of text and image on each page. have next page and prev page link on each page.

    <link rel=”prefetch” href=”/images/big.jpeg” as=”image” />

  • if it works, update command in usage.html. add notes on prerender is not supported by firefox.

    prefetch works in firefox. prerender works in chrome/msedge.

  • problems
    • in chrome, load unpacked no longer works I can’t see any files, only dir. click open doesn’t add local extension.

      drop file from file manager to that page also fail. “drop to install” shows, but does nothing.

      is it affected by chrome local admin? /etc/opt/chrome/policies/managed/policy001.json

      xorg/chrome.sls:/etc/opt/chrome/policies/managed/policy001.json

      nope. still fail to install.

      chrome://policy/

      try drop policy. still fail to install local addon.

    • try it in windows. in ryzen5 winten02 VM.

      cp -r build/chrome/ ~/d/shared/nextpage-chrome/ it works in windows 10.

      prerender works very well on freebsd handbook and bing search result page. I would like to enable it by default. User can disable it via config file.

2021-04-26 <mouse-4>, <mouse-5>, <wheel-up>, <wheel-down> no longer work.

github issue 48 sylecn/ff-nextpage#48

  • mouse-5 no longer work in chrome. doesn’t work in firefox. enable debug. oh. I don’t have mouse-5 key. I only have <wheel-down> wheel-down works in both chrome and firefox.
  • 2021-04-26 test whether <mouse-2> (wheel press), <mouse-3> (right click) binding works in windows.

    mouse-2, mouse-3 doesn’t work in linux, nor windows. mouse-2 on linux send no event. mouse-2 on windows trigger free 4-way scroll. mouse-3 show context menu on both linux and windows.

  • EventTarget.addEventListener() - Web APIs | MDN https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener Event reference | MDN https://developer.mozilla.org/en-US/docs/Web/Events MouseEvent - Web APIs | MDN https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent Element: auxclick event - Web APIs | MDN https://developer.mozilla.org/en-US/docs/Web/API/Element/auxclick_event

    try listen to auxclick event. test it in both windows (winten01 VM) and linux.

    auxclick works. mouse-2 and mouse-3 event is triggered properly.

  • problems
    • auxclick works. mouse-2 and mouse-3. but when using mouse-3, context menu still shows.

      search: auxclick disable context menu on right click

    • add “return false”. nope.
    • Element: contextmenu event - Web APIs | MDN https://developer.mozilla.org/en-US/docs/Web/API/Element/contextmenu_event

      Any right-click event that is not disabled (by calling the event’s preventDefault() method) will result in a contextmenu event being fired at the targeted element.

      Element: auxclick event - Web APIs | MDN https://developer.mozilla.org/en-US/docs/Web/API/Element/auxclick_event

      Additionally, you may need to avoid opening a system context menu after a right click. Due to timing differences between operating systems, this too is not a preventable default behavior of auxclick. Instead, this can be done by preventing the default behavior of the contextmenu event.

      MouseEvent.button - Web APIs | MDN https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button

      Users may change the configuration of buttons on their pointing device so that if an event’s button property is zero, it may not have been caused by the button that is physically left–most on the pointing device; however, it should behave as if the left button was clicked in the standard button layout.

    • works in firefox. in chrome, mouse-2 and mouse-3 event not triggered.

      two nextpage installed. load unpacked extension will not replace the extension installed from webstore.

      try use a chrome profile just for testing this extension. it works.

      in edge, mouse-2 event not triggered. mouse-3 works fine. wheel-down works fine.

      search: middle mouse click doesn’t trigger on edge on windows

      Fix Microsoft Edge Mouse Wheel Not Working - Technipages https://www.technipages.com/fix-microsoft-edge-mouse-wheel-not-working

      search: middle mouse click event new edge browser in windows search: capture middle mouse click event in new edge browser

      MOVED mouse-2 (middle button) doesn’t work in new edge in windows. I will leave it for now.

2019-08-23 support previous-page command.

2019-08-23 describeKeyInEmacsNotation bug. shift+p should be “P”, not S-p

just like *.

C-S-l ==> same as C-l S-l ==> L M-S-l ==> M-L

the emacs rules are kind of complicated. I should add some test case for this. if control key and letter keys are pressed, ignore and consume shift key.

  • test cases:
    pressemacs notation
    ll
    S-lL
    88
    **
    C-lC-l
    C-LC-l
    M-lM-l
    M-LM-L
    C-M-LC-M-l
    C-*C-*
    C-M-*C-M-*
    C-.C-.
    C->C->

2019-08-22 describeKeyInEmacsNotation() is not reliable.

“C-S-,” should be C-< in emacs notation. keyCode is S-KEYCODE188 all symbols that requires shift key to press have this problem. “*”, not S-8

  • DONE support (bind “C-.” ‘nextpage)
  • DONE support (bind “C-S-b” ‘nextpage)
  • DONE support (bind “C-(” ‘nextpage) (bind “C-<” ‘nextpage)
  • DONE support (bind “*” ‘nextpage)

    ”-” key is 173 in firefox 68.0.2. “-” key is 189 in chrome 76.0.x.

    e.key will be ‘-’ in both browser.

    use e.key can’t support <kp-2> keys, because browser just return “2”. so I continue to use keyCode to support more keys.

2019-08-22 keypress event to keydown event. fix issue #41.

  • problems
    • press C-i will trigger two events. one for ctrl, one for C-i. I should ignore pure modifier key events. I don’t plan to support key chain.
    • I can capture some built-in hotkey after switching to keydown event. in chrome, C-o, C-h, C-c all send to my extension. C-n is not sent.

      can I block default behavior by returning false?

    • TODO bug in firefox. press p will go previous page, then immediately go next page.

      reproduce:

      open debian install manual. https://www.debian.org/releases/stable/amd64/ press n press p expect see previous page, but see previous page, then immediately see next page.

      No problem in chrome.

      it’s because nextpageLink.click(); send a <mouse-1> click. my ext got that click event. but there is no binding for this key.

      • open debian install manual. press n press toolbar back button. has the same issue. looks like a bug of firefox.

        only debian install manual have the problem? not all page have this problem. ignore this bug for now.

      • firefox 68 doesn’t have the problem. maybe it’s firefox profile issue.

2018-04-06 svg icon not supported by chrome webstore.

can’t install.

https://developer.chrome.com/apps/manifest/icons

2018-04-05 publish extension on chrome webstore

https://chrome.google.com/webstore/developer/dashboard

  • release it now.
  • Detailed description, can I include links? no.
  • need a few 1280x800 screenshot

    could be any design of that size. doesn’t necessarily a screenshot.

    ~/d/nextpage-screenshots/

    sc example pages in 640x400

    // image quality is very poor on desktop browser.

    Applications and themes require at least one screenshot. Extensions may have no screenshots, but such extensions won’t be shown in Chrome Web Store’s browse functions.

    Provide preferably 4 or 5 screenshots of your app (up to a maximum of 5). If your app supports multiple locales, you can provide locale-specific screenshots. Your screenshot should have square corners and no padding (full bleed).

    We prefer screenshots to be 1280x800 pixels in size, as they will be used in future high dpi displays. Currently, the Chrome Web Store will downscale all screenshots to 640x400, so if your screenshots will not look good downscaled (eg. have a lot of text) or if 1280x800 is too big for your app (screenshot of low resolution game), we also support 640x400 pixels screenshots.

    For now, I should use 640x400 images.

    just put 2 images, one intro, one options page.

  • should I enable GA for it?
  • A one-time developer registration fee of US$5.00 is required to verify your account and publish items. Learn more

    paid.

  • publish okay.
  • problems
    • I see this notice on developer dashboard.

      As of November 21st, 2016, all newly published packaged or hosted apps are restricted to Chrome OS, and are not available to users on Windows, Mac or Linux.

      All packaged and hosted apps will be removed from Chrome Web Store search & browse functions in mid-December 2017. Existing apps will continue to work and receive updates.

      it links to Chromium Blog: From Chrome Apps to the Web https://blog.chromium.org/2016/08/from-chrome-apps-to-web.html

      //WTF?

      DONE I will read it later. if the store doesn’t work, just upload to https://emacsos.com/misc/nextpage-chrome.zip

      this only affects chrome apps. is web extension one kind of chrome apps? nope. it’s for apps like atom editor, which is a desktop app that is built on top of chromium.

2018-04-04 feature request: allow bind copy-title-and-url-maybe.

this is for myself. not in default config. I can remove the tabcopy add-on and copy fixer add-on when this is done.

(bind “C-c” ‘copy-title-and-url-maybe)

make it work in both firefox and chrome.

  • add command implementation

    add in nextpage.js, copyTitleAndUrl copyTitleAndUrlMaybe

  • update config file parser. in options.js, update VALID_COMMANDS
  • update interpreter in nextpage.js, runUserCommand
  • well, since commands work differently in chrome. I can bind c instead of Ctrl-C.
  • I will get rid of background script and commands.

    Notes (FYI): to make C-c work in chrome:

    add in manifest-chrome.json:

    "background": {
        "scripts": ["bg.js"],
        "persistent": false
    },
    "commands": {
        "copy-title-and-url-maybe": {
            "suggested_key": {
                "default": "Ctrl+C"
            },
            "description": "Copy Title and URL to clipboard when no text is selected"
        }
    },
        

    create bg.js,

    (function () {
        // eslint-disable-next-line no-console
        let log = console.log;
    
        if (typeof(chrome) !== 'undefined' &&
            typeof(chrome.commands) !== 'undefined') {
            chrome.commands.onCommand.addListener(function(command) {
                switch (command) {
                case "copy-title-and-url":
                case "copy-title-and-url-maybe":
                    chrome.tabs.query({
                        active: true,
                        currentWindow: true
                    }, function(tabs) {
                        chrome.tabs.sendMessage(tabs[0].id, {"onCommand": command});
                    });
                    break;
                default:
                    log('command not supported:', command);
                }
            });
        }
    })();
        

    add in nextpage.js,

    // use command system to handle combination keys
    if (typeof(chrome) !== 'undefined' &&
        typeof(chrome.runtime) !== 'undefined') {
        chrome.runtime.onMessage.addListener(
            // eslint-disable-next-line no-unused-vars
            function(request, sender, sendResponse) {
                if (typeof(request.onCommand) === 'undefined') {
                    return;
                }
                let command = request.onCommand;
                switch (command) {
                case "copy-title-and-url":
                    copyTitleAndUrl();
                    break;
                case "copy-title-and-url-maybe":
                    copyTitleAndUrlMaybe();
                    break;
                default:
                    log("unknown command: ", command);
                }
            });
    }
        
  • problems
    • how to check whether some text is selected? I think I have this code somewhere.

      var selection = window.getSelection();

    • how to copy text to clipboard?

      just check how TabCopy do it.

      ~/.config/google-chrome/Default/Extensions/micdllihgoppmejpecmkilggmaagfdmb/ copyToClipboard()

      it modify doc.oncopy to manually overwrite clipboardData, then call doc.execCommand(‘copy’) so the oncopy event handler is run.

      this is mentioned in https://developer.mozilla.org/en-US/docs/Web/Events/copy

    • TODO bug: when saving user config, no warning given when there is unknown command.
    • in chrome, C-c doesn’t trigger runUserCommand() at all.

      (enable-debug-for-key-events)

      no keypress event when press C-c in chrome.

      Since I can’t reuse the infrastructures, I will create a separate extension for this.

      How about firefox, does it support this? it works in firefox.

      how to know C-c is pressed in chrome? TabCopy can do it.

      https://developer.chrome.com/extensions/events which events are available in chrome? most apis.

      https://developer.chrome.com/extensions/api_index commands API.

      commands only work with background script (event pages). need to send command event to content script to copy page’s title and url. (in bg.js, it will get bg.js’s document url, I tried it.)

      works now. although I didn’t see the default hotkey shown anywhere in chrome UI.

      https://developer.chrome.com/extensions/commands The user can manually add more shortcuts from the chrome://extensions/configureCommands dialog. (Extensions > Keyboard Shortcuts)

    • how to communicate between background script and content script? https://developer.chrome.com/extensions/messaging
    • C-c doesn’t work in options.html textarea, when it’s used to copy-title-and-url-maybe.

      problem went away after I removed bg.js and commands. I don’t need those anyway.

2018-04-04 bug: in firefox, doc link doesn’t link to help page in preferences page.

  • see also the bug in waiting section. that’s mozilla’s add-on website.
  • in chrome, there is a “Help” button, which opens the help page.

// this is not a problem. there is a help button on both firefox and chrome.

2018-03-13 make it work in chrome browser.

  • create a new manifest.json for chrome. drop some unsupported keys.
  • make browser.storage.sync optional in nextpage.js and options.js or use chrome’s sync object.
  • I tried it on x201 today. n key already works. SPC key doesn’t work.
  • 2018-04-04 continue this. I designed the firefox extension first. I will focus on
    • how to sync user configuration across sessions.

      https://developer.chrome.com/extensions/options

      Use the storage.sync API to persist these preferences. These values will then become accessible in any script within your extension, on all your user’s devices.

      chrome.storage.sync.set(data, callback); chrome.storage.sync.get(keyWithDefaultValues, callback);

  • fix any bugs.
    • nextpage.js:905 browser is not defined nextpage.js:979

      https://developer.chrome.com/extensions/storage#type-StorageArea StorageArea api is not the same. in firefox, .get return a Promise. in chrome, you pass in a callback function.

      wait, I used .then() api in firefox. not callback. do I need to create a wrapper for storage access?

      search: chrome.storage.sync browser.storage.sync wrapper

      seems none exists. I will create one, just for my needs.

      That’s just reading user’s parsed config. fixed.

    • preferences page doesn’t show up. update manifest.json, key is different.
    • fix storage usage in options.html options.js:7, :273

      I split store code in storage.js I need to load/include this file in both nextpage.js and options.js.

      fix store usage in options.js

    • fix browser.i18n.getMessage in options.js document.getElementById(elementId).firstChild.nodeValue = browser.i18n.getMessage(messageId);
  • all test pages work in chrome now. test this build in firefox dev env. make sure I didn’t break anything.

    all test page works in firefox.

  • problems
    • try load the unpacked addon.
      • manifest.json
        • Unrecognized manifest key ‘applications’.
        • found unexpected key ‘browser_style’

      search: one manifest.json file for both chrome and firefox extension

      I will use jinja2 template. Can I use m4 for this?

      Since there are only two browsers, and manifest file is not updated very frequently, I will just use two files.

      DONE update build process to use manifest-chrome.json for chrome browser.

    • how to pack for chrome? https://developer.chrome.com/extensions/hosting it’s just zip file, same as firefox. DONE I will create a build dir since manifest file is different.
    • after split storage.js, I listed two js files in content_scripts js. but the later js file can’t access the variables defined in first js file.

      https://developer.chrome.com/extensions/content_scripts#execution-environment

      only page script and content script is isolated. doesn’t say anything about content scripts in one extension. if js files in each content script is isolated, there is no use to include jquery as an example there.

      Are content scripts supposed to share a single global namespace? - Google Groups https://groups.google.com/forum/#!topic/chromium-extensions/-xdbFNr7Q2I

      All content scripts for the same extension/page pair should share a context. If you aren’t seeing this, it is a bug.

      it’s my problem. use var to define global variable. now it works.

    • in chrome, SPC key doesn’t goto next page when at page bottom. n key does work.

      window.scrollMaxY <= window.scrollY this is always false in chrome.

      window.scrollMaxY is undefined in chrome, so it’s always <= a number. scrollMaxY is not standard.

      search: detect scrolled to bottom https://stackoverflow.com/questions/9439725/javascript-how-to-detect-if-browser-window-is-scrolled-to-bottom (window.innerHeight + window.scrollY) >= document.body.offsetHeight

      fixed.

    • doesn’t goto next page on debian site. try enable debugging. (enable-debug) (enable-debug-goto-next-page)

      it finds the next page link, but failed to follow the link. <LINK rel=”next”> href=https://www.debian.org/releases/stable/amd64/pr01.html.en

      maybe .click() is not supported on this node in chrome.

      test page: https://www.debian.org/releases/stable/amd64/ var head = document.getElementsByTagName(‘head’); var lastElement = head[0].lastElementChild; lastElement lastElement.click() the click() function is defined, but it doesn’t goto that URL in chrome.

      document.location.href = lastElement.href;

      (lastElement.tagName.toUpperCase() === “LINK”)

      fixed.

2017-10-18 changelog for first 2.x release

  • [feature] support firefox 57+
  • [feature] user configuration is now synced by browser if you logged in.
  • [feature] add new user config command ignore-on, you can now disable nextpage on some websites. fix issue #15.
  • [notice] This version is a rewrite in Web Extension API. There are two changes that may affect user experience.
    • User config file ~/.config/nextpage.lisp is obsolete. If you have created user config file, please copy & paste the text to the new options window.
    • If some resource of a page loads very slow, nextpage hotkeys may not work on them.
    • Please report a bug if you have other issues in the new version.
  • it’s approved right away. maybe WE add-on doesn’t require much review.
    • test it in xp VM. it works.
  • problems
    • how to release the new add-on. it’s no longer an xpi. https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Publishing_your_WebExtension just zip it.
    • DONE what is update_url? I don’t have it yet. https://developer.mozilla.org/en-US/Add-ons/WebExtensions/manifest.json/applications try remove it.
    • warns about it’s one-way upgrade. you can not go back to xpi.

      TODO I need to check my js files for errors and unused code. maybe rename some variables with underscore in them.

      TODO localization is not added yet. Chinese users will lose UI.

    • validator doesn’t like usage of .innerHTML how to update h3 and span in javascript without using innerHTML?

      search: update span without using innerHTML using innerText or textContent

      myDiv.childNodes[0].nodeValue = “The text has been changed.”;

      document.getElementById(‘elementid’).firstChild.nodeValue = new_text;

2017-10-19 run jslint on my js files

make check

2017-10-19 implement I18N for options window and manifest file.

  • problems
    • do I need to use javascript to rewrite HTML tags in options.html? that will be boring.

      search: firefox web extension option page I18N

      title and labels shows nothing. add-on name is also not reflected on UI.

      try restart firefox

    • There was an error during installation: Extension is invalid

      search: firefox There was an error during installation: Extension is invalid

      works when I add messages.json for zh_CN. maybe it doesn’t like empty locale dirs.

      now i18n works.

    • how to check zh_CN locale options page. about:config general.useragent.locale set to zh-CN need to restart firefox.

      addon name and description works. options page still show English. options page only fetch English message.json, not other languages. confirm in zh-CN and zh locale, it doesn’t fetch _locale/zh_CN/messages.json

      search: browser.i18n.getMessage always fetch English

2017-10-18 disabled website 可以开放出来了。fix bug #15

(ignore-on “https://www.qidian.com/”) (ignore-on “https://.*.qidian.com/”)

both works. cool.

  • parse this command in options.js

    how to do proper parsing? there may be escapes in the string. just use regexp for now. don’t care escapes.

  • use the parse result in nextpage.js
  • document it in usage.html

2017-10-18 add an options page. store user hotkeys somewhere.

  • make user config file backward compatible.
  • ~/projects/firefox/nextpage/src/chrome/content/config.jsm
  • the old preferences window config file: ~/.config/nextpage.lisp

    built-in config: (bind “SPC” ‘nextpage-maybe) (bind “n” ‘nextpage) (bind “p” ‘history-back)

    user config: <text area>

    [save & reload] [reload only] [Help]

  • just remake it using WE api. Options page - Mozilla | MDN https://developer.mozilla.org/en-US/Add-ons/WebExtensions/user_interface/Options_pages

    reading a local text file is impossible now. maybe for security reasons. I will need to store the user configuration somewhere else.

    just use add-on storage api. https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/Storage

    parse result: see parseUserConfig docstring.

    make sure this works:

    1. open webpage. n, p, space works.
    2. change user config.
      ;; user config
      (enable-debug)
      (bind "SPC" 'nextpage-maybe)
      (bind "M-n" 'nextpage)
      (bind "p" 'history-back)
              

      save and reload.

    3. open new webpage. M-n, p, SPC works.
    4. in old webpage. default key works. M-n doesn’t.
  • make mouse click work.
  • if user clear user config, clear the parsed config key.
  • update src/usage.html, there is no longer “file” concept.

    To retain old behavior, if user doesn’t say unbind-all, all built-in binding should continue work.

  • problems
    • how should the two communicate? content script and options page? I can just read key map from storage api. this way it’s always latest. when reload, just parse user config and store it in another key.

      notify page script to update a lexical binding is better. especially those debug variables. I don’t like reading from pref for all of them.

      It will make things too complicated. Just make config work in new tabs. Leave existing tabs alone.

    • DONE remove all occurrence of in_overlay checks
    • storage saved in browser.storage.sync can’t get back. storage.local has the same problem. I can’t get back what I put in.

      I see the problem. let setKey = store.set({ STORAGE_KEY_USER_CONFIG: newUserConfig, STORAGE_KEY_PARSED_CONFIG: parsedUserConfig }); the capital name becomes object literal, not constant! you can force evaluation of the const using [CONST_NAME].

      works now.

2017-10-18 make basic things work.

2017-10-18 16:46:15 basic things work. test whether there are any js errors, then make a commit.

  • problems
    • can I put my code in multiple files and compile them to one? I want to use es2015 modules.

      search: can I use es2015 modules in firefox web extension

      search: compile es2015 modules to a single javascript file

      I will keep it simple. just use old javascript.

    • DONE search for content. after migrating. content is not needed in WE.

About

nextpage extension for firefox, chrome and the new edge.

Topics

Resources

Stars

20 stars

Watchers

3 watching

Forks

Releases

Packages

Used by

Contributors

Languages