Skip to content

sylecn/nextpage-we

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

66 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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

Browser Extensions - Mozilla | MDN https://developer.mozilla.org/en-US/Add-ons/WebExtensions

Content scripts - Mozilla | MDN https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Content_scripts Options page - Mozilla | MDN https://developer.mozilla.org/en-US/Add-ons/WebExtensions/user_interface/Options_pages storage.sync - Mozilla | MDN https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/storage/sync Publishing your extension - Mozilla | MDN https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Publishing_your_WebExtension Internationalization - Mozilla | MDN https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Internationalization Interact with the clipboard - Mozilla | MDN https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Interact_with_the_clipboard https://developer.mozilla.org/en-US/docs/Web/API/Document/execCommand

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 http://haskell-servant.readthedocs.io/en/stable/tutorial/Server.html 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

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

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 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.

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

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

Watchers

Forks

Releases

No releases published

Packages

No packages published