Commit Graph

61 Commits

Author SHA1 Message Date
toasted-nutbread
782b945905
Header lint (#1444)
* Add eslint-plugin-header

* Add rule for header format

* Add missing header

* Fix header issues
2021-02-25 20:21:05 -05:00
toasted-nutbread
ae92e0b378
AnkiUtil (#1439)
* Add AnkiUtil

* Update AnkiConnect to use AnkiUtil

* Use AnkiUtil in AnkiNoteBuilder

* Replace containsAnyMarker with AnkiUtil.stringContainsAnyFieldMarker

* Add AnkiUtil.getFieldMarkers

* Add fieldsObjectContainsMarker to AnkiUtil

* Remove unused global

* Remove unused parameter: enabled

* Add cloneFieldMarkerPattern
2021-02-24 21:54:58 -05:00
toasted-nutbread
723a5a5a35
Update eslint rules (#1401) 2021-02-15 12:38:45 -05:00
toasted-nutbread
450912c109
Move js/settings (#1397)
* Move js/settings to js/pages/settings

* Fix script ordering
2021-02-14 23:10:01 -05:00
toasted-nutbread
d6332d2bc7
Test html script ordering (#1396)
* Simplify getAllFiles

* Add test to validate script order

* Update script include order

* Update content script order

* Update sw.js and corresponding lint

* Update manifest
2021-02-14 20:25:41 -05:00
toasted-nutbread
d97c84f8ac
Update lint definitions for sandboxed files (#1395) 2021-02-14 18:20:35 -05:00
toasted-nutbread
48b59375eb
Cleanup yomichan api (#1394)
* Move invokeMessageHandler to core.js

* Move getMessageResponseResult to backghend.js

* Replace getTemporaryListenerResult
2021-02-14 18:18:02 -05:00
toasted-nutbread
9279ced686
Log refactoring (#1393)
* Create Logger class and log instance

* Replace yomichan.logWarning with log.warn

* Replace yomichan.logError with log.error

* Replace yomichan.log with log.log

* Update the Yomichan class to use the global log object

* Update lint rules
2021-02-14 17:52:01 -05:00
toasted-nutbread
5268c5d1bc
Util rename (#1389)
* Rename MediaUtility to MediaUtil for consistency

* Update variable names

* Rename media-utility.js to media-util.js

* Rename ProfileConditions to ProfileConditionsUtil

* Rename variables

* Move profile-conditions.js to profile-conditions-util.js

* Rename test-profile-conditions.js to test-profile-conditions-util.js
2021-02-14 11:32:30 -05:00
toasted-nutbread
0117df6bd8
Update lint and tests (#1388)
* Update paths to no longer use bg/, fg/, or mixed/

* Only allow modal-jquery.js to use jQuery
2021-02-14 11:24:43 -05:00
toasted-nutbread
e419a418f6
Move bg/js (#1387)
* Move bg/js/anki.js to js/comm/anki.js

* Move bg/js/mecab.js to js/comm/mecab.js

* Move bg/js/search-main.js to js/display/search-main.js

* Move bg/js/template-patcher.js to js/templates/template-patcher.js

* Move bg/js/template-renderer-frame-api.js to js/templates/template-renderer-frame-api.js

* Move bg/js/template-renderer-frame-main.js to js/templates/template-renderer-frame-main.js

* Move bg/js/template-renderer-proxy.js to js/templates/template-renderer-proxy.js

* Move bg/js/template-renderer.js to js/templates/template-renderer.js

* Move bg/js/media-utility.js to js/media/media-utility.js

* Move bg/js/native-simple-dom-parser.js to js/dom/native-simple-dom-parser.js

* Move bg/js/simple-dom-parser.js to js/dom/simple-dom-parser.js

* Move bg/js/audio-downloader.js to js/media/audio-downloader.js

* Move bg/js/deinflector.js to js/language/deinflector.js

* Move bg/js/backend.js to js/background/backend.js

* Move bg/js/translator.js to js/language/translator.js

* Move bg/js/search-display-controller.js to js/display/search-display-controller.js

* Move bg/js/request-builder.js to js/background/request-builder.js

* Move bg/js/text-source-map.js to js/general/text-source-map.js

* Move bg/js/clipboard-reader.js to js/comm/clipboard-reader.js

* Move bg/js/clipboard-monitor.js to js/comm/clipboard-monitor.js

* Move bg/js/query-parser.js to js/display/query-parser.js

* Move bg/js/profile-conditions.js to js/background/profile-conditions.js

* Move bg/js/dictionary-database.js to js/language/dictionary-database.js

* Move bg/js/dictionary-importer.js to js/language/dictionary-importer.js

* Move bg/js/anki-note-builder.js to js/data/anki-note-builder.js

* Move bg/js/anki-note-data.js to js/data/anki-note-data.js

* Move bg/js/database.js to js/data/database.js

* Move bg/js/json-schema.js to js/data/json-schema.js

* Move bg/js/options.js to js/data/options-util.js

* Move bg/js/background-main.js to js/background/background-main.js

* Move bg/js/permissions-util.js to js/data/permissions-util.js

* Move bg/js/context-main.js to js/pages/action-popup-main.js

* Move bg/js/generic-page-main.js to js/pages/generic-page-main.js

* Move bg/js/info-main.js to js/pages/info-main.js

* Move bg/js/permissions-main.js to js/pages/permissions-main.js

* Move bg/js/welcome-main.js to js/pages/welcome-main.js
2021-02-14 11:19:54 -05:00
toasted-nutbread
43d1457ebf
Move bg/js/settings(2) (#1385)
* Move bg/js/settings/ to js/settings/

* Move bg/js/settings2/ to js/settings/
2021-02-13 23:20:22 -05:00
toasted-nutbread
6a271e067f
Move mixed/js (#1383)
* Move mixed/js/core.js to js/core.js

* Move mixed/js/yomichan.js to js/yomichan.js

* Move mixed/js/timer.js to js/debug/timer.js

* Move mixed/js/hotkey-handler.js to js/input/hotkey-handler.js

* Move mixed/js/hotkey-help-controller.js to js/input/hotkey-help-controller.js

* Move mixed/js/hotkey-util.js to js/input/hotkey-util.js

* Move mixed/js/audio-system.js to js/input/audio-system.js

* Move mixed/js/media-loader.js to js/input/media-loader.js

* Move mixed/js/text-to-speech-audio.js to js/input/text-to-speech-audio.js

* Move mixed/js/comm.js to js/comm/cross-frame-api.js

* Move mixed/js/api.js to js/comm/api.js

* Move mixed/js/frame-client.js to js/comm/frame-client.js

* Move mixed/js/frame-endpoint.js to js/comm/frame-endpoint.js

* Move mixed/js/display.js to js/display/display.js

* Move mixed/js/display-audio.js to js/display/display-audio.js

* Move mixed/js/display-generator.js to js/display/display-generator.js

* Move mixed/js/display-history.js to js/display/display-history.js

* Move mixed/js/display-notification.js to js/display/display-notification.js

* Move mixed/js/display-profile-selection.js to js/display/display-profile-selection.js

* Move mixed/js/japanese.js to js/language/japanese-util.js

* Move mixed/js/dictionary-data-util.js to js/language/dictionary-data-util.js

* Move mixed/js/document-focus-controller.js to js/dom/document-focus-controller.js

* Move mixed/js/document-util.js to js/dom/document-util.js

* Move mixed/js/dom-data-binder.js to js/dom/dom-data-binder.js

* Move mixed/js/html-template-collection.js to js/dom/html-template-collection.js

* Move mixed/js/panel-element.js to js/dom/panel-element.js

* Move mixed/js/popup-menu.js to js/dom/popup-menu.js

* Move mixed/js/selector-observer.js to js/dom/selector-observer.js

* Move mixed/js/scroll.js to js/dom/window-scroll.js

* Move mixed/js/text-scanner.js to js/language/text-scanner.js

* Move mixed/js/cache-map.js to js/general/cache-map.js

* Move mixed/js/object-property-accessor.js to js/general/object-property-accessor.js

* Move mixed/js/task-accumulator.js to js/general/task-accumulator.js

* Move mixed/js/environment.js to js/background/environment.js

* Move mixed/js/dynamic-loader.js to js/scripting/dynamic-loader.js

* Move mixed/js/dynamic-loader-sentinel.js to js/scripting/dynamic-loader-sentinel.js
2021-02-13 22:52:28 -05:00
toasted-nutbread
deed5027cd
Move mixed/lib/ to lib/ (#1382) 2021-02-13 21:28:47 -05:00
toasted-nutbread
94db6c69fa
Permissions button in browser action popup (#1368)
* Add key icon

* Update context icon styles

* Add permissions links

* Show warning badge if permissions are insufficient for certain settings

* Create PermissionsUtil

* Use PermissionsUtil in Backend

* Update SettingsController to use PermissionsUtil

* Update AnkiController to use getRequiredPermissionsForAnkiFieldValue

* Show the permissions buttons/links on the context page when necessary

* Update MV3 compatibility
2021-02-11 18:55:09 -05:00
toasted-nutbread
e610a62ceb
Refactor anki field templates (#1323)
* Update glossary and glossary-single

* Define patch

* Create TemplatePatcher

* Add test
2021-01-28 21:17:10 -05:00
toasted-nutbread
8ec48456e6
Disable undefined usage (#1262) 2021-01-17 12:20:06 -05:00
toasted-nutbread
5ae3acf6ff
Anki note data abstraction (#1228)
* Create AnkiNoteData

* Create AnkiNoteDataDefinitionProxyHandler

* Update media injection

* Create AnkiNoteDataDefinitionSecondaryProperties

* Update note context format

* Expose url and cloze on definition

* Simplify for understandability

* Remove unused _createNoteData

* Update public object

* Remove trims on sentence, since it should already be trimmed

* Fix unused global
2021-01-12 22:47:07 -05:00
toasted-nutbread
b20622b2c8
Core refactor (#1207)
* Copy set intersection functions

* Remove unused functions

* Simplify url check

* Remove parseUrl

* Simplify stringReverse

* Remove hasOwn due to infrequent use

* Rename errorToJson/jsonToError to de/serializeError

For clarity on intended use.

* Fix time argument on timeout

* Add missing return value

* Throw an error for unexpected argument values

* Add documentation comments
2021-01-07 21:36:20 -05:00
toasted-nutbread
7d706df66b
Update DictionaryDataUtil to be able to be used in a sandbox frame (#1206) 2021-01-07 20:24:22 -05:00
toasted-nutbread
05d4049f16
DOMParser replacement (#561)
* Add script to build library files

* Add built parse5 library

* Add new SimpleDOMParser which uses parse5

* Update license info

* Update MV3 build to use the new SimpleDOMParser

* Update file exclusions

* Hide/clarify license info for MV2 builds
2020-12-18 17:06:30 -05:00
toasted-nutbread
51223abfa6
Set up initial manifest v3 support (#605) 2020-12-18 15:54:05 -05:00
toasted-nutbread
219dfb4917
Add a core deepEqual function (#1018)
* Add a core deepEqual function

* Add tests
2020-11-09 21:47:25 -05:00
toasted-nutbread
c8b738ddf7
Remove unused toIterable function (#857) 2020-09-22 22:59:07 -04:00
toasted-nutbread
29890f7625
Remove comments from . eslintrc.json (#853) 2020-09-20 12:16:59 -04:00
toasted-nutbread
dd8e32e7c4
Fix template renderer sandbox compatibility (#770)
* Use Object.prototype.hasOwnProperty.call instead of hasOwn

* Disable WebExtension and core.js APIs for template-renderer.js
2020-09-04 18:19:43 -04:00
toasted-nutbread
934355dd09
Add promiseAnimationFrame function (#752) 2020-08-23 12:43:53 -04:00
toasted-nutbread
a96e1c20a7
Dynamic property (#749)
* Add DynamicProperty class

* Add tests for DynamicProperty
2020-08-22 17:50:56 -04:00
toasted-nutbread
f0c974d319
Move generateId to core.js (#748) 2020-08-22 15:49:24 -04:00
toasted-nutbread
04d47bf8a9
Build system changes (#721)
* Refactor manifest.json

* Change end-of-line convention for built plain-text files

* Ignore builds directory

* Mark the "dev" directory as using the node environment

* Create build script

* Register build scripts

* Remove old build script

* Fix 64x64 icon

* Add test to ensure manifest data is updated properly
2020-08-09 13:09:06 -04:00
toasted-nutbread
128588bb92
Add no-underscore-dangle rule (#651) 2020-07-03 16:10:08 -04:00
toasted-nutbread
7b5dd5c310
Update browser compatibility and Edge detection (#629) 2020-06-28 12:40:02 -04:00
toasted-nutbread
cdf191336a
Clone function (#624)
* Add clone function

* Replace utilIsolate with clone

* Replace JsonSchema.isolate with clone function

* Include core.js for tests which use json-schema.js

* Update visisted set
2020-06-28 12:38:34 -04:00
toasted-nutbread
5bf805755a
Yomichan object separation (#627)
* Move "yomichan" object setup to a separate file

* Update script imports

* Align message handlers

* Rename Yomichan.prepare to Yomichan.ready

* Add new prepare function

* Improve isExtensionUrl
2020-06-28 11:26:43 -04:00
toasted-nutbread
51981f0c4e
Add deferPromise function (#626) 2020-06-28 11:23:51 -04:00
siikamiika
39df44eca4
Fix "tags" template (#539)
* fix tag templates for merge and group modes

* update version upgrade

* adjust upgrade replacement order
2020-05-22 20:03:34 -04:00
siikamiika
77b744e675
Modifier key profile condition (#487)
* update Frontend options on modifier change

* add modifier key profile condition

* use select element for modifier condition value

* support "is" and "is not" modifier key conditions

* use plural

* remove dead null check

it's never null in that function

* pass element on rather than assigning to this

* rename event

* remove Firefox OS key to Meta detection

* hide Meta from dropdown on Firefox

* move input type
2020-05-03 04:39:24 +03:00
toasted-nutbread
d581bffa15
Style fixes (#494)
* Place multi-line expression parentheses on the correct line

* Add function-paren-newline eslint rule

* Add some additional eslint rules
2020-05-02 13:04:17 -04:00
toasted-nutbread
5b96559df8
Error logging refactoring (#454)
* Create new logging methods on yomichan object

* Use new yomichan.logError instead of global logError

* Remove old logError

* Handle unhandledrejection events

* Add addEventListener stub

* Update log function

* Update error conversion to support more types

* Add log event

* Add API log function

* Log errors to the backend

* Make error/warning logs update the badge

* Clear log error indicator on extension button click

* Log correct URL on the background page

* Fix incorrect error conversion

* Remove unhandledrejection handling

Firefox doesn't support it properly.

* Remove unused argument type from log function

* Improve function name

* Change console.warn to yomichan.logWarning

* Move log forwarding initialization into main scripts
2020-04-26 16:55:25 -04:00
toasted-nutbread
f439d12718
Merge pull request #385 from toasted-nutbread/pitch-accents
Pitch accents
2020-04-05 12:51:27 -04:00
toasted-nutbread
ae246093a9 Create some tests for fullscreen elements, <iframe>s, and shadow DOMs 2020-04-04 16:56:06 -04:00
toasted-nutbread
a339bf69d3 Move set functions into core.js 2020-03-28 14:50:10 -04:00
toasted-nutbread
64fc0349a1 Update global declarations 2020-03-10 22:40:35 -04:00
toasted-nutbread
8f9b6534c6 Move stringReplaceAsync
It is only used in AnkiNoteBuilder and it was originally created
for this purpose.
2020-03-07 21:47:48 -05:00
toasted-nutbread
81fbe60da9 Define core globals only for extension scripts 2020-02-25 22:30:29 -05:00
toasted-nutbread
32cb1debb5 Add "guard-for-in": "error" 2020-02-25 22:15:50 -05:00
toasted-nutbread
9dd779836c Add "no-prototype-builtins" 2020-02-22 14:53:02 -05:00
toasted-nutbread
f1ccd52806 Explicitly indicate that "no-param-reassign" is allowed 2020-02-22 14:53:02 -05:00
toasted-nutbread
c0d91bffc4 Add no-shadow 2020-02-22 14:53:02 -05:00
toasted-nutbread
b3212d776e Stylistic rules 2020-02-22 14:52:09 -05:00