Commit Graph

253 Commits

Author SHA1 Message Date
eight
2fd531e253 Rewrite linter system (#487)
* Add: implement new linter system

* Refactor: pull out editor worker

* Switch to new linter and worker

* Enable eslint cache

* Fix: undefined error

* Windows compatibility

* Fix: refresh linter if the editor.linter changes

* Add: stylelint

* Add: getStylelintRules, getCsslintRules

* Fix: logic to get correct linter

* WIP: linter-report

* Fix: toggle hidden state

* Add: matain the order of lint report for section editor

* Add: unhook event

* Add: gotoLintIssue

* Fix: shouldn't delete rule.init

* Add: linter-help-dialog

* Drop linterConfig

* Add: linter-config-dialog, cacheFn

* Add: use cacheFn

* Drop lint.js

* Add: refresh. Fix report order

* Fix: hide empty table

* Add: updateCount. Fix table caption

* Switch to new linter/worker

* Fix: remove unneeded comment

* Fix: cacheFn -> cacheFirstCall

* Fix: use cacheFirstCall

* Fix: cache metaIndex

* Fix: i < trs.length

* Fix: drop isEmpty

* Fix: expose some simple states to global

* Fix: return object code style

* Fix: use proxy to reflect API

* Fix: eslint-disable-line -> eslint-disable-next-line

* Fix: requestId -> id

* Fix: one-liner

* Fix: one-liner

* Fix: move dom event block to top

* Fix: pending -> pendingResponse

* Fix: onSuccess -> onUpdated

* Fix: optimize row removing when i === 0

* Fix: hook/unhook -> enableForEditor/disableForEditor

* Fix: linter.refresh -> linter.run

* Fix: some shadowing

* Fix: simplify getAnnotations

* Fix: cacheFirstCall -> memoize

* Fix: table.update -> table.updateCaption

* Fix: unneeded reassign

* Fix: callbacks -> listeners

* Fix: don't compose but extend

* Refactor: replace linter modules with linter-defaults and linter-engines

* Fix: implement linter fallbacks

* Fix: linter.onChange -> linter.onLintingUpdated

* Fix: cms -> tables

* Fix: parseMozFormat is not called correctly

* Move csslint-loader to background

* Fix: watch config changes

* Fix: switch to LINTER_DEFAULTS

* Fix: csslint-loader -> parserlib-loader
2018-10-01 09:03:17 -05:00
tophf
af77b55eea fixup 2fdfd966
#482
2018-08-27 20:42:51 +03:00
tophf
2fdfd96699 use the new originalDigest in update UI
...when force-updating a locally edited style that turned out to be equal to the remote one

fixes #482
2018-08-27 20:39:36 +03:00
tophf
c0c5f1dbcc avoid overwriting existing usercss on saving a new one 2018-08-18 23:17:20 +03:00
tophf
406a7cd4c0 FF bug workaround: apply styles to more iframes 2018-08-09 21:22:26 +03:00
tophf
be94303bad simplify onInstalled 2018-08-06 18:20:57 +03:00
tophf
15c3c7c8ab fixup 3418ac9c: explicitly set the optional parameter
fixes #423
2018-07-09 09:10:36 +03:00
tophf
0d7b8152e8 code cosmetics 2018-07-05 15:46:01 +03:00
tophf
d8b776bedf try installing from full code if 'sections' is empty in style json
fixes #414
2018-07-05 15:46:01 +03:00
tophf
d37b113d0d retry on HTTP status 429 "Too Many Requests" 2018-07-02 17:20:22 +03:00
tophf
711a3afeee logQueue can be empty 2018-05-24 21:09:00 +03:00
tophf
82b797738a use Alarms API since js timers are limited to 596 hours
fixes #388
2018-05-14 08:56:31 +03:00
tophf
d36fea27ad fixup 3418ac9c: append to updateLog 2018-05-09 18:33:28 +03:00
tophf
3548a6caed fixup c26fa76f: parameter is an object =_=' 2018-05-09 18:11:59 +03:00
tophf
1f347df8cf fixup c26fa76f: Set#has
#380
2018-05-04 22:08:19 +03:00
tophf
c26fa76f53 retry the update check on 503
fixes #380
2018-04-30 20:05:52 +03:00
tophf
0a082f30d2 Chrome with NativeCrxBindings: ignore lastError in injectCS 2018-04-25 10:37:07 +03:00
tophf
677bf7b9bf Chrome with NativeCrxBindings: check lastError in injectCS 2018-04-24 22:16:21 +03:00
tophf
e80efa7604 FF: hotkeys dialog 2018-04-12 21:28:45 +03:00
tophf
8524c76f66 setBadgeText has a callback in Chrome 67+ 2018-04-05 00:41:05 +03:00
tophf
36b0e8f4bb clear entire cache when updating styles with global sections 2018-03-22 04:26:43 +03:00
tophf
4901e97f9f open USO style settings even if the site tab is auto-activated 2018-03-13 18:35:28 +03:00
tophf
a7774c26fb bump version 2018-03-13 17:24:10 +03:00
tophf
40054902e9 USO can't handle POST requests for style json 2018-03-13 17:23:47 +03:00
tophf
28ef5572ba FF: ensure styles are applied to about:blank iframes
fixes #215
2018-03-08 19:25:09 +03:00
tophf
850b7dc635 clear localStorage for CM themes on extension update 2018-03-03 23:45:14 +03:00
tophf
918888ffb0 code cosmetics 2018-02-16 18:05:25 +03:00
DecentM
44a11508ff Add OpenUserCSS support (#328) 2018-02-15 11:27:00 +03:00
tophf
f6991c4f57 fallback to 'path' when Canvas is blocked in FF
fixes #335
2018-01-30 19:42:30 +03:00
tophf
02989edb05 eat unclosed comments 2018-01-30 18:59:28 +03:00
tophf
90aacefff8 ignore @charset when deciding if section is empty
fixes #337
2018-01-30 18:59:28 +03:00
tophf
ca5f8c941b don't refresh own tabs twice
fixes #336
2018-01-29 04:37:24 +03:00
tophf
bc2da3f66a prevent hanging when parent frame is absent 2018-01-20 02:28:20 +03:00
tophf
a3962b7adf put https://top.site.origin in "stylus-iframe" attr 2018-01-19 15:37:26 +03:00
tophf
72e0f5fbf5 update refreshAllTabs cache and icon on disabling livepreview 2018-01-14 17:32:25 +03:00
tophf
b42dfc8300 fixup bb34538d: decrement styles.length on delete 2018-01-14 15:40:36 +03:00
tophf
eabfaca08e run webNavUsercssInstallerFF on the entire githubusercontent.com
fixes #329
2018-01-14 15:23:09 +03:00
tophf
bb34538da0 smart invalidateCache: try to update filters in-place 2018-01-12 00:54:40 +03:00
tophf
989df35b05 live preview in editor
* refreshAllTabs was extracted
* ...and fixed to use each frame's url when getting the styles
2018-01-12 00:54:36 +03:00
tophf
650cf3521b correctly strip 'code' from style hash 2018-01-10 22:18:35 +03:00
tophf
9fdabe3582 simplify getStyles
* 'asHash' implies 'enabled'
* 'length' is added to the style hash
2018-01-10 22:18:30 +03:00
tophf
bbfda6d33b expose findUsercss 2018-01-09 19:13:37 +03:00
tophf
022e588c97 allow errors in usercss when saving in editor and live-reloading 2018-01-07 16:36:30 +03:00
tophf
87d28d3fc7 silence eslint 2018-01-07 11:52:46 +03:00
tophf
71c3e0c7a8 extract and improve dummy chrome.storage in FF
* chrome.storage.onChanged supported in own pages
* values are stored in the background page
* chrome.storage in own pages accesses that background storage
2018-01-04 17:04:23 +03:00
tophf
2374c88e1b extract styleSectionsEqual 2018-01-04 16:43:54 +03:00
tophf
9be2f942c7 restore default template on saving empty code
fixes 3418ac9c
2018-01-04 16:41:55 +03:00
tophf
1eea8fdbbf fixups for refreshAllTabs 2018-01-03 18:26:31 +03:00
tophf
a572620765 cache icon imageData because the browser doesn't 2018-01-03 10:44:12 +03:00
tophf
3f570c4d3a FF injects content script automatically 2018-01-03 10:44:12 +03:00
tophf
3418ac9cb9 FF: support private/container tabs 2018-01-03 10:43:56 +03:00
tophf
5bc4206593 reuse existing usercss installer tab
A few additional checks were needed to circumvent FF bugs
so openURL was refactored to keep the code readable
2017-12-31 17:59:32 +03:00
tophf
8d9c7acb3c only preserve old style name on update if it was actually customized
We didn't detect that previously and just blindly assumed that a local name is always customized by a user, which is nonsense, obviously. To ensure reliable detection a new property is added to the style object: "originalName". From now on the styles that didn't change their name remotely will be successfully marked as having non-customized names, hence the names will update along with the code. Should be like 99% of styles. As for the remaining 1%, welp, only uninstalling and reinstalling the style anew would switch to the new remote name.
2017-12-13 09:12:54 +03:00
tophf
51ad84e6a9 don't open the homepage on first install as it's not helpful
see #112
2017-12-13 05:35:02 +03:00
tophf
ad692d4f61 chrome.contextMenus.update bug is fixed in Chrome 65.0.3289
#272
2017-12-12 06:20:07 +03:00
tophf
adabb9aeff use LZString alias for LZStringUnsafe 2017-12-11 04:49:59 +03:00
tophf
6fb9d2d157 switch to a much faster LZStringUnsafe
https://github.com/pieroxy/lz-string/pull/98
2017-12-10 11:30:57 +03:00
tophf
405400de68 move 'tempUsercssCode' cleanup to usercss helper 2017-12-10 10:11:18 +03:00
tophf
5d54ce3464 DRY chromeLocal and chromeSync 2017-12-10 10:11:18 +03:00
tophf
42e458ad69 saved.name is absent when checking in manager 2017-12-09 23:27:40 +03:00
tophf
9486c7f3df don't report usercss as installed on USO if homepage matches 2017-12-09 04:43:02 +03:00
tophf
f337e18515 recognize usercss @updateURL
* installation URL is preferred - same behavior as before

* @updateURL is used when the style was drag'n'dropped into the manage page
  because there's no real URL in this case

* install-usercss page shows the new update URL, which is set as per the above,
  under the checkbox that enables updates
2017-12-06 22:35:19 +03:00
tophf
1785bac9d2 fix usercss updater: skip if code hasn't changed 2017-12-04 10:28:24 +03:00
tophf
f4677a7b7b actually use the name when saving 2017-12-03 20:32:50 +03:00
tophf
c11c100cbb circumvent the bug with disabling check marks in Chrome 62+
fixes #272
2017-12-02 16:13:40 +03:00
tophf
7de3e37a51 show "Style installed" in manager for styles added while it's open 2017-12-02 07:07:12 +03:00
tophf
cbe90272b9 silence some useless warnings in console 2017-11-29 17:59:01 +03:00
tophf
ff175d9af4 store installDate and updateDate 2017-11-26 20:47:23 +03:00
tophf
288f347e40 fixup 978e5ca9 and ee86ef30: editor.contextDelete option 2017-11-26 14:20:44 +03:00
tophf
e4de02995c fixup 978e5ca9: don't reuse the same object in async code! 2017-11-26 00:04:19 +03:00
tophf
6aef6cdcd7 0 is a valid tab id 2017-11-25 20:24:15 +03:00
tophf
aedb02bbb1 install usercss from raw.githubusercontent.com 2017-11-25 18:24:37 +03:00
tophf
59d32e6f2f inline and simplify closeTab() 2017-11-25 18:00:41 +03:00
tophf
978e5ca9f0 sendMessage()
Promise mode [default]:
  - rejects on receiving {__ERROR__: message} created by
    background.js::onRuntimeMessage
  - suppresses chrome.runtime.lastError
    by browserAction.setText which lacks a callback param in chrome API

Callback mode:
  - enabled by passing a second param
  - doesn't suppress chrome.runtime.lastError
2017-11-25 18:00:38 +03:00
tophf
8f04e17d27 fix #223 - Android compatibility 2017-11-25 16:25:20 +03:00
tophf
8c5471092c rework install-usercss: CSS, layout, warnings 2017-11-24 13:19:10 +03:00
tophf
00ead83da9 don't hardcode homepage URL, extract it from "Get Help" translation 2017-11-21 09:48:55 +03:00
tophf
fc5c00e37d all actions must always return a Promise 2017-11-15 07:11:46 +03:00
tophf
94ed435e75 fixup d2b9b302: prevent setting version var to 'undefined' 2017-11-14 11:12:18 +03:00
tophf
ac8331e6ae FF: use tabs API for XML viewer 2017-11-14 09:52:51 +03:00
tophf
9503acc2bf styleSectionsEqual() order of sections should be identical
Thus we account for the case of multiple sections matching the same URL because the order of rules is part of cascading
2017-11-14 09:38:09 +03:00
tophf
3c08342e98 open usercss installer tab next to the source tab 2017-11-14 09:38:08 +03:00
tophf
1d463d7820
Merge pull request #134 from eight04/dev-user-css
Install styles from *.user.css file
2017-11-14 08:22:56 +03:00
eight
1dd0dbf907 Revert: isSame/isEdited util 2017-11-09 14:11:25 +08:00
eight
92b01e19e8 Fix: reindent single then 2017-11-09 09:12:03 +08:00
eight
8d19e0b09a Fix: noReject in one line 2017-11-09 09:12:02 +08:00
eight
08c7004123 Fix: use switch for version compare 2017-11-09 09:12:02 +08:00
eight
90be1dae25 Fix: status: 'success' -> success: true 2017-11-09 05:35:45 +08:00
tophf
72714160bb storage: fallback on any IndexedDB-related failure 2017-11-05 06:13:51 +03:00
eight
098dc10f85 Fix: pull out runtimeSend 2017-11-01 11:15:11 +08:00
eight
79b6266cf9 Fix: no new line before use strict 2017-11-01 11:13:57 +08:00
eight
6f51100c82 Fix: unused injectContent 2017-11-01 08:09:08 +08:00
eight
62748b3b79 Fix: use arrow function for IIFE 2017-10-30 01:22:10 +08:00
eight
831a4ef939 Fix: remove logging in wrapReject 2017-10-16 14:59:45 +08:00
eight
54076d9f17 Merge branch 'master' of https://github.com/openstyles/stylus into dev-user-css 2017-10-12 16:28:18 +08:00
eight
0d4d058b00 Fix: remove unused initInstallPage 2017-10-06 16:33:50 +08:00
eight
f194155830 Add: close source tab after install 2017-10-06 16:33:50 +08:00
eight
2912a53729 Fix: missing id when updating digest 2017-10-04 16:19:20 +08:00
tophf
9585aea08d insertCSS#cssOrigin requires FF53 2017-09-30 02:32:43 +03:00
eight
7365a8bada Fix: various fixes 2017-09-25 18:43:55 +08:00
eight
cb7aaa7111 Fix: move to root 2017-09-24 17:18:38 +08:00
eight
18fd15317e WIP: install page 2017-09-24 11:39:04 +08:00
eight
aa71984fd3 Fix: save name when updating usercss 2017-09-18 12:59:22 +08:00
eight
1d829fe8f5 Fix: split up usercss logic from saveStyle 2017-09-18 11:34:12 +08:00
eight
a0495f466f Change style structure 2017-09-16 10:14:23 +08:00
eight
eaf33afbe3 Rewrite parser, add uso preprocessor 2017-09-15 13:40:04 +08:00
eight
f3176de950 Fix: findDupUsercss indent 2017-09-12 18:57:06 +08:00
eight
e1d221e9a9 Fix: saveStyle indent 2017-09-12 18:54:38 +08:00
eight
e13a6f6f92 Fix: saveUsercss 2017-09-12 18:52:55 +08:00
eight
a395df18f9 Fix: rewrite filterUsercss 2017-09-12 18:49:17 +08:00
eight
33200dbde4 Fix: cleanup injectContent 2017-09-12 18:34:48 +08:00
eight
8207d608be Fix: injectResource -> injectContent 2017-09-12 18:28:16 +08:00
tophf
a8796b0bd2 prevent race condition in getStyles before dbExec.initialized
fixes #184
2017-09-12 12:12:11 +03:00
eight
d4ddefe8a0 Merge branch 'master' of https://github.com/openstyles/stylus into dev-user-css 2017-09-12 03:40:56 +08:00
eight
f305719db3 Fix: update progress 2017-09-12 01:23:32 +08:00
eight
cb23f89b6a Add: allow saveUsercss to build style 2017-09-10 22:04:43 +08:00
eight
3daff40acf Add: vars validation 2017-09-09 19:29:35 +08:00
eight
1f44898475 Add: adopt node-semver 2017-09-06 03:08:03 +08:00
eight
f74641e20d Add: make filterUsercss build code to get section includes 2017-09-05 18:48:18 +08:00
tophf
36d790e0c2 improve CSS transition suppression on own pages in FF 2017-09-04 01:05:32 +03:00
tophf
538da08a95 fixup d843b4e2: a shallow copy is needed 2017-09-03 22:34:42 +03:00
tophf
50239a49df fixup 53aa239d for new installations 2017-09-03 21:56:46 +03:00
tophf
09010c20a6 enqueue stuff dependent on DB decision 2017-09-03 21:25:19 +03:00
tophf
53aa239da3 fallback to chrome.storage when IndexedDB is dysfunctional 2017-09-03 20:06:42 +03:00
tophf
ea8eaf3146 swap parameters in prefs.subscribe 2017-09-03 20:06:30 +03:00
tophf
d843b4e23f filterStyles: code cosmetics and a bug fix 2017-09-03 19:43:38 +03:00
tophf
519d745f59 globally disable CSS transitions for a moment during page opening
the problem we fix is that since we add the styles asynchronously, the browsers, esp. Firefox, sometimes apply transitions from the null/default state to the one specified in the injected CSS.

supersedes 72e8213b and 4dbca46b
2017-09-03 19:43:37 +03:00
eight
3c40b52f96 Add 'injectResource' message to inject js/css 2017-09-01 18:21:45 +08:00
tophf
c88438c6eb use tryCatch to simplify 7e5396a1 2017-08-30 18:05:22 +03:00
eight
dece4b57f3 Add: install styles from *.user.css file
Fix: handle dup name+namespace

Fix: eslint eqeqeq

Fix: trim @name's spaces

Add: check update for userstyle

Add: build CSS variable

Fix: only check dup when id is not provided

Refactor: userStyle2json -> userstyle.json

Add: style for input

Add: config dialog

Fix: preserve config during update

Fix: onchange doesn't fire on keyboard enter event

Fix: remove empty file

Add: validator. Metas must stay in the same line

Add: warn the user if installation failed

Fix: add some delay before starting installation

Add: open the editor after first installation

Fix: add openEditor to globals

Fix: i18n

Add: preprocessor. Move userstyle.build to background page.

Fix: remove unused global

Fix: preserved unknown prop in saveStyleSource() like saveStyle()

Add: edit userstyle source

Fix: load preprocessor dynamically

Fix: load content script dynamically

Fix: buildCode is async function

Fix: drop Object.entries

Fix: style.sections is undefined

Fix: don't hide the name input but disable it

Fix: query the style before installation

Revert: changes to editor, editor.html

Refactor: use term `usercss` instead of `userstyle`

Fix: don't show homepage action for usercss

Refactor: move script-loader to js/

Refactor: pull out mozParser

Fix: code style

Fix: we don't need to build meta anymore

Fix: use saveUsercss instead of saveStyle to get responsed error

Fix: last is undefined, load script error

Fix: switch to moz-format

Fix: drop injectContentScript. Move usercss check into install-user-css

Fix: response -> respond

Fix: globals -> global

Fix: queryUsercss -> filterUsercss

Fix: add processUsercss function

Fix: only open editor for usercss

Fix: remove findupUsercss fixme

Fix: globals -> global

Fix: globals -> global

Fix: global pollution

Revert: update.js

Refactor: checkStyle

Add: support usercss

Fix: no need to getURL in background page

Fix: merget semver.js into usercss.js

Fix: drop all_urls in match pattern

Fix: drop respondWithError

Move stylus -> stylus-lang

Add stylus-lang/readme

Fix: use include_globs

Fix: global pollution
2017-08-30 17:29:41 +08:00
tophf
37bff1c5c9 handle null response from API in chromeSync 2017-08-28 15:20:38 +03:00
tophf
5330db11af FF: ignore lastError in sendMessage where irrelevant 2017-08-28 15:20:38 +03:00
tophf
cd6bcc6511 FF: when not dom.storage.enabled use dummies 2017-08-28 15:20:38 +03:00
tophf
9946f3c781 regroup some of lint* data and code
* all lint-related js files are prefixed by lint-
* config-related stuff is grouped in linterConfig
* CM helper is rewritten and moved in /edit now that CSSLint supports these features
* chromeSync methods that apply LZString got LZ in their names
* empty string is used for 'disabled' in linter selector
2017-08-28 15:20:37 +03:00
Rob Garrison
988af5f1b8 Store linter rules with sync & LZ compression 2017-08-27 17:20:47 -05:00
Rob Garrison
8dc2115347 Revert no-inline-comments (2ea5a3bbaa2fdb0a) 2017-08-27 17:20:46 -05:00
Rob Garrison
d563495c26 Fix no-inline-comments issues 2017-08-27 17:20:45 -05:00
tophf
d1924c1d63 deglobalize onAttached listener for editor tabs
* bonus: one unconditional global listener less
* bonus: in FF the saved window size is restored on detaching
* theoretically possible drawback: 100+ editor tabs on a slow computer may be slower than before
2017-08-27 17:17:28 +03:00
tophf
8976bd58b8 inform when dysfunctional due to FF options 2017-08-26 15:34:27 +03:00
tophf
0d038c59bc make getDomains foolproof
fixes #172
2017-08-26 07:57:52 +03:00
tophf
7e5396a11d prevent browser exception bug on sendResponse to a closed tab
fixes #171
2017-08-26 07:51:28 +03:00
tophf
815f8ca959 also find styles for URLs with stripped #hash
kinda fixes #155

as per spec the fragment portion is ignored in @-moz-document:
https://www.w3.org/TR/2012/WD-css3-conditional-20120911/#url-of-doc
but we still respect url("foo#hash") set in userstyles
because the spec is outdated and doesn't account for SPA sites

collateral damage: simplified URLS.supported()
2017-08-18 13:18:19 +03:00
tophf
af41d646dd Don't show editor.contextDelete option in FF; #128 2017-07-31 19:39:44 +03:00
tophf
3ddf812635 Don't count styles on NTP in Chrome 61+, see #122 2017-07-28 08:19:07 +03:00
tophf
3b49d83616 In Chrome 61.0.3161+ NTP can't be styled anymore 2017-07-23 12:42:34 +03:00
tophf
b37b2c5246 fixup e463ca7e: use the actual tab index 2017-07-22 16:57:52 +03:00
tophf
e463ca7ece setBadgeText: skip pre-rendered tabs 2017-07-22 12:56:38 +03:00
Rob Garrison
8cfb37351d Remove unused variables 2017-07-16 14:40:13 -05:00
Rob Garrison
417e3b5de3 Add eqeqeq definition to eslint 2017-07-16 13:07:21 -05:00
Rob Garrison
1a630033bd Use a single declaration per line 2017-07-14 04:10:00 -05:00