see ./privacy-policy.rst or on the page you download this add-on.
Icon made by Freepik from www.flaticon.com
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.
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
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
- Open “about:debugging” in Firefox, click “Load Temporary Add-on” and select
any file in your extension’s directory.
You can also use web-ext to load temporary WebExtensions from the command line. https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Getting_started_with_web-ext this requires node LTS and npm.
- for Chrome, open Extensions page, click load unpacked extension, choose the src dir.
just run make
This will create zip files that you can upload to firefox/chrome developer page.
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
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
- 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.
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
- 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
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.
not sure why.
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)
e.g. let np = (function() {…})(); np.linkToString(np.getNextPageLink());
- I need to move some function definitions.
what is the best way to define a function?
function foo() {…} let foo = function () {…}; const foo = function () {…};
- Functions - JavaScript | MDN
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions
Seems it doesn’t matter. just use whatever syntax I like.
add a right arrow button on url bar, also add menu item.
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
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.
2023-12-22 fix issue #60 www.google.com should click on “More Results”
- the link
<a class=”T7sFge sW9g3e VknLRd” href=”https://www.google.com/search?q=debian&sca_esv=592848921&sxsrf=AM9HkKkCvWeLSV1KCvTYST9nZe6TWR7mBw:1703174757076&source=hp&ei=ZWKEZYezAsakwAOZlqDQCA&iflsig=AO6bgOgAAAAAZYRwdezdqQJOpkx_8YuSHXi4yTXCZGXo&uact=5&oq=debian&gs_lp=Egdnd3Mtd2l6IgZkZWJpYW4yChAjGIAEGIoFGCcyBBAjGCcyBBAjGCcyChAAGIAEGIoFGEMyCxAAGIAEGIoFGJECMgoQABiABBiKBRhDMgoQABiABBiKBRhDMgoQABiABBiKBRhDMgoQABiABBiKBRhDMgoQABiABBiKBRhDSI0GUABY9gRwAHgAkAEAmAGSAaABiQaqAQMwLja4AQPIAQD4AQHCAg4QABiABBiKBRiRAhixA8ICFBAuGIAEGIoFGLEDGIMBGMcBGK8BwgILEAAYgAQYsQMYgwHCAg4QABiABBiKBRixAxiDAcICCBAAGIAEGLEDwgIREAAYgAQYigUYkQIYsQMYgwHCAhEQLhiABBixAxiDARjHARjRA8ICDRAAGIAEGIoFGEMYsQM&sclient=gws-wiz&aomd=1” style=”transform: scale(1);” jsname=”oHxHid” jsaction=”qBEZuc” aria-label=”More results” data-ve-view=”” role=”button” data-hveid=”CCkQBA” data-ved=”2ahUKEwiD4p609KCDAxUxbPUHHR1rA1IQqq4CegQIKRAE” aria-hidden=”false”><hr class=”KXbwLb” aria-hidden=”true”><h3 aria-hidden=”true”><div class=”GNJvt ipz2Oe”><span class=”kQdGHd”><span class=”OTvAmd z1asCe QFl0Ff”><svg focusable=”false” xmlns=”http://www.w3.org/2000/svg” viewBox=”0 0 24 24”><path d=”M16.59 8.59L12 13.17 7.41 8.59 6 10l6 6 6-6z”></path></svg></span></span><span class=”RVQdVd”>More results</span></div></h3></a>
just add “More results” in <a> link text should work.
~/projects/firefox/nextpage-we/misc/test-regexp.js
but would this match things that it should not match? maybe just add it in preGeneric rule.
www.google.com how about country level google sites? www.google.fr
<a class=”T7sFge sW9g3e VknLRd” href=”https://www.google.fr/search?q=debian&sca_esv=592848921&source=hp&ei=UGSEZf7aGszf2roP59GdgAc&iflsig=AO6bgOgAAAAAZYRyYAAwkdOj5wlhvMrIdht3-9dGPM6W&uact=5&oq=debian&gs_lp=Egdnd3Mtd2l6IgZkZWJpYW4yBRAAGIAEMgUQABiABDIFEAAYgAQyBRAAGIAEMgUQABiABDIFEAAYgAQyBRAAGIAEMgUQABiABDIFEAAYgAQyBRAAGIAESJcJUPQCWO8HcAF4AJABAZgBtgKgAakGqgEHMy4yLjAuMbgBA8gBAPgBAagCAMICERAuGIAEGLEDGIMBGMcBGNEDwgIIEAAYgAQYsQPCAgsQABiABBixAxiDAQ&sclient=gws-wiz&aomd=1” style=”transform: scale(1);” jsname=”oHxHid” jsaction=”qBEZuc” aria-label=” 更多結果” data-ve-view=”” role=”button” data-hveid=”CEUQBA” data-ved=”2ahUKEwi00tSm9qCDAxVnklYBHV7OAlUQqq4CegQIRRAE” aria-hidden=”false”><hr class=”KXbwLb” aria-hidden=”true”><h3 aria-hidden=”true”><div class=”GNJvt ipz2Oe”><span class=”kQdGHd”><span class=”OTvAmd z1asCe QFl0Ff”><svg focusable=”false” xmlns=”http://www.w3.org/2000/svg” viewBox=”0 0 24 24”><path d=”M16.59 8.59L12 13.17 7.41 8.59 6 10l6 6 6-6z”></path></svg></span></span><span class=”RVQdVd”>更多結果</span></div></h3></a>
www.google.com.hk 更多结果
<a class=”T7sFge sW9g3e VknLRd” href=”https://www.google.com.hk/search?q=debian&sca_esv=592848921&source=hp&ei=y2OEZYZU8qXaug-J3rf4Aw&iflsig=AO6bgOgAAAAAZYRx2wrCzohtV0CN7LYHYz_sfoJ_SkHA&uact=5&oq=debian&gs_lp=Egdnd3Mtd2l6IgZkZWJpYW4yBRAAGIAEMgUQABiABDIFEAAYgAQyBRAAGIAEMgUQABiABDIFEAAYgAQyBRAAGIAEMgUQABiABDIFEAAYgAQyBRAAGIAESMkIUO8CWKYHcAF4AJABAJgBhQGgAeIEqgEDNC4yuAEDyAEA-AEBqAIAwgILEAAYgAQYsQMYgwHCAgsQLhiABBjHARjRA8ICERAuGIAEGLEDGIMBGMcBGNEDwgIOEC4YgAQYsQMYgwEY1ALCAgsQLhiABBixAxiDAcICDhAAGIAEGIoFGLEDGIMB&sclient=gws-wiz&aomd=1” style=”transform: scale(1);” jsname=”oHxHid” jsaction=”qBEZuc” aria-label=” 更多结果” data-ve-view=”” role=”button” data-hveid=”CEEQBA” data-ved=”2ahUKEwjnne3g9aCDAxXhrlYBHRjWBcYQqq4CegQIQRAE” aria-hidden=”false”><hr class=”KXbwLb” aria-hidden=”true”><h3 aria-hidden=”true”><div class=”GNJvt ipz2Oe”><span class=”kQdGHd”><span class=”OTvAmd z1asCe QFl0Ff”><svg focusable=”false” xmlns=”http://www.w3.org/2000/svg” viewBox=”0 0 24 24”><path d=”M16.59 8.59L12 13.17 7.41 8.59 6 10l6 6 6-6z”></path></svg></span></span><span class=”RVQdVd”>更多结果</span></div></h3></a>
- use preGeneric, I can support CN and EN.
querySelector match on attribute it works.
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.
- chrome Extensions - Chrome Developers https://developer.chrome.com/docs/extensions/ Migrate from Manifest V2 to Manifest V3
- v3 changes
- service worker replace background pages. I don’t use bg pages.
- other changes doesn’t affect my extension. // so I can just update version to 3.
- update my extension
- Update the manifest - Chrome Developers https://developer.chrome.com/docs/extensions/migrating/manifest/
- Manifest V3 migration checklist - Chrome Developers https://developer.chrome.com/docs/extensions/migrating/checklist/
- Replace Browser Actions and Page Actions with Actions
https://developer.chrome.com/docs/extensions/migrating/api-calls/#replace-browser-page-actions
MOVED I would like to add a context menu item to copy-title-and-url, when hotkey
is disabled. is that possible?
in user config, you can enable this menu item by (enable-context-menu ‘copy-title-and-url)
- yeah, nothing to change for chrome.
- now change firefox’s document.
- nothing to change for firefox. also, firefox is not deprecating v2.
just different browser version support different WebExtension APIs.
Browser extensions - Mozilla | MDN https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions manifest.json - Mozilla | MDN https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json Browser support for JavaScript APIs - Mozilla | MDN https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Browser_support_for_JavaScript_APIs
- new code tested in chrome 114.
- test in firefox 114.
- problems
- when firefox is using dark theme, my preferences page doesn’t follow the theme. bg is white.
- hotkeys not working in firefox.
no key events.
check API changes in firefox.
I used document.addEventListener(“keydown”, function (e) {…})
Permissions access your data for all websites toggle is off.
when this is enabled, it works. so check permission changes in v3 in firefox.
search: firefox web extension access your data for all websites is off by default
I think browser will ask user when user install the add-on.
- in chrome, preferences page width, height should be set.
default is too small. user can’t see Save and Help button.
search: chrome options_ui window min height and width
try add css in options.html
nope. min-height is document height, it just add white space at page bottom. the window size is still small.
search: chrome options_ui window min height and width
How can I set height of chrome extension to browser window height? - Stack Overflow https://stackoverflow.com/questions/47568794/how-can-i-set-height-of-chrome-extension-to-browser-window-height
600px height and 800px width - are the maximums for a popup size. You can’t change that.
Then I need to rework this UI.
can I show preferences in a regular tab?
Chrome Extensions: Give users options - Chrome Developers https://developer.chrome.com/docs/extensions/mv3/options/
use options_page to open in a tab. use options_ui to open in pop up or tab (with open_in_tab: true).
I will keep using options_page. Firefox has different behavior with Chrome on this.
增加向上、向下滚屏的功能,允许用户定义快捷键 #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.
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.
- in chrome, load unpacked no longer works
I can’t see any files, only dir. click open doesn’t add local extension.
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.
- auxclick works. mouse-2 and mouse-3.
but when using mouse-3, context menu still shows.
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:
press emacs notation l l S-l L 8 8 * * C-l C-l C-L C-l M-l M-l M-L M-L C-M-L C-M-l C-* C-* C-M-* C-M-* C-. C-. C-> C->
“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.
- 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.
- open debian install manual.
press n
press toolbar back button. has the same issue.
looks like a bug of firefox.
can’t install.
https://developer.chrome.com/apps/manifest/icons
- use png icon. 128x128 most commonly used 48x48 used in chrome://extensions 16x16 favicon
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.
- I see this notice on developer dashboard.
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.
- how to check whether some text is selected?
I think I have this code somewhere.
- 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.
- 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);
- how to sync user configuration across sessions.
- 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);
- nextpage.js:905 browser is not defined
nextpage.js:979
- 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.
- manifest.json
- 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.
- try load the unpacked addon.
- [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;
make check
- 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
- do I need to use javascript to rewrite HTML tags in options.html?
that will be boring.
(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
- 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:
- open webpage. n, p, space works.
- change user config.
;; user config (enable-debug) (bind "SPC" 'nextpage-maybe) (bind "M-n" 'nextpage) (bind "p" 'history-back)
save and reload.
- open new webpage. M-n, p, SPC works.
- 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.
- 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.
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.
- can I put my code in multiple files and compile them to one?
I want to use es2015 modules.