├── .gitignore
├── doc
└── images
│ ├── options.png
│ ├── get-the-addon.png
│ └── ruler-demo-1.gif
├── content
├── icons
│ ├── ruler-48.png
│ ├── ruler-96.png
│ ├── ruler-128.png
│ ├── ruler-disabled-128.png
│ ├── ruler-disabled-48.png
│ └── ruler-disabled-96.png
├── popup
│ ├── negative.svg
│ └── popup.html
├── _locales
│ └── en
│ │ └── messages.json
├── css
│ ├── main.css
│ └── popup.css
├── src
│ ├── common
│ │ ├── colors.js
│ │ ├── commands.js
│ │ ├── extension.js
│ │ └── options.js
│ ├── content
│ │ ├── dom.js
│ │ ├── polyfills.js
│ │ ├── range.js
│ │ ├── iframe-visualizer.js
│ │ ├── rect.js
│ │ ├── highlight-visualizer.js
│ │ ├── caret.js
│ │ ├── main.js
│ │ ├── negative-visualizer.js
│ │ └── ruler.js
│ ├── popup
│ │ ├── color-chooser.js
│ │ └── popup.js
│ ├── background
│ │ └── background.js
│ └── LICENSE
└── manifest.json
├── package.json
├── .vscode
└── settings.json
├── README.md
└── LICENSE
/.gitignore:
--------------------------------------------------------------------------------
1 | dist/
2 | node_modules/
3 | content/src/polyfills/**
--------------------------------------------------------------------------------
/doc/images/options.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/orentrutner/reading-ruler/HEAD/doc/images/options.png
--------------------------------------------------------------------------------
/content/icons/ruler-48.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/orentrutner/reading-ruler/HEAD/content/icons/ruler-48.png
--------------------------------------------------------------------------------
/content/icons/ruler-96.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/orentrutner/reading-ruler/HEAD/content/icons/ruler-96.png
--------------------------------------------------------------------------------
/content/icons/ruler-128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/orentrutner/reading-ruler/HEAD/content/icons/ruler-128.png
--------------------------------------------------------------------------------
/doc/images/get-the-addon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/orentrutner/reading-ruler/HEAD/doc/images/get-the-addon.png
--------------------------------------------------------------------------------
/doc/images/ruler-demo-1.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/orentrutner/reading-ruler/HEAD/doc/images/ruler-demo-1.gif
--------------------------------------------------------------------------------
/content/icons/ruler-disabled-128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/orentrutner/reading-ruler/HEAD/content/icons/ruler-disabled-128.png
--------------------------------------------------------------------------------
/content/icons/ruler-disabled-48.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/orentrutner/reading-ruler/HEAD/content/icons/ruler-disabled-48.png
--------------------------------------------------------------------------------
/content/icons/ruler-disabled-96.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/orentrutner/reading-ruler/HEAD/content/icons/ruler-disabled-96.png
--------------------------------------------------------------------------------
/content/popup/negative.svg:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "reading-ruler",
3 | "version": "1.8",
4 | "description": "A browser add-on to highlight the row of text you are reading.",
5 | "main": "main.js",
6 | "homepage": "https://addons.mozilla.org/en-US/firefox/addon/readingruler",
7 | "repository": "git@github.com:orentrutner/reading-ruler.git",
8 | "author": "Oren Trutner ",
9 | "license": "GPL-3.0",
10 | "scripts": {
11 | "polyfills": "cpx node_modules/webextension-polyfill/dist/browser-polyfill.min.js content/src/polyfills/",
12 | "build": "web-ext build --overwrite-dest --source-dir=content --artifacts-dir dist",
13 | "start": "web-ext run --source-dir=content --url=https://github.com/orentrutner/reading-ruler"
14 | },
15 | "devDependencies": {
16 | "@types/download": "^8.0.1",
17 | "body-parser": "1.20.0",
18 | "cpx": "^1.5.0",
19 | "download": "^8.0.0",
20 | "express": "4.18.1",
21 | "safe-compare": "^1.1.4",
22 | "web-ext": "^7.2.0",
23 | "webextension-polyfill": "^0.10.0"
24 | },
25 | "resolutions": {
26 | "ws": "^7.4.6"
27 | },
28 | "dependencies": {
29 | "ws": "^8.8.1"
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "psi-header.templates": [
3 | {
4 | "language": "*",
5 | "template": [
6 | "Copyright 2020-2022 Oren Trutner",
7 | "",
8 | "This file is part of Reading Ruler.",
9 | "",
10 | "Reading Ruler is free software: you can redistribute it and/or modify",
11 | "it under the terms of the GNU General Public License as published by",
12 | "the Free Software Foundation, either version 3 of the License, or",
13 | "(at your option) any later version.",
14 | "",
15 | "Reading Ruler is distributed in the hope that it will be useful,",
16 | "but WITHOUT ANY WARRANTY; without even the implied warranty of",
17 | "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the",
18 | "GNU General Public License for more details.",
19 | "",
20 | "You should have received a copy of the GNU General Public License",
21 | "along with Reading Ruler. If not, see ."
22 | ]
23 | }
24 | ]
25 | }
--------------------------------------------------------------------------------
/content/_locales/en/messages.json:
--------------------------------------------------------------------------------
1 | {
2 | "extensionName": {
3 | "message": "Reading Ruler",
4 | "description": "Name of the extension"
5 | },
6 | "extensionDescription": {
7 | "message": "Highlights the row of text you are reading.",
8 | "description": "Description of the extension"
9 | },
10 | "addonEnabledText": {
11 | "message": "Enable Reading Ruler",
12 | "description": "Enable Reading Ruler checkbox"
13 | },
14 | "hotkeyInfo": {
15 | "message": "You can also use the Alt+R hotkey to enable and disable Reading Ruler.",
16 | "description": "A message telling the user about the hotkey for the add-on."
17 | },
18 | "colorHeading": {
19 | "message": "Color",
20 | "description": "Heading of the popup's color section"
21 | },
22 | "opacityHeading": {
23 | "message": "Opacity",
24 | "description": "Heading of the popup's opacity section"
25 | },
26 | "showOnThisPage": {
27 | "message": "Show on this page",
28 | "description": "Show on this page checkbox"
29 | },
30 | "showOnAllPagesOf": {
31 | "message": "Show on all pages of $1",
32 | "description": "Show on all pages checkbox"
33 | }
34 | }
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Reading Ruler
2 | [](https://addons.mozilla.org/en-US/firefox/addon/readingruler/)
3 |
4 | Reading Ruler is a browser add-on that highlights the row of text under the mouse cursor. This helps you focus on the text you are currently reading, or come back to it if your mind wanders as you read.
5 |
6 | The ruler works best for articles, blogs and long posts. You can hide it on pages or sites where it doesn't help as much.
7 |
8 | You can choose the color and opacity of the ruler for the level of contrast you like best.
9 |
10 | Reading Ruler does not collect your data. It does not send anything to the cloud. It does not collect telemetry. It is not interested in monetization; and, it definitely does not show ads.
11 |
12 | 
13 |
14 | 
15 |
16 | # Notes to developers
17 | ## Running the add-on locally
18 | Before running the add-on on your development computer for the first time:
19 | ```
20 | yarn
21 | yarn polyfills
22 | ```
23 |
24 | To run the add-on in a sandboxed instance of Firefox, run:
25 | ```
26 | yarn start
27 | ```
28 |
29 | ## Publishing to the Mozilla Developer Hub
30 | Before publishing:
31 | 1. Bump the version number in `package.json` and `manifest.json`.
32 | 2. Build and pack the add-on:
33 | ```
34 | yarn build
35 | ```
--------------------------------------------------------------------------------
/content/css/main.css:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020-2022 Oren Trutner
3 | *
4 | * This file is part of Reading Ruler.
5 | *
6 | * Reading Ruler is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * Reading Ruler is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with Reading Ruler. If not, see .
18 | */
19 |
20 | .--reading-ruler-ruler, .--reading-ruler-top, .--reading-ruler-mask, .--reading-ruler-bottom {
21 | background: none;
22 | opacity: 0;
23 |
24 | position: fixed;
25 | max-width: none; /* Don't let the page override the size of the ruler. */
26 | z-index: 2147483647;
27 |
28 | pointer-events: none;
29 | transition: all 0.1s, opacity 0.3s ease-in-out;
30 | }
31 |
32 | .--reading-ruler-ruler {
33 | background-color: steelblue;
34 | border-radius: 4px;
35 | }
36 |
37 | .--reading-ruler-top, .--reading-ruler-mask, .--reading-ruler-bottom {
38 | background-color: black;
39 | }
--------------------------------------------------------------------------------
/content/src/common/colors.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020-2022 Oren Trutner
3 | *
4 | * This file is part of Reading Ruler.
5 | *
6 | * Reading Ruler is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * Reading Ruler is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with Reading Ruler. If not, see .
18 | */
19 |
20 | const COLORS = [
21 | { name: 'blue', hex: '#4682b4', appearance: 'ruler', label: 'Blue', icon: null },
22 | { name: 'lime', hex: '#99dd00', appearance: 'ruler', label: 'Lime', icon: null },
23 | { name: 'yellow', hex: '#eebb00', appearance: 'ruler', label: 'Yellow', icon: null },
24 | { name: 'orange', hex: '#dd4400', appearance: 'ruler', label: 'Orange', icon: null },
25 | { name: 'pink', hex: '#ff0066', appearance: 'ruler', label: 'Pink', icon: null },
26 | { name: 'negative', hex: '#ffffff', appearance: 'negative', label: 'Negative', icon: 'negative.svg' },
27 | ];
--------------------------------------------------------------------------------
/content/src/common/commands.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020-2022 Oren Trutner
3 | *
4 | * This file is part of Reading Ruler.
5 | *
6 | * Reading Ruler is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * Reading Ruler is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with Reading Ruler. If not, see .
18 | */
19 |
20 | /** Commands bound to hotkeys in manifest.json */
21 | const MANIFEST_EXTENSION_COMMANDS = {
22 | toggleAddon: 'toggle-addon'
23 | };
24 |
25 | /** Commands passed between content, background and popup scripts. */
26 | const INTERNAL_EXTENSION_COMMANDS = {
27 | activate: 'activate',
28 | deactivate: 'deactivate',
29 | options: 'options',
30 | };
31 |
32 | /** Commands passed between windows via window.postMessage() */
33 | const WINDOW_COMMANDS = {
34 | show: 'show',
35 | hide: 'hide',
36 | stash: 'stash',
37 | positionAt: 'positionAt'
38 | };
39 |
40 | const WINDOW_MESSAGE_GUARD = 'reading-ruler';
--------------------------------------------------------------------------------
/content/src/content/dom.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020-2022 Oren Trutner
3 | *
4 | * This file is part of Reading Ruler.
5 | *
6 | * Reading Ruler is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * Reading Ruler is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with Reading Ruler. If not, see .
18 | */
19 |
20 | /** Maps iframe window objects to their iframe elements. */
21 | let frameCache = null;
22 |
23 | /** Gets the iframe element hosting the given window. */
24 | function frameFromWindow(frameWindow) {
25 | const cachedFrame = frameCache && frameCache.get(frameWindow);
26 | if (cachedFrame) {
27 | return cachedFrame;
28 | }
29 |
30 | for (const frame of window.document.getElementsByTagName('iframe')) {
31 | if (frame.contentWindow === frameWindow) {
32 | if (!frameCache) {
33 | frameCache = new Map();
34 | }
35 | frameCache.set(frameWindow, frame);
36 | return frame;
37 | }
38 | }
39 |
40 | return null;
41 | }
42 |
--------------------------------------------------------------------------------
/content/src/content/polyfills.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020-2022 Oren Trutner
3 | *
4 | * This file is part of Reading Ruler.
5 | *
6 | * Reading Ruler is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * Reading Ruler is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with Reading Ruler. If not, see .
18 | */
19 |
20 | /** Gets the DOM node at a page coordinate and its bounding rectangle. */
21 | function caretFromPoint(x, y) {
22 | if (document.caretPositionFromPoint) {
23 | const position = document.caretPositionFromPoint(x, y);
24 | const rect = position?.getClientRect();
25 | return ((position && rect)
26 | ? {
27 | node: position.offsetNode,
28 | offset: position.offset,
29 | rect: rect
30 | }
31 | : null);
32 | } else if (document.caretRangeFromPoint) {
33 | const range = document.caretRangeFromPoint(x, y);
34 | const rect = range?.getBoundingClientRect();
35 | return ((range && rect)
36 | ? {
37 | node: range.commonAncestorContainer,
38 | offset: range.startOffset,
39 | rect: rect
40 | }
41 | : null);
42 | } else {
43 | return null;
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/content/src/content/range.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020-2022 Oren Trutner
3 | *
4 | * This file is part of Reading Ruler.
5 | *
6 | * Reading Ruler is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * Reading Ruler is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with Reading Ruler. If not, see .
18 | */
19 |
20 | /*
21 | * Range functions. A range represents a 1-dimensional interval defined by
22 | * low and high values (inclusive.)
23 | */
24 |
25 | /** Checks if a number is within a range (inclusive.) */
26 | function rangeContains(value, low, high) {
27 | return value >= low && value <= high;
28 | }
29 |
30 | /** Gets the nearest value inside a range to a given value. */
31 | function rangeClip(value, low, high) {
32 | return (value < low ? low : (value > high ? high : value));
33 | }
34 |
35 | /** Checks if a number is within a range or outside but near its boundaries. */
36 | function rangeContainsOrIsNear(value, low, high, fraction) {
37 | const buffer = (high - low) * fraction;
38 | return rangeContains(value, low - buffer, high + buffer);
39 | }
40 |
41 | /**
42 | * Gets the distance from a value to the nearest end of a range.
43 | * Returns 0 if the value is inside the range.
44 | */
45 | function rangeDistanceToValue(value, low, high) {
46 | return (rangeContains(value, low, high)
47 | ? 0
48 | : Math.min(Math.abs(value - low), Math.abs(value - high)));
49 | }
--------------------------------------------------------------------------------
/content/src/common/extension.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020-2022 Oren Trutner
3 | *
4 | * This file is part of Reading Ruler.
5 | *
6 | * Reading Ruler is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * Reading Ruler is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with Reading Ruler. If not, see .
18 | */
19 |
20 | /** Gets the currently active browser tab. */
21 | async function getCurrentTab() {
22 | const tabs = await browser.tabs.query({ active: true, currentWindow: true });
23 | return (tabs && tabs.length && tabs.length > 0
24 | ? tabs[0]
25 | : null);
26 | }
27 |
28 | /** Broadcasts a message throughout the add-on. */
29 | async function broadcast(message) {
30 | const normalizedMessage = normalizeMessage(message);
31 |
32 | // Send the message to the background and popup scripts.
33 | try { await browser.runtime.sendMessage(normalizedMessage); }
34 | catch (exception) { /* ignore any failures to receive */ }
35 |
36 | // Send the message to the current browser tab.
37 | const tabId = (await getCurrentTab())?.id;
38 | if (tabId != null) {
39 | try { await browser.tabs.sendMessage(tabId, normalizedMessage); }
40 | catch (exception) { /* ignore any failures to receive */ }
41 | }
42 | }
43 |
44 | function normalizeMessage(message) {
45 | return typeof message === 'string'
46 | ? { command: message }
47 | : message;
48 | }
--------------------------------------------------------------------------------
/content/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "manifest_version": 2,
3 | "name": "__MSG_extensionName__",
4 | "version": "1.8",
5 | "description": "__MSG_extensionDescription__",
6 | "developer": {
7 | "name": "Oren Trutner",
8 | "url": "https://github.com/orentrutner/reading-ruler"
9 | },
10 | "default_locale": "en",
11 |
12 | "permissions": [ "storage", "tabs" ],
13 |
14 | "icons": {
15 | "48": "icons/ruler-48.png",
16 | "96": "icons/ruler-96.png",
17 | "128": "icons/ruler-128.png"
18 | },
19 |
20 | "page_action": {
21 | "browser_style": true,
22 | "default_icon": {
23 | "48": "icons/ruler-48.png",
24 | "96": "icons/ruler-96.png",
25 | "128": "icons/ruler-128.png"
26 | },
27 | "default_popup": "popup/popup.html",
28 | "show_matches": ["http://*/*", "https://*/*"]
29 | },
30 |
31 | "commands": {
32 | "toggle-addon": {
33 | "suggested_key": {
34 | "default": "Alt+R"
35 | },
36 | "description": "Toggle Reading Ruler on or off"
37 | }
38 | },
39 |
40 | "background": {
41 | "scripts": [
42 | "src/polyfills/browser-polyfill.min.js",
43 | "src/common/colors.js",
44 | "src/common/commands.js",
45 | "src/common/extension.js",
46 | "src/common/options.js",
47 | "src/background/background.js"
48 | ]
49 | },
50 |
51 | "content_scripts": [{
52 | "matches": ["http://*/*", "https://*/*"],
53 | "css": ["css/main.css"],
54 | "js": [
55 | "src/polyfills/browser-polyfill.min.js",
56 | "src/common/colors.js",
57 | "src/common/commands.js",
58 | "src/common/extension.js",
59 | "src/common/options.js",
60 | "src/content/range.js",
61 | "src/content/rect.js",
62 | "src/content/polyfills.js",
63 | "src/content/dom.js",
64 | "src/content/caret.js",
65 | "src/content/highlight-visualizer.js",
66 | "src/content/iframe-visualizer.js",
67 | "src/content/negative-visualizer.js",
68 | "src/content/ruler.js",
69 | "src/content/main.js"
70 | ],
71 | "all_frames": true
72 | }]
73 | }
--------------------------------------------------------------------------------
/content/src/content/iframe-visualizer.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020-2022 Oren Trutner
3 | *
4 | * This file is part of Reading Ruler.
5 | *
6 | * Reading Ruler is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * Reading Ruler is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with Reading Ruler. If not, see .
18 | */
19 |
20 | /**
21 | * A ruler visualizer that proxies mouse movement from inside an iframe to the
22 | * ruler on the containing page. This visualizer is used inside iframes to
23 | * avoid multiple rulers in the same browser window. Multiple rulers are
24 | * particularly disruptive when the negative visualizer is used, as the darkened
25 | * areas around the ruler get darkened twice.
26 | */
27 | class IframeVisualizer {
28 | constructor() {
29 | this.hide();
30 | }
31 |
32 | /** Adds the visualizer's elements into the document. */
33 | addToDocument() { /* do nothing. */ }
34 |
35 | /** Removes the visualizer's elements from the document. */
36 | removeFromDocument() { /* do nothing. */ }
37 |
38 | /** Shows the ruler. */
39 | show() { this.sendMessage(WINDOW_COMMANDS.show); }
40 |
41 | /** Hides the ruler. */
42 | hide() { this.sendMessage(WINDOW_COMMANDS.hide); }
43 |
44 | /** Temporarily hides the ruler. */
45 | stash() { this.sendMessage(WINDOW_COMMANDS.stash); }
46 |
47 | /** Sets the ruler's color. */
48 | setColor(color) { /* do nothing. */ }
49 |
50 | /** Sets the ruler's opacity. */
51 | setOpacity(newOpacity) { /* do nothing. */ }
52 |
53 | /** Positions and sizes the ruler to cover a specific rectangle. */
54 | positionAt(rect) {
55 | this.sendMessage({
56 | guard: WINDOW_MESSAGE_GUARD,
57 | command: WINDOW_COMMANDS.positionAt,
58 | rect: rect
59 | });
60 | }
61 |
62 | /** Sends a message to the parent window. */
63 | sendMessage(message) {
64 | window.parent.postMessage(normalizeMessage(message), '*');
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/content/src/content/rect.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020-2022 Oren Trutner
3 | *
4 | * This file is part of Reading Ruler.
5 | *
6 | * Reading Ruler is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * Reading Ruler is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with Reading Ruler. If not, see .
18 | */
19 |
20 | /*
21 | * Rectangle functions. Should work on DOMRect values, e.g. as returned from
22 | * Element.getBoundingClientRect. Note that mutating functions might not work
23 | * on DOMRectReadOnly properties.
24 | */
25 |
26 | /** Checks if a rectangle has zero size. */
27 | function rectIsEmpty(rect) {
28 | return rect.width <= 0 || rect.height <= 0;
29 | }
30 |
31 | /** Checks if two rectangles are equal. */
32 | function rectsAreEqual(rect1, rect2) {
33 | return (rect1 === rect2
34 | || (rect1 && rect2
35 | && rect1.x === rect2.x
36 | && rect1.y === rect2.y
37 | && rect1.width === rect2.width
38 | && rect1.height === rect2.height));
39 | }
40 |
41 | /** Checks if a rectangle contains a point. */
42 | function rectContains(rect, x, y) {
43 | return x >= rect.x && x <= rect.x + rect.width && y >= rect.y && y <= rect.y + rect.height;
44 | }
45 |
46 | /** Translates the rect, in place, by a given offset. */
47 | function translateRect(rect, x, y) {
48 | rect.x += x;
49 | rect.y += y;
50 | }
51 |
52 | /** Gets a translated copy of the given rect. */
53 | function translatedRect(rect, x, y) {
54 | const translated = { ...rect };
55 | translateRect(translated, x, y);
56 | return translated;
57 | }
58 |
59 | /** Increases the size of a rectangle, in place, by a given amount. */
60 | function inflateRect(rect, x, y) {
61 | rect.x -= x;
62 | rect.y -= y;
63 | rect.width += 2 * x;
64 | rect.height += 2 * y;
65 | }
66 |
67 | /** Rounds the coordinates of a rectangle, in place. */
68 | function roundRect(rect) {
69 | rect.x = Math.round(rect.x);
70 | rect.y = Math.round(rect.y);
71 | rect.width = Math.round(rect.width);
72 | rect.height = Math.round(rect.height);
73 | }
--------------------------------------------------------------------------------
/content/popup/popup.html:
--------------------------------------------------------------------------------
1 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
Reading Ruler
34 |
35 |
36 |
You can also use the Alt+R hotkey to enable and disable Reading Ruler.
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
Color
46 |
47 |
48 |
Opacity
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/content/src/content/highlight-visualizer.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020-2022 Oren Trutner
3 | *
4 | * This file is part of Reading Ruler.
5 | *
6 | * Reading Ruler is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * Reading Ruler is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with Reading Ruler. If not, see .
18 | */
19 |
20 | /** A ruler visualizer that highlights text with color. */
21 | class HighlightVisualizer {
22 | static PREFIX = '--reading-ruler-';
23 | static RULER_ID = HighlightVisualizer.PREFIX + 'ruler';
24 |
25 | constructor() {
26 | this.opacity = 0.2;
27 | this.isVisible = true;
28 | }
29 |
30 | /** Adds the visualizer's elements into the document. */
31 | addToDocument() {
32 | this.element = document.getElementById(HighlightVisualizer.RULER_ID)
33 | if (!this.element) {
34 | this.element = document.createElement('div');
35 | this.element.id = HighlightVisualizer.RULER_ID;
36 | this.element.className = HighlightVisualizer.RULER_ID;
37 | document.body.appendChild(this.element);
38 | }
39 |
40 | this.hide();
41 | }
42 |
43 | /** Removes the visualizer's elements from the document. */
44 | removeFromDocument() {
45 | if (this.element) {
46 | this.element.remove();
47 | this.element = null;
48 | }
49 | }
50 |
51 | /** Shows the ruler. */
52 | show() {
53 | if (!this.isVisible) {
54 | this.element.style.opacity = this.opacity;
55 | this.isVisible = true;
56 | }
57 | }
58 |
59 | /** Hides the ruler. */
60 | hide() {
61 | if (this.isVisible) {
62 | this.element.style.opacity = 0;
63 | this.isVisible = false;
64 | }
65 | }
66 |
67 | /** Temporarily hides the ruler. */
68 | stash() {
69 | this.hide();
70 | }
71 |
72 | /** Sets the ruler's color. */
73 | setColor(color) {
74 | this.element.style.backgroundColor = color;
75 | }
76 |
77 | /** Sets the ruler's opacity. */
78 | setOpacity(newOpacity) {
79 | this.opacity = newOpacity;
80 | if (this.isVisible) {
81 | this.element.style.opacity = newOpacity;
82 | }
83 | }
84 |
85 | /** Positions and sizes the ruler to cover a specific rectangle. */
86 | positionAt(rect) {
87 | this.element.style.left = rect.x + 'px';
88 | this.element.style.top = rect.y + 'px';
89 | this.element.style.width = rect.width + 'px';
90 | this.element.style.height = rect.height + 'px';
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/content/src/popup/color-chooser.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020-2022 Oren Trutner
3 | *
4 | * This file is part of Reading Ruler.
5 | *
6 | * Reading Ruler is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * Reading Ruler is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with Reading Ruler. If not, see .
18 | */
19 |
20 | /** A UI component for choosing a color from a short list of named colors. */
21 | class ColorChooser {
22 | constructor(element) {
23 | this.element = element;
24 | this.inputs = [];
25 | this.chooseHandlers = [];
26 |
27 | // Create a radio button for each color.
28 | for (let color of COLORS) {
29 | // Create a radio button for the color.
30 | const input = document.createElement('input');
31 | input.type = 'radio';
32 | input.name = 'color';
33 | input.id = 'color' + color.name;
34 | input.value = color.name;
35 |
36 | this.inputs.push(input);
37 | this.element.appendChild(input);
38 |
39 | // Create a label for the radio button. The label renders the color
40 | // or icon if the color has an icon associated with it.
41 | const label = document.createElement('label');
42 | label.htmlFor = input.id;
43 | label.style = `background-color: ${color.hex};`;
44 | if (color.icon) {
45 | const image = document.createElement('img');
46 | image.src = color.icon;
47 | image.width = 30;
48 | image.height = 30;
49 | label.appendChild(image);
50 | } else {
51 | label.innerText = ' ';
52 | }
53 | label.addEventListener('click', this.onClick.bind(this));
54 | this.element.appendChild(label);
55 | }
56 | }
57 |
58 | set disabled(value) {
59 | for (const input of this.inputs) {
60 | input.disabled = value;
61 | }
62 | }
63 |
64 | /** Selects the specified color in the chooser's UI. */
65 | chooseColor(colorName) {
66 | for (const input of this.inputs) {
67 | input.checked = input.value === colorName;
68 | }
69 | }
70 |
71 | /** Registers for events. */
72 | addEventListener(eventName, handler) {
73 | switch (eventName) {
74 | case 'choose':
75 | this.chooseHandlers.push(handler);
76 | break;
77 | default: throw new Error("Unrecognized event name.");
78 | }
79 | }
80 |
81 | /** Reacts to clicks on color radio buttons. */
82 | async onClick(e) {
83 | for (const handler of this.chooseHandlers) {
84 | handler({ colorName: e.target.previousSibling.value });
85 | }
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/content/src/background/background.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020-2022 Oren Trutner
3 | *
4 | * This file is part of Reading Ruler.
5 | *
6 | * Reading Ruler is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * Reading Ruler is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with Reading Ruler. If not, see .
18 | */
19 |
20 | const DEFAULT_ICON = {
21 | "48": "/icons/ruler-48.png",
22 | "96": "/icons/ruler-96.png",
23 | "128": "/icons/ruler-128.png"
24 | };
25 | const DISABLED_ICON = {
26 | "48": "/icons/ruler-disabled-48.png",
27 | "96": "/icons/ruler-disabled-96.png",
28 | "128": "/icons/ruler-disabled-128.png"
29 | };
30 |
31 | /** Updates the add-on's icon to reflect its enabled state. */
32 | async function updateIcon(enable) {
33 | const tab = await getCurrentTab();
34 | const tabId = tab && tab.id;
35 | if (tabId != null) {
36 | await browser.pageAction.setIcon({
37 | path: enable ? DEFAULT_ICON : DISABLED_ICON,
38 | tabId: tabId
39 | });
40 | }
41 | }
42 |
43 | // Read and apply the page's options when it loads.
44 | browser.tabs.onUpdated.addListener(async (tabId, changeInfo, tab) => {
45 | if (tab.status === 'complete' && tab.active) {
46 | // Read the options.
47 | const options = new Options(tab.url);
48 | await options.read();
49 |
50 | // Update the add-on's icon to reflect its enabled state.
51 | await updateIcon(options.enabled);
52 | }
53 | });
54 |
55 | // Reapply the page's options when the user switches to a different tab.
56 | // This ensures the ruler is displayed with the current options even if the page
57 | // wasn't active when the popup changes the options.
58 | browser.tabs.onActivated.addListener(async activeInfo => {
59 | const tab = await getCurrentTab();
60 | const options = new Options(tab.url);
61 | await options.read();
62 | await options.broadcast();
63 | await updateIcon(options.enabled);
64 | });
65 |
66 | // Respond to hot-key commands, as specified in manifest.json.
67 | browser.commands.onCommand.addListener(async command => {
68 | switch (command) {
69 | // Toggle the add-on's on/off state
70 | case MANIFEST_EXTENSION_COMMANDS.toggleAddon:
71 | const tab = await getCurrentTab();
72 | const options = new Options(tab.url);
73 | await options.read();
74 | options.addonEnabled = !options.addonEnabled;
75 | await options.write();
76 | await updateIcon(options.enabled);
77 | break;
78 | default:
79 | break;
80 | }
81 | });
82 |
83 | // Respond to messages from the options popup.
84 | browser.runtime.onMessage.addListener(async (message, sender, sendResponse) => {
85 | switch(message.command) {
86 | case INTERNAL_EXTENSION_COMMANDS.options:
87 | await updateIcon(message.enabled);
88 | break;
89 | default:
90 | break;
91 | }
92 | });
--------------------------------------------------------------------------------
/content/src/common/options.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020-2022 Oren Trutner
3 | *
4 | * This file is part of Reading Ruler.
5 | *
6 | * Reading Ruler is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * Reading Ruler is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with Reading Ruler. If not, see .
18 | */
19 |
20 | /** Represents the user-selected options for a given page. */
21 | class Options {
22 | constructor(url) {
23 | this.url = url;
24 | this.host = new URL(url).host;
25 | }
26 |
27 | /** Should the add-on be enabled for the page? */
28 | get enabled() {
29 | return this.addonEnabled && this.domainEnabled && this.pageEnabled;
30 | }
31 |
32 | /** Gets the hex value of the ruler color. */
33 | get color() {
34 | return COLORS.find(color => color.name === this.colorName).hex;
35 | }
36 |
37 | /** Reads the options from local storage. */
38 | async read() {
39 | this.addonEnabled = !!await this.readValue('addonEnabled', true);
40 | this.domainEnabled = !!await this.readValue(this.host, true);
41 | this.pageEnabled = !!await this.readValue(this.url, true);
42 | this.appearance = await this.readValue('appearance', 'ruler');
43 | this.colorName = await this.readValue('colorName', COLORS[0].name);
44 | this.opacity = await this.readValue('opacity', 0.2);
45 | }
46 |
47 | /** Writes the options to local storage. */
48 | async write() {
49 | await this.writeValue('addonEnabled', this.addonEnabled);
50 | await this.writeValue(this.host, this.domainEnabled);
51 | await this.writeValue(this.url, this.pageEnabled);
52 | await this.writeValue('appearance', this.appearance);
53 | await this.writeValue('colorName', this.colorName);
54 | await this.writeValue('opacity', this.opacity);
55 |
56 | // Broadcast the option values throughout the add-on.
57 | await this.broadcast();
58 | }
59 |
60 | /** Broadcasts the option values throughout the add-on. */
61 | async broadcast() {
62 | await broadcast({
63 | command: INTERNAL_EXTENSION_COMMANDS.options,
64 | ...this.snap()
65 | });
66 | }
67 |
68 | /** Creates and returns a snapshot of the option value. */
69 | snap() {
70 | return {
71 | enabled: this.enabled,
72 | appearance: this.appearance,
73 | color: this.color,
74 | opacity: this.opacity
75 | };
76 | }
77 |
78 | /** Reads a single value from local storage. */
79 | async readValue(key, fallback) {
80 | const container = await browser.storage.local.get([ key ]);
81 | const value = container[key];
82 | return value !== undefined ? value : fallback;
83 | }
84 |
85 | /** Writes a single value to local storage. */
86 | async writeValue(key, value) {
87 | let container = {};
88 | container[key] = value;
89 | await browser.storage.local.set(container);
90 | }
91 | }
--------------------------------------------------------------------------------
/content/src/content/caret.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020-2022 Oren Trutner
3 | *
4 | * This file is part of Reading Ruler.
5 | *
6 | * Reading Ruler is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * Reading Ruler is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with Reading Ruler. If not, see .
18 | */
19 |
20 | /*
21 | * Caret functions. A caret represents a text position between two characters,
22 | * including the DOM node, the text offset and the bounding rectangle.
23 | */
24 |
25 | /**
26 | * Gets the caret for the nearest text position to the given coordinates.
27 | * Looks first in the DOM node under the coordinates, then horizontally around
28 | * it using up to the given number of sample points.
29 | */
30 | function caretAtOrNear(x, y, sampleCount) {
31 | return caretAt(x, y) || caretNear(x, y, sampleCount);
32 | }
33 |
34 | /**
35 | * Gets the caret for the nearest text position to the given coordinates.
36 | * Checks horizontally around the coordinates for the nearest match, using up to
37 | * the given number of sample points.
38 | */
39 | function caretNear(x, y, sampleCount) {
40 | const bodyWidth = document.body.clientWidth;
41 | var nearestCaret = null;
42 | var nearestCaretDistance = Number.MAX_VALUE;
43 |
44 | // Scan up to all sample points from left to right.
45 | for (var i = 0; i < sampleCount; ++i) {
46 | // Get the caret nearest the next sample point.
47 | const nextCaret = caretAt((i + 1) * bodyWidth / (sampleCount + 2), y);
48 |
49 | if (nextCaret) {
50 | // Check how close the caret is to the coordinates.
51 | const nextCaretDistance = rangeDistanceToValue(x, nextCaret.rect.x, nextCaret.rect.x + nextCaret.rect.width);
52 | if (nearestCaretDistance > nextCaretDistance) {
53 | // Getting closer to the coordinate? Great! -- keep track of
54 | // the closest caret so far.
55 | nearestCaret = nextCaret;
56 | nearestCaretDistance = nextCaretDistance;
57 | } else if (nearestCaret) {
58 | // No getting any closer? The remaining sample points won't get
59 | // us any closer either. Return the nearest caret so far.
60 | return nearestCaret;
61 | }
62 | }
63 | }
64 |
65 | // Looks like the last caret found was the closest.
66 | return nearestCaret;
67 | }
68 |
69 | /**
70 | * Gets the caret for the nearest text position to the given coordinates.
71 | * Looks only in the DOM node under the coordinates.
72 | */
73 | function caretAt(x, y) {
74 | // Get the nearest caret to the given coordinates.
75 | var caretInfo = caretFromPoint(x, y);
76 | if (!caretInfo) {
77 | return null;
78 | }
79 |
80 | // When in doubt, browsers assume you want the end of the previous row.
81 | // But we prefer to have the exact row under the coordinate.
82 | if (y > caretInfo.rect.bottom) {
83 | caretInfo = caretNext(caretInfo);
84 | }
85 |
86 | return (caretInfo && rangeContainsOrIsNear(y, caretInfo.rect.top, caretInfo.rect.bottom, 1)
87 | ? caretInfo
88 | : null);
89 | }
90 |
91 | /**
92 | * Gets the following caret position to the given caret.
93 | * Returns the original caret position if there isn't a following one.
94 | */
95 | function caretNext(caretInfo) {
96 | try {
97 | // Create a range for the following position. This can fail if there
98 | // is no following position.
99 | const nextCaretRange = document.createRange();
100 | nextCaretRange.setStart(caretInfo.node, caretInfo.offset + 1);
101 |
102 | // Return the caret at the location of the range.
103 | const nextCaretRect = nextCaretRange.getBoundingClientRect();
104 | return caretFromPoint(nextCaretRect.x, nextCaretRect.y);
105 | } catch (exception) {
106 | // Failed -- return the original caret.
107 | return caretInfo;
108 | }
109 | }
--------------------------------------------------------------------------------
/content/src/content/main.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020-2022 Oren Trutner
3 | *
4 | * This file is part of Reading Ruler.
5 | *
6 | * Reading Ruler is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * Reading Ruler is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with Reading Ruler. If not, see .
18 | */
19 |
20 | /**
21 | * This is the entry point for the add-on's "content" script, i.e. the script
22 | * that executes within every web page that the browser loads.
23 | *
24 | * It creates a single ruler and sets up event handlers to highlight the row
25 | * under the mouse cursor every time the mouse moves or the page scrolls.
26 | */
27 | (async function() {
28 | // Bail out if it looks like we're inside an advertising tracking iframe.
29 | const isInsideIframe = window.self !== window.top;
30 | if (isInsideIframe && window.innerWidth <= 100 || window.innerHeight <= 100) {
31 | return;
32 | }
33 |
34 | // Create the ruler.
35 | const ruler = new Ruler(isInsideIframe ? new IframeVisualizer() : null);
36 |
37 | // Track state.
38 | const mousePosition = { x: 0, y: 0 };
39 |
40 | // React to messages from the background and popup scripts.
41 | browser.runtime.onMessage.addListener(message => {
42 | switch (message.command) {
43 | case INTERNAL_EXTENSION_COMMANDS.activate:
44 | ruler.activate();
45 | break;
46 | case INTERNAL_EXTENSION_COMMANDS.deactivate:
47 | ruler.deactivate();
48 | break;
49 | case INTERNAL_EXTENSION_COMMANDS.options:
50 | ruler.applyOptions(message);
51 | break;
52 | default:
53 | break;
54 | }
55 | });
56 |
57 | // React to messages from iframes.
58 | window.addEventListener('message', e => {
59 | if (!e.data || e.data.guard !== WINDOW_MESSAGE_GUARD) {
60 | return;
61 | }
62 |
63 | switch (e.data && e.data.command) {
64 | case WINDOW_COMMANDS.show:
65 | ruler.show();
66 | break;
67 | case WINDOW_COMMANDS.hide:
68 | ruler.hide();
69 | break;
70 | case WINDOW_COMMANDS.stash:
71 | ruler.stash();
72 | break;
73 | case WINDOW_COMMANDS.positionAt:
74 | ruler.positionOnFrame(e.source, e.data.rect);
75 | break;
76 | default:
77 | break;
78 | }
79 | });
80 |
81 | /**
82 | * Activates the ruler. Use this inside requestAnimationFrame() to avoid
83 | * creating a new bound instance of ruler.activate upon each animation frame.
84 | */
85 | function activateRuler() {
86 | ruler.activate();
87 | }
88 |
89 | /**
90 | * Deactivates the ruler. Use this inside requestAnimationFrame() to avoid
91 | * creating a new bound instance of ruler.deactivate upon each animation frame.
92 | */
93 | function deactivateRuler() {
94 | ruler.deactivate();
95 | }
96 |
97 | /** Repositions the ruler when the mouse moves. */
98 | function positionRulerAroundMouseIfRowExited() {
99 | ruler.positionAroundIfRowExited(mousePosition.x, mousePosition.y);
100 | }
101 |
102 | document.addEventListener('mousemove', function(e) {
103 | // Keep track of the mouse position.
104 | mousePosition.x = e.x;
105 | mousePosition.y = e.y;
106 |
107 | // Position the ruler to match the mouse position.
108 | requestAnimationFrame(positionRulerAroundMouseIfRowExited);
109 | });
110 |
111 | // Reposition the ruler to match the mouse when the document is scrolled.
112 | function positionRulerAroundMouse() {
113 | ruler.positionAround(mousePosition.x, mousePosition.y);
114 | }
115 |
116 | document.addEventListener('scroll', function(e) {
117 | requestAnimationFrame(positionRulerAroundMouse);
118 | });
119 |
120 | // Deactivate the ruler when the mouse is outside the window.
121 | window.addEventListener('mouseout', e => {
122 | if (!e.relatedTarget) {
123 | requestAnimationFrame(deactivateRuler);
124 | }
125 | });
126 | window.addEventListener('mouseover', e => {
127 | if (!e.relatedTarget) {
128 | requestAnimationFrame(activateRuler);
129 | }
130 | });
131 | window.addEventListener('click', e => requestAnimationFrame(activateRuler));
132 |
133 | // Enable and style the ruler based on page options.
134 | const options = new Options(window.location.href);
135 | await options.read();
136 | ruler.applyOptions(options.snap());
137 | })();
--------------------------------------------------------------------------------
/content/src/content/negative-visualizer.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020-2022 Oren Trutner
3 | *
4 | * This file is part of Reading Ruler.
5 | *
6 | * Reading Ruler is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * Reading Ruler is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with Reading Ruler. If not, see .
18 | */
19 |
20 | /** A ruler visualizer that darkens the page except for the ruler row. */
21 | class NegativeVisualizer {
22 | static PREFIX = '--reading-ruler-';
23 | static TOP_ID = NegativeVisualizer.PREFIX + 'top';
24 | static MASK_ID = NegativeVisualizer.PREFIX + 'mask';
25 | static BOTTOM_ID = NegativeVisualizer.PREFIX + 'bottom';
26 |
27 | static Visibility = {
28 | SHOW: 1,
29 | HIDE: 2,
30 | STASH: 3,
31 |
32 | showOverlay(visibility) {
33 | return visibility === NegativeVisualizer.Visibility.SHOW || visibility == NegativeVisualizer.Visibility.STASH;
34 | },
35 |
36 | showMask(visibility) {
37 | return visibility === NegativeVisualizer.Visibility.STASH;
38 | }
39 | };
40 |
41 | constructor() {
42 | this.opacity = 0.2;
43 | this.visibility = NegativeVisualizer.Visibility.STASH;
44 | }
45 |
46 | /** Adds the visualizer's elements into the document. */
47 | addToDocument() {
48 | this.topElement = document.getElementById(NegativeVisualizer.TOP_ID)
49 | if (!this.topElement) {
50 | this.topElement = document.createElement('div');
51 | this.topElement.id = NegativeVisualizer.TOP_ID;
52 | this.topElement.className = NegativeVisualizer.TOP_ID;
53 | document.body.appendChild(this.topElement);
54 | }
55 |
56 | this.maskElement = document.getElementById(NegativeVisualizer.MASK_ID);
57 | if (!this.maskElement) {
58 | this.maskElement = document.createElement('div');
59 | this.maskElement.id = NegativeVisualizer.MASK_ID;
60 | this.maskElement.className = NegativeVisualizer.MASK_ID;
61 | document.body.append(this.maskElement);
62 | }
63 |
64 | this.bottomElement = document.getElementById(NegativeVisualizer.BOTTOM_ID)
65 | if (!this.bottomElement) {
66 | this.bottomElement = document.createElement('div');
67 | this.bottomElement.id = NegativeVisualizer.BOTTOM_ID;
68 | this.bottomElement.className = NegativeVisualizer.BOTTOM_ID;
69 | document.body.appendChild(this.bottomElement);
70 | }
71 |
72 | this.positionAt({ x: 0, y: 0, width: 0, height: 0 });
73 | this.hide();
74 | }
75 |
76 | /** Removes the visualizer's elements from the document. */
77 | removeFromDocument() {
78 | if (this.topElement) {
79 | this.topElement.remove();
80 | this.topElement = null;
81 | this.maskElement.remove();
82 | this.maskElement = null;
83 | this.bottomElement.remove();
84 | this.bottomElement = null;
85 |
86 | this.visibility = NegativeVisualizer.Visibility.HIDE;
87 | }
88 | }
89 |
90 | /** Shows the ruler. */
91 | show() {
92 | if (!NegativeVisualizer.Visibility.showOverlay(this.visibility)) {
93 | this.topElement.style.opacity = this.opacity;
94 | this.bottomElement.style.opacity = this.opacity;
95 | }
96 |
97 | if (NegativeVisualizer.Visibility.showMask(this.visibility)) {
98 | this.maskElement.style.opacity = 0;
99 | }
100 |
101 | this.visibility = NegativeVisualizer.Visibility.SHOW;
102 | }
103 |
104 | /** Hides the ruler. */
105 | hide() {
106 | if (NegativeVisualizer.Visibility.showOverlay(this.visibility)) {
107 | this.topElement.style.opacity = 0;
108 | this.bottomElement.style.opacity = 0;
109 | }
110 |
111 | if (NegativeVisualizer.Visibility.showMask(this.visibility)) {
112 | this.maskElement.style.opacity = 0;
113 | }
114 |
115 | this.visibility = NegativeVisualizer.Visibility.HIDE;
116 | }
117 |
118 | /** Temporarily hides the ruler. */
119 | stash() {
120 | if (!NegativeVisualizer.Visibility.showOverlay(this.visibility)) {
121 | this.topElement.style.opacity = this.opacity;
122 | this.bottomElement.style.opacity = this.opacity;
123 | }
124 |
125 | if (!NegativeVisualizer.Visibility.showMask(this.visibility)) {
126 | this.maskElement.style.opacity = this.opacity;
127 | }
128 |
129 | this.visibility = NegativeVisualizer.Visibility.STASH;
130 | }
131 |
132 | /** Sets the ruler's color. */
133 | setColor(color) {
134 | // Do nothing.
135 | }
136 |
137 | /** Sets the ruler's opacity. */
138 | setOpacity(newOpacity) {
139 | this.opacity = newOpacity;
140 |
141 | if (NegativeVisualizer.Visibility.showOverlay(this.visibility)) {
142 | this.topElement.style.opacity = newOpacity;
143 | this.bottomElement.style.opacity = newOpacity;
144 | }
145 |
146 | if (NegativeVisualizer.Visibility.showMask(this.visibility)) {
147 | this.maskElement.style.opacity = newOpacity;
148 | }
149 | }
150 |
151 | /** Positions and sizes the ruler to cover a specific rectangle. */
152 | positionAt(rect) {
153 | const widthPx = window.innerWidth + 'px';
154 |
155 | this.topElement.style.left = '0px';
156 | this.topElement.style.top = '0px';
157 | this.topElement.style.width = widthPx;
158 | this.topElement.style.height = rect.y + 'px';
159 |
160 | this.maskElement.style.left = '0px';
161 | this.maskElement.style.top = rect.y + 'px';
162 | this.maskElement.style.width = widthPx;
163 | this.maskElement.style.height = rect.height + 'px';
164 | this.maskElement.style.opacity = 0;
165 |
166 | this.bottomElement.style.left = '0px';
167 | this.bottomElement.style.top = (rect.y + rect.height) + 'px';
168 | this.bottomElement.style.width = widthPx;
169 | this.bottomElement.style.height = (window.innerHeight - rect.y - rect.height) + 'px';
170 |
171 | if (this.visibility === NegativeVisualizer.Visibility.STASH) {
172 | this.visibility = NegativeVisualizer.Visibility.SHOW;
173 | }
174 | }
175 | }
176 |
--------------------------------------------------------------------------------
/content/src/popup/popup.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020-2022 Oren Trutner
3 | *
4 | * This file is part of Reading Ruler.
5 | *
6 | * Reading Ruler is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * Reading Ruler is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with Reading Ruler. If not, see .
18 | */
19 |
20 | class Popup {
21 | constructor() {
22 | // Initialize and react to changes on the enable-add-on checkbox.
23 | this.enableAddonCheckbox = document.getElementById('addonEnabled');
24 | this.enableAddonCheckbox.addEventListener('change', this.onEnableAddonCheckboxChanged.bind(this));
25 |
26 | // Initialize and react to changes on the enable-for-domain checkbox.
27 | this.enableForDomainCheckbox = document.getElementById('enableForDomain');
28 | this.enableForDomainCheckbox.addEventListener('change', this.onEnableForDomainCheckboxChanged.bind(this));
29 |
30 | // Initialize and react to changes on the enable-for-page checkbox.
31 | this.enableForPageCheckbox = document.getElementById('enableForPage');
32 | this.enableForPageCheckbox.addEventListener('change', this.onEnableForPageCheckboxChanged.bind(this));
33 |
34 | // Initialize and react to changes on the color chooser.
35 | this.colorChooser = new ColorChooser(document.getElementById('colorButtons'));
36 | this.colorChooser.addEventListener('choose', this.onChooseColor.bind(this));
37 |
38 | // Initialize and react to changes on the opacity slider.
39 | this.opacitySlider = document.getElementById('opacitySlider');
40 | this.opacitySlider.addEventListener('input', this.onOpacitySliderMoved.bind(this));
41 | }
42 |
43 | applyOptions(options) {
44 | this.options = options;
45 |
46 | this.loadI18nStrings();
47 |
48 | this.enableAddonCheckbox.checked = options.addonEnabled;
49 | this.enableForDomainCheckbox.checked = options.domainEnabled;
50 | this.enableForPageCheckbox.checked = options.pageEnabled;
51 | this.colorChooser.chooseColor(options.colorName);
52 | this.opacitySlider.value = options.opacity;
53 |
54 | this.enableElements();
55 | }
56 |
57 | /** Loads user-visible text from the locale-specific messages.json. */
58 | loadI18nStrings() {
59 | document.getElementById('popupHeading').innerText = browser.i18n.getMessage('extensionName');
60 | document.getElementById('addonEnabledText').innerText = browser.i18n.getMessage('addonEnabledText');
61 | document.getElementById('hotkeyInfo').innerText = browser.i18n.getMessage('hotkeyInfo');
62 | document.getElementById('enableForPageText').innerText = browser.i18n.getMessage('showOnThisPage');
63 | document.getElementById('enableForDomainText').innerText = browser.i18n.getMessage('showOnAllPagesOf', this.options.host);
64 | document.getElementById('colorHeading').innerText = browser.i18n.getMessage('colorHeading');
65 | document.getElementById('opacityHeading').innerText = browser.i18n.getMessage('opacityHeading');
66 | }
67 |
68 | /** Enables form controls based on the state of the enable-addon checkbox. */
69 | enableElements() {
70 | document.getElementById('form').classList.toggle('disabled', !this.options.addonEnabled);
71 | this.enableForDomainCheckbox.disabled = !this.options.addonEnabled;
72 | this.enableForPageCheckbox.disabled = !this.options.addonEnabled;
73 | this.colorChooser.disabled = !this.options.addonEnabled;
74 | this.opacitySlider.disabled = !this.options.addonEnabled;
75 | }
76 |
77 | /** Reacts to changed of the enable-addon checkbox. */
78 | async onEnableAddonCheckboxChanged(e) {
79 | this.options.addonEnabled = e.target.checked;
80 | await this.options.write();
81 | this.enableElements();
82 | }
83 |
84 | /** Reacts to changes of the enable-for-domain checkbox. */
85 | async onEnableForDomainCheckboxChanged(e) {
86 | this.options.domainEnabled = e.target.checked;
87 | await this.options.write();
88 | }
89 |
90 | /** Reacts to changes of the enable-for-page checkbox. */
91 | async onEnableForPageCheckboxChanged(e) {
92 | this.options.pageEnabled = e.target.checked;
93 | await this.options.write();
94 | }
95 |
96 | /** Called when the user chooses a color. */
97 | async onChooseColor(e) {
98 | if (this.options.addonEnabled) {
99 | const color = COLORS.find(nextColor => nextColor.name === e.colorName);
100 | if (color) {
101 | this.options.colorName = e.colorName;
102 | this.options.appearance = color.appearance;
103 | await this.options.write();
104 | }
105 | }
106 | }
107 |
108 | /** Reacts to changes of the opacity slider. */
109 | async onOpacitySliderMoved(e) {
110 | this.options.opacity = this.opacitySlider.value;
111 | await this.options.write();
112 | }
113 | }
114 |
115 | /**
116 | * This is the entry point for the add-on's "popup" script. This script
117 | * executes in the tiny web "page" showing the add-on's dropdown menu when
118 | * you click the add-on's icon.
119 | */
120 | document.addEventListener('DOMContentLoaded', async () => {
121 | // Activate the ruler when the popup is shown.
122 | broadcast(INTERNAL_EXTENSION_COMMANDS.activate);
123 |
124 | // Read the add-on's options.
125 | const tab = await getCurrentTab();
126 | const options = new Options(tab.url);
127 | await options.read();
128 | await options.broadcast();
129 |
130 | const popup = new Popup();
131 | popup.applyOptions(options);
132 |
133 | // Update the state of the popup controls when an options update is received
134 | // from the background script. This can happen when the background script
135 | // receives a hotkey command.
136 | browser.runtime.onMessage.addListener(async message => {
137 | switch (message.command) {
138 | case INTERNAL_EXTENSION_COMMANDS.options:
139 | const options = new Options(tab.url);
140 | await options.read();
141 | popup.applyOptions(options);
142 | break;
143 | default:
144 | break;
145 | }
146 | });
147 |
148 | // Activate the ruler when entering the popup. This gives direct feedback
149 | // to what option changes look like, and counters the deactivation of the
150 | // ruler when the mouse exits the window to open the popup.
151 | document.documentElement.addEventListener('mouseenter', e => broadcast(INTERNAL_EXTENSION_COMMANDS.activate));
152 | document.documentElement.addEventListener('mouseleave', e => broadcast(INTERNAL_EXTENSION_COMMANDS.deactivate));
153 |
154 | // Deactivate the ruler when the popup closes.
155 | window.addEventListener('blur', e => {
156 | if (e.target === window) {
157 | broadcast(INTERNAL_EXTENSION_COMMANDS.deactivate);
158 | }
159 | });
160 | }, false);
161 |
--------------------------------------------------------------------------------
/content/css/popup.css:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020-2022 Oren Trutner
3 | *
4 | * This file is part of Reading Ruler.
5 | *
6 | * Reading Ruler is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * Reading Ruler is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with Reading Ruler. If not, see .
18 | */
19 |
20 | /* Light color scheme */
21 | @media (prefers-color-scheme: light) {
22 | /* Body and heading colors, regular and disabled. */
23 | body {
24 | background: #f9f9fb;
25 | color: #445;
26 | }
27 |
28 | h1, h2, h3, h4 {
29 | color: black;
30 | }
31 |
32 | div.disabled h1, div.disabled h2, div.disabled h3, div.disabled h4 {
33 | color: #666;
34 | }
35 |
36 | /* Switch-shaped checkbox colors */
37 | div.switch input[type="checkbox"]:not(:checked) + span::before {
38 | background-color: #aaa;
39 | }
40 |
41 | div.switch label:hover input[type="checkbox"]:checked + span::before {
42 | background-color: #7b4;
43 | }
44 |
45 | div.switch label:hover input[type="checkbox"]:not(:checked) + span::before {
46 | background-color: #9a8;
47 | }
48 |
49 | div.switch label:hover span {
50 | color: black;
51 | text-shadow: 0px 0px 2px rgba(0, 0, 0, 0.5);
52 | }
53 |
54 | /* Color chooser radio button colors */
55 | .color-radio input[type="radio"]:not([disabled]):not(:checked):hover + label,
56 | .color-radio input[type="radio"]:checked + label {
57 | border-color: black;
58 | }
59 |
60 | /* Regular checkbox colors */
61 | div.checkbox input[type="checkbox"]:not([disabled]) + span:hover {
62 | color: black;
63 | text-shadow: 0px 0px 2px rgba(0, 0, 0, 0.5);
64 | }
65 |
66 | div.disabled div.checkbox span {
67 | color: #aaa;
68 | }
69 | }
70 |
71 | /* Dark color scheme */
72 | @media (prefers-color-scheme: dark) {
73 | /* Body and heading colors, regular and disabled. */
74 | body {
75 | background: #333;
76 | color: #ddd;
77 | }
78 |
79 | h1, h2, h3, h4 {
80 | color: white;
81 | }
82 |
83 | div.disabled h1, div.disabled h2, div.disabled h3, div.disabled h4 {
84 | color: #888;
85 | }
86 |
87 | /* Switch-shaped checkbox colors */
88 | div.switch input[type="checkbox"]:not(:checked) + span::before {
89 | background-color: #666;
90 | }
91 |
92 | div.switch label:hover input[type="checkbox"]:checked + span::before {
93 | background-color: #7b4;
94 | }
95 |
96 | div.switch label:hover input[type="checkbox"]:not(:checked) + span::before {
97 | background-color: #786;
98 | }
99 |
100 | div.switch label:hover span {
101 | color: white;
102 | text-shadow: 0px 0px 2px rgba(255, 255, 255, 0.7);
103 | }
104 |
105 | /* Color chooser radio button colors */
106 | .color-radio input[type="radio"]:not([disabled]):not(:checked):hover + label,
107 | .color-radio input[type="radio"]:checked + label {
108 | border-color: white;
109 | }
110 |
111 | /* Regular checkbox colors */
112 | div.checkbox input[type="checkbox"]:not([disabled]) + span:hover {
113 | color: white;
114 | text-shadow: 0px 0px 2px rgba(255, 255, 255, 0.7);
115 | }
116 |
117 | div.disabled div.checkbox span {
118 | color: #666;
119 | }
120 | }
121 |
122 | body {
123 | font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
124 | font-size: 13px;
125 | font-weight: 400;
126 | margin: 24px;
127 | user-select: none;
128 | }
129 |
130 | h1, h2, h3, h4 {
131 | transition: color 200ms;
132 | }
133 |
134 | h1 {
135 | font-size: 36px;
136 | font-weight: 200;
137 | }
138 |
139 | h2 {
140 | font-size: 22px;
141 | font-weight: 300;
142 | }
143 |
144 | h3 {
145 | font-size: 17px;
146 | font-weight: 600;
147 | }
148 |
149 | h4 {
150 | font-size: 14px;
151 | font-weight: 600;
152 | margin: 24px 0 6px 0;
153 | }
154 |
155 | div.preamble {
156 | width: min-content;
157 | }
158 |
159 | p.info {
160 | margin: 3pt 0 12pt 12pt;
161 | font-style: italic;
162 | word-wrap: break-word;
163 | opacity: 0.8;
164 | }
165 |
166 | div.indent {
167 | margin-left: 12px;
168 | }
169 |
170 | /* Switch-shaped checkbox */
171 |
172 | div.switch {
173 | margin-bottom: 18px;
174 | white-space: nowrap;
175 | }
176 |
177 | div.switch label {
178 | position: relative;
179 | }
180 |
181 | div.switch input[type="checkbox"] {
182 | position: absolute;
183 | left: -5000px;
184 | }
185 |
186 | /* Switch-shaped checkbox: background and text */
187 | div.switch input[type="checkbox"] + span::before {
188 | content: 'OFF';
189 | position: absolute;
190 | left: 0px;
191 | top: -8px;
192 | width: 45px;
193 | height: 18px;
194 | padding: 8px 18px;
195 | border-radius: 40px;
196 |
197 | background-color: #bbb;
198 | box-shadow: inset 1px 1px 3px rgba(0, 0, 0, 0.2);
199 | color: white;
200 | font-weight: bold;
201 | text-indent: 24px;
202 |
203 | transition: 200ms;
204 | }
205 |
206 | div.switch input[type="checkbox"]:checked + span::before {
207 | content: 'ON';
208 | text-indent: 0px;
209 | background-color: #6aa630;
210 | }
211 |
212 | div.switch label:hover input[type="checkbox"] + span::before {
213 | box-shadow: inset 1px 1px 4px rgba(0, 0, 0, 0.5);
214 | }
215 |
216 | /* Switch-shaped checkbox: bubble */
217 | div.switch input[type="checkbox"] + span::after {
218 | content: '';
219 | position: absolute;
220 | left: 6px;
221 | top: -3px;
222 | width: 24px;
223 | height: 24px;
224 | border-radius: 30px;
225 |
226 | background: white;
227 | box-shadow: 1px 1px 3px rgba(0, 0, 0, 0.2);
228 |
229 | transition: 200ms;
230 | }
231 |
232 | div.switch input[type="checkbox"]:checked + span::after {
233 | transform: translate(45px);
234 | }
235 |
236 | div.switch label:hover input[type="checkbox"] + span::after {
237 | box-shadow: 1px 1px 4px rgba(0, 0, 0, 0.5);
238 | }
239 |
240 | div.switch label:hover input[type="checkbox"]:checked + span::after {
241 | transform: translate(43px);
242 | }
243 |
244 | div.switch label:hover input[type="checkbox"]:not(:checked) + span::after {
245 | transform: translate(2px);
246 | }
247 |
248 | /* Switch-shaped checkbox: label to the right */
249 | div.switch label span {
250 | display: inline-block;
251 | margin-left: 88px;
252 | }
253 |
254 | /* Color radio buttons */
255 | .color-radio {
256 | margin: 0;
257 | }
258 |
259 | .color-radio input[type="radio"] {
260 | display: none;
261 | }
262 |
263 | .color-radio label {
264 | display: inline-block;
265 | min-width: 30px;
266 | min-height: 30px;
267 | margin: 0 8px 0 0;
268 | font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
269 | background-color: white;
270 | border: none;
271 |
272 | transition: filter 200ms;
273 | }
274 |
275 | .color-radio label::after {
276 | content: "";
277 | position: absolute;
278 | width: 30px;
279 | height: 30px;
280 | background-color: white;
281 | opacity: 0.5;
282 | }
283 |
284 | .color-radio label img {
285 | position: absolute;
286 | }
287 |
288 | .color-radio input[type="radio"]:not([disabled]):not(:checked):hover + label {
289 | width: 32px;
290 | height: 32px;
291 | margin: 0 6px 0 0;
292 | transform: translate(-1px, 1px);
293 | border-style: solid;
294 | border-width: 1px;
295 | }
296 |
297 | .color-radio input[type="radio"]:checked + label {
298 | width: 36px;
299 | height: 36px;
300 | margin: 0 2px 0 0;
301 | transform: translate(-3px, 3px);
302 | border-style: solid;
303 | border-width: 3px;
304 | }
305 |
306 | div.disabled .color-radio label {
307 | filter: grayscale(1) opacity(0.5);
308 | }
309 |
310 | /* Regular checkboxes */
311 | div.checkbox span {
312 | transition: color 200ms;
313 | }
314 |
315 | /* The opacity slider */
316 | #opacitySlider {
317 | width: 220px;
318 | }
--------------------------------------------------------------------------------
/content/src/content/ruler.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020-2022 Oren Trutner
3 | *
4 | * This file is part of Reading Ruler.
5 | *
6 | * Reading Ruler is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * Reading Ruler is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with Reading Ruler. If not, see .
18 | */
19 |
20 | /**
21 | * Represents a "ruler" that highlights a row of text.
22 | * A ruler uses a visualizer object to do the actual highlighting.
23 | */
24 | class Ruler {
25 | constructor(visualizer = null) {
26 | this.enabled = false; // enabled unless the user turned it off
27 | this.appearance = 'ruler';
28 | this.forcedVisualizer = visualizer;
29 | this.visualizer = visualizer || new HighlightVisualizer();
30 | this.latestRowBounds = null;
31 | this.latestPosition = null;
32 | this.options = {};
33 |
34 | this.visualizer.addToDocument();
35 | }
36 |
37 | // Public methods
38 |
39 | /** Applies a snapshot of an Options object. */
40 | applyOptions(optionsSnapshot) {
41 | this.enableIf(optionsSnapshot.enabled);
42 | this.setAppearance(optionsSnapshot.appearance);
43 | this.setColor(optionsSnapshot.color);
44 | this.setOpacity(optionsSnapshot.opacity);
45 | }
46 |
47 | /** Enables or disables the ruler, based on the given input. */
48 | enableIf(enable) {
49 | if (enable) {
50 | this.enable();
51 | } else {
52 | this.disable();
53 | }
54 | }
55 |
56 | /** Enables the ruler. It will stay enabled until explicitly disabled. */
57 | enable() {
58 | this.enabled = true;
59 | this.show();
60 | }
61 |
62 | /** Disables the ruler. It will stay disabled until explicitly enabled. */
63 | disable() {
64 | this.enabled = false;
65 | this.hide();
66 | }
67 |
68 | /** Activates the ruler, if it was temporarily deactivated. */
69 | activate() {
70 | this.show();
71 | }
72 |
73 | /** Temporarily deactivates the ruler. */
74 | deactivate() {
75 | this.hide();
76 | }
77 |
78 | /** Sets the ruler's appearance. */
79 | setAppearance(newAppearance) {
80 | if (this.appearance === newAppearance) {
81 | return;
82 | }
83 |
84 | // Keep the new appearance.
85 | this.appearance = newAppearance;
86 |
87 | // Replace the visualizer, if the new appearance requires it.
88 | const newVisualizer = this.forcedVisualizer || Ruler.VISUALIZER_BY_APPEARANCE[newAppearance] || Ruler.VISUALIZER_BY_APPEARANCE["ruler"];
89 | if (this.visualizer !== newVisualizer) {
90 | // Remove the old visualizer.
91 | this.visualizer.hide();
92 | this.visualizer.removeFromDocument();
93 |
94 | // Bring in the new visualizer.
95 | this.visualizer = newVisualizer;
96 | this.visualizer.addToDocument();
97 | }
98 |
99 | // Show and position the new visualizer.
100 | this.show();
101 | this.positionAtLatest();
102 |
103 | this.visualizer.setColor(this.options.color);
104 | this.visualizer.setOpacity(this.options.opacity);
105 | }
106 |
107 | /** Sets the ruler's color. */
108 | setColor(newColor) {
109 | this.options.color = newColor;
110 | this.visualizer.setColor(newColor);
111 | }
112 |
113 | /** Sets the ruler's opacity. */
114 | setOpacity(newOpacity) {
115 | this.options.opacity = newOpacity;
116 | this.visualizer.setOpacity(newOpacity);
117 | }
118 |
119 | /**
120 | * Positions and shows the ruler on the text row around a mouse coordinate.
121 | * As a performance optimization, only makes a change if the coordinate
122 | * exited the previously highlighted row.
123 | */
124 | positionAroundIfRowExited(x, y) {
125 | if (!this.enabled || (this.latestRowBounds && rectContains(this.latestRowBounds, x, y))) {
126 | return;
127 | }
128 |
129 | this.positionAround(x, y)
130 | }
131 |
132 | /**
133 | * Positions and shows the ruler on the text row around a mouse coordinate.
134 | */
135 | positionAround(x, y) {
136 | // Do nothing if disabled.
137 | if (!this.enabled) {
138 | return;
139 | }
140 |
141 | // Find the row bounds.
142 | const rowBounds = this.latestRowBounds = this.boundsAroundPoint(x, y);
143 | if (!rowBounds) {
144 | this.stash();
145 | return;
146 | }
147 | roundRect(rowBounds);
148 |
149 | // Make sure the ruler is visible.
150 | this.activate();
151 |
152 | // Position the ruler.
153 | inflateRect(rowBounds, Ruler.PADDING.x, Ruler.PADDING.y);
154 | this.positionAt(rowBounds);
155 | }
156 |
157 | /**
158 | * Positions and shows the ruler over a rectangle relative to a given
159 | * iframe.
160 | */
161 | positionOnFrame(frameWindow, rect) {
162 | const frame = frameFromWindow(frameWindow);
163 | const frameRect = frame.getBoundingClientRect();
164 | const frameStyle = window.getComputedStyle(frame);
165 | const rulerRect = translatedRect(
166 | rect,
167 | frameRect.left + parseInt(frameStyle.paddingLeft) + parseInt(frameStyle.borderLeftWidth),
168 | frameRect.top + parseInt(frameStyle.paddingTop) + parseInt(frameStyle.borderTopWidth));
169 | roundRect(rulerRect);
170 | this.activate();
171 | this.positionAt(rulerRect);
172 | }
173 |
174 | // Private methods
175 |
176 | /** Shows the ruler. */
177 | show() {
178 | if (this.enabled) {
179 | this.visualizer.show();
180 | }
181 | }
182 |
183 | /** Hides the ruler. */
184 | hide() {
185 | this.visualizer.hide();
186 | }
187 |
188 | /** Temporarily hides the ruler. */
189 | stash() {
190 | this.visualizer.stash();
191 | this.latestPosition = null;
192 | }
193 |
194 | /**
195 | * Positions the visualizer in the latest position it was in.
196 | * This is useful after changing visualizers.
197 | */
198 | positionAtLatest() {
199 | if (this.latestPosition) {
200 | this.visualizer.positionAt(this.latestPosition);
201 | }
202 | }
203 |
204 | /** Positions and sizes the ruler to cover a specific rectangle. */
205 | positionAt(rect) {
206 | if (!rectsAreEqual(rect, this.latestPosition)) {
207 | this.visualizer.positionAt(rect);
208 | this.latestPosition = rect;
209 | }
210 | }
211 |
212 | /**
213 | * Gets the bounds of the DOM element to highlight at a given mouse
214 | * coordinate. Returns null if the element at that location shouldn't be
215 | * highlighted.
216 | */
217 | boundsAroundPoint(x, y) {
218 | // Find the DOM element at the given coordinate.
219 | const caretInfo = caretAtOrNear(x, y, Ruler.SAMPLE_COUNT);
220 | if (!caretInfo || !caretInfo.node) {
221 | return null;
222 | }
223 |
224 | // Get the shape of the DOM element.
225 | const element = this.ancestorBlockElement(caretInfo.node.parentElement, 3);
226 | const elementRect = element.getBoundingClientRect();
227 |
228 | // Position and size the ruler to highlight the DOM element.
229 | switch (caretInfo.node.nodeType) {
230 | case 1: // A non-text highlight-worthy element
231 | // Highlight the entire element.
232 | const element = caretInfo.node;
233 | if (Ruler.ELEMENTS_TO_HIGHLIGHT.has(element.nodeName.toLowerCase())) {
234 | return elementRect;
235 | } else {
236 | return null;
237 | }
238 | case 3: // text
239 | // Highlight just the row under the mouse, not the entire
240 | // paragraph.
241 | return {
242 | x: elementRect.x,
243 | y: caretInfo.rect.y,
244 | width: elementRect.width,
245 | height: caretInfo.rect.height
246 | };
247 | default: return null;
248 | }
249 | }
250 |
251 | /**
252 | * Gets the nearest ancestor block element of a given element.
253 | * Scans up to the given number of levels.
254 | * Returns null if the root of the DOM tree is reached, or the last ancestor
255 | * looked at if no block ancestor is found within the limit.
256 | */
257 | ancestorBlockElement(element, levels) {
258 | for (var level = 0;
259 | level < levels && element;
260 | ++level, element = element.parentElement) {
261 |
262 | if (window.getComputedStyle(element).display === 'block') {
263 | return element;
264 | }
265 | }
266 |
267 | return element;
268 | }
269 | }
270 |
271 | Ruler.SAMPLE_COUNT = 5;
272 | Ruler.ELEMENTS_TO_HIGHLIGHT = new Set(['hg', 'img', 'svg', 'video']);
273 | Ruler.PADDING = { x: 4, y: 2 };
274 | Ruler.VISUALIZER_BY_APPEARANCE = {
275 | "ruler": new HighlightVisualizer(),
276 | "negative": new NegativeVisualizer()
277 | };
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
--------------------------------------------------------------------------------
/content/src/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
--------------------------------------------------------------------------------