Compare commits
1785 Commits
freestyler
...
master
Author | SHA1 | Date | |
---|---|---|---|
|
fc39f0d5a6 | ||
|
1725c0ecb9 | ||
|
79dff2775b | ||
|
b22bbaaec0 | ||
|
fff59ee12f | ||
|
540e2af62c | ||
|
0128489bbb | ||
|
a5b11ac687 | ||
|
5d3a9dccf3 | ||
|
09691a6362 | ||
|
62987fe5f8 | ||
|
405a93f9e5 | ||
|
da4bdc6821 | ||
|
d1f5468a81 | ||
|
efc6d09d49 | ||
|
0bb0d32c29 | ||
|
f5397b8aec | ||
|
1594b4dcd8 | ||
|
527d7c0fbc | ||
|
cda606e7cc | ||
|
5cb30c8b69 | ||
|
1b914a397e | ||
|
7b64deeb37 | ||
|
9398857d93 | ||
|
b45825c015 | ||
|
3aae3f181a | ||
|
48d90544f6 | ||
|
ef998e423e | ||
|
6979958908 | ||
|
4236eb4e29 | ||
|
c351413c3f | ||
|
d91cf11366 | ||
|
e49644f1c8 | ||
|
15b59ae207 | ||
|
ad43560016 | ||
|
c423025c5d | ||
|
030621462c | ||
|
bf3dd0318d | ||
|
3489b513c9 | ||
|
984fa6e425 | ||
|
6110cbee68 | ||
|
40ec2c000f | ||
|
9022f6b318 | ||
|
c5667b0352 | ||
|
5379f62c90 | ||
|
9d3fa1c5f9 | ||
|
906a5ca960 | ||
|
e1e351d956 | ||
|
7a5569e9d5 | ||
|
2d21bb1dd6 | ||
|
8302c50d54 | ||
|
27a878aed8 | ||
|
f9e6df116f | ||
|
a832b51d9c | ||
|
b88a978843 | ||
|
685bf1fa3e | ||
|
6995483ec0 | ||
|
6ff5f17140 | ||
|
7a1045b45a | ||
|
079e7e50f1 | ||
|
00b732177f | ||
|
484ff24950 | ||
|
31177f1017 | ||
|
e406e2b5dc | ||
|
bd2b435781 | ||
|
b742ed2c65 | ||
|
d68433c867 | ||
|
a10003ee80 | ||
|
3fcd4f8027 | ||
|
9364ef585f | ||
|
6e0cfb7d0f | ||
|
91501cce19 | ||
|
95a4514f15 | ||
|
3d6b55e53e | ||
|
88a0a3858c | ||
|
685ee625ee | ||
|
944a7f23ef | ||
|
d78329d295 | ||
|
b5fd8b63dc | ||
|
a77996df60 | ||
|
2e1961bdf7 | ||
|
cd88aff733 | ||
|
0f3ba30066 | ||
|
cda6e4fb9e | ||
|
97520be9b2 | ||
|
30af48a69a | ||
|
b33b5ba624 | ||
|
ad5c90e240 | ||
|
3522a53ad4 | ||
|
79ada00a01 | ||
|
a34fe5f400 | ||
|
ffb72cc656 | ||
|
a74ae5ac4f | ||
|
3907116328 | ||
|
fd42f2d365 | ||
|
537372dffa | ||
|
f54d145bf5 | ||
|
2efb6c5cd1 | ||
|
ea388ea9a7 | ||
|
24aaf2fdb8 | ||
|
963e58f237 | ||
|
57a7939b5e | ||
|
ec5a685ee2 | ||
|
b21497c1b2 | ||
|
ba1f10b865 | ||
|
7ab95cce33 | ||
|
0a84d802d3 | ||
|
2c42f40acb | ||
|
ee0826e538 | ||
|
411d7f7b95 | ||
|
614dce0e8c | ||
|
619f771b4a | ||
|
9ed550c882 | ||
|
6d721fe7a5 | ||
|
d9ad0fec3c | ||
|
d623aa679f | ||
|
9e009726c5 | ||
|
bcc98d913b | ||
|
2e31cae71e | ||
|
b80c3e2f73 | ||
|
37baf8a2c6 | ||
|
b4f10cb296 | ||
|
8fc6c8bcde | ||
|
29cafd619c | ||
|
bd9d51308a | ||
|
d2a99b5be1 | ||
|
e567b6d56d | ||
|
329d0caac1 | ||
|
51e9b09f52 | ||
|
f5b2fe2fc6 | ||
|
38ac974d8a | ||
|
5ff664f9b9 | ||
|
b75e2cb56b | ||
|
d162928fb9 | ||
|
ce7137c54d | ||
|
62974751ff | ||
|
e0c9c13856 | ||
|
6ff68aaa74 | ||
|
bd0e8273c1 | ||
|
268c7b758b | ||
|
38ddf5d79d | ||
|
90a71c0afc | ||
|
dd1f30e6aa | ||
|
b804e39de6 | ||
|
16f7e19915 | ||
|
ad969fca6a | ||
|
9d64e9ba54 | ||
|
cc3c85be58 | ||
|
f7bbfd6ead | ||
|
dff0c133b4 | ||
|
1364d3a8ba | ||
|
bef70f6db3 | ||
|
77562ecd8d | ||
|
9fbf641571 | ||
|
a58af7f816 | ||
|
8d3e01e05a | ||
|
c9b8593830 | ||
|
6fb2727f6b | ||
|
1721bad7d8 | ||
|
944c44ffb8 | ||
|
adef93c3ed | ||
|
b7cfbe6e66 | ||
|
dd38856eda | ||
|
225a2cec31 | ||
|
2e021f6ac9 | ||
|
fcad0ee523 | ||
|
f9a2b9de35 | ||
|
648b295ef2 | ||
|
81a5acfda3 | ||
|
10de02f04d | ||
|
b86cb6a36c | ||
|
290a0f99d2 | ||
|
ae6f7024ce | ||
|
de5eb32d2d | ||
|
c29048c366 | ||
|
6b87f7840f | ||
|
421526d60b | ||
|
9b0db09b6c | ||
|
bab1ba17a9 | ||
|
50da5f1966 | ||
|
2e2c6765b5 | ||
|
b2bc18c3d5 | ||
|
84f4262176 | ||
|
799423629a | ||
|
f282623ef7 | ||
|
513ced6d57 | ||
|
d048c480c3 | ||
|
f966b2ef96 | ||
|
c597303692 | ||
|
26b75e77b3 | ||
|
46785b0550 | ||
|
554d121c45 | ||
|
f9e11f5806 | ||
|
5529cbec2b | ||
|
5253c863b9 | ||
|
60834f7bd6 | ||
|
8afab0eaeb | ||
|
4c4a319b33 | ||
|
ea7c26ce71 | ||
|
f740686cb5 | ||
|
e54178a43c | ||
|
60f59e9f06 | ||
|
0e31557748 | ||
|
45eeedbe97 | ||
|
b4b135826c | ||
|
ce9e74e2a0 | ||
|
f041f2265a | ||
|
98da86f816 | ||
|
4c696fefbc | ||
|
6a07ad0f56 | ||
|
b692cf9608 | ||
|
be43bf3f23 | ||
|
cc7eba979e | ||
|
594ca3520c | ||
|
42d6e2f2af | ||
|
f7729eac15 | ||
|
0705392fb2 | ||
|
936f5b40d2 | ||
|
9136631bc6 | ||
|
14e0a418bf | ||
|
12eb243610 | ||
|
956b60e1ef | ||
|
0c20ef5d17 | ||
|
ddc09f3511 | ||
|
8ddeef221b | ||
|
cce483dd22 | ||
|
d9a80623e1 | ||
|
ca5402136d | ||
|
5791ae7b05 | ||
|
68dc584749 | ||
|
6e4fc3236e | ||
|
ba9d904ccc | ||
|
51e56110e8 | ||
|
906508832b | ||
|
8128100cef | ||
|
6afb4dc634 | ||
|
440395db9f | ||
|
3cdf526fa3 | ||
|
6b9cdf2bc2 | ||
|
249196d414 | ||
|
0ac01d2e22 | ||
|
9d2854c272 | ||
|
f6e6a138db | ||
|
3ea7e45624 | ||
|
7e3c6f16e9 | ||
|
e23077a7ea | ||
|
9ab5369393 | ||
|
9d1243073b | ||
|
a59aab73fc | ||
|
6c13db1468 | ||
|
19ebeedf6a | ||
|
b17eef4053 | ||
|
7ad3f94697 | ||
|
8b67eb885d | ||
|
707d8bb1a7 | ||
|
0034dcb941 | ||
|
992b89f0eb | ||
|
37a174b092 | ||
|
4243815349 | ||
|
11028bd635 | ||
|
dc18320b60 | ||
|
eaef854bcf | ||
|
e5807a7823 | ||
|
818031a86b | ||
|
fce049a911 | ||
|
cf0ecbfd4a | ||
|
997f1fe8de | ||
|
94f727dc09 | ||
|
05bc4301ad | ||
|
58ad6f64d6 | ||
|
349a8c3878 | ||
|
4a0f74764a | ||
|
dfd8f7a1b1 | ||
|
59cac7a469 | ||
|
e7d5fff736 | ||
|
048c267266 | ||
|
a56676122f | ||
|
701c30a6c8 | ||
|
a08dd2800d | ||
|
31dd972c7a | ||
|
d84e1bddab | ||
|
d181298e56 | ||
|
2c31dc2af8 | ||
|
abced603b4 | ||
|
a5a8d97767 | ||
|
12764baacb | ||
|
b0ed85c5ea | ||
|
2eeab2c1be | ||
|
bfd0d03871 | ||
|
8ac43fca31 | ||
|
32c5e17d08 | ||
|
95205c70e5 | ||
|
8e36e0277f | ||
|
9d6542a39d | ||
|
c08747202a | ||
|
6927fa5d70 | ||
|
46b0c9005d | ||
|
9722554b3b | ||
|
07291f9486 | ||
|
598735fc7b | ||
|
1e5f118d2d | ||
|
49af723078 | ||
|
304dcb1489 | ||
|
434e7ff6c6 | ||
|
2dbccf71db | ||
|
ce2250a1f3 | ||
|
50717465b9 | ||
|
91324a4a48 | ||
|
6798114196 | ||
|
ba7b55c23d | ||
|
295cb4541c | ||
|
b6cc6a09b9 | ||
|
404efcecf9 | ||
|
55046ef68c | ||
|
f35bf6a2a5 | ||
|
c34b054642 | ||
|
e1b65ae21f | ||
|
6e591b0d52 | ||
|
6650a37194 | ||
|
23d86c53a7 | ||
|
ebb5fcafbc | ||
|
39c51435ca | ||
|
a46bb103c5 | ||
|
02db1aab6f | ||
|
7a0ac57b06 | ||
|
33ff2c8373 | ||
|
2d9d0ad1f8 | ||
|
61c7d4f08c | ||
|
69ccdb0591 | ||
|
8abcf9e754 | ||
|
654403eb00 | ||
|
ffcdf47ab5 | ||
|
9e9c9061dc | ||
|
ab44c60522 | ||
|
e8e18abe58 | ||
|
58fc531515 | ||
|
44b08dc089 | ||
|
264544dfa9 | ||
|
a2c8953e63 | ||
|
9e72784b2a | ||
|
fa43c6d94d | ||
|
fe45781545 | ||
|
ada46e8277 | ||
|
4e87a060f5 | ||
|
83a6808c67 | ||
|
4bd956f891 | ||
|
367ae56047 | ||
|
18265b94c6 | ||
|
440a9f4763 | ||
|
d736a00bc1 | ||
|
be4fd17113 | ||
|
b0a03d53fc | ||
|
23aa036db5 | ||
|
0aa6d3b463 | ||
|
f10ebffeff | ||
|
892b295897 | ||
|
afcd8ebcf4 | ||
|
711f6502b5 | ||
|
43f1da1b4c | ||
|
baca54bf19 | ||
|
0b9b972338 | ||
|
a934571dc7 | ||
|
82d2530669 | ||
|
33e7f920a3 | ||
|
fa2dec724a | ||
|
2d5788766a | ||
|
8c160ed40c | ||
|
ed238183eb | ||
|
3f4fb0617e | ||
|
35e0a9d032 | ||
|
21d902c48c | ||
|
a7ae3fbc55 | ||
|
db77e03e97 | ||
|
692d3c9826 | ||
|
9531698dd7 | ||
|
9d19d61913 | ||
|
ff63b84489 | ||
|
4ae2c67033 | ||
|
65ac351699 | ||
|
7d08fea5e1 | ||
|
8eca4e9139 | ||
|
102121ad8f | ||
|
4228758cec | ||
|
c0eace302f | ||
|
a56e528b31 | ||
|
01e2e09fa5 | ||
|
b8f6f5db8d | ||
|
41533e863d | ||
|
53c71614fc | ||
|
9b46da5846 | ||
|
81fa6b1e79 | ||
|
a5d2d96717 | ||
|
69308d04e9 | ||
|
75ae8e79bf | ||
|
14efa1f052 | ||
|
3e415460c6 | ||
|
ea6359307b | ||
|
acaf12f694 | ||
|
abd018d750 | ||
|
cf1f51af0a | ||
|
b61cd75b25 | ||
|
c5e2baaf87 | ||
|
76ee0992e7 | ||
|
a674874861 | ||
|
58ae4704b2 | ||
|
3102738cfb | ||
|
c17dddb0ee | ||
|
75db3601d0 | ||
|
83adc5aa1e | ||
|
890ff395c0 | ||
|
c00c748c1e | ||
|
c60c764d34 | ||
|
1746235d0d | ||
|
94cf673f68 | ||
|
ade8d1981b | ||
|
50959354ec | ||
|
784a1018f8 | ||
|
34c067c3be | ||
|
c12d3fc5e3 | ||
|
272dea01a2 | ||
|
5304805c63 | ||
|
8ee964c045 | ||
|
24a0077783 | ||
|
c41a5f92c3 | ||
|
3a3104b30a | ||
|
afa4a1ac14 | ||
|
2c9ea4fdc0 | ||
|
8cabf8a8aa | ||
|
02bd682135 | ||
|
a88996be6f | ||
|
a66a1f8ed6 | ||
|
4338f67352 | ||
|
914943ed4c | ||
|
eb5fd90dc7 | ||
|
b00e6d23fe | ||
|
fe176c9b62 | ||
|
ac7b33d7e0 | ||
|
39e03b0a9f | ||
|
312f444ec7 | ||
|
1308efb8d0 | ||
|
11d311d1e8 | ||
|
767b2017e0 | ||
|
dfb9135f6a | ||
|
7d6b4fc8ac | ||
|
57233db546 | ||
|
cb85fe9392 | ||
|
fd890f8e61 | ||
|
8807819f16 | ||
|
6563aca141 | ||
|
d26dd92f44 | ||
|
c35302dff6 | ||
|
fdbfb23547 | ||
|
06823bd5b4 | ||
|
1e614fa2bc | ||
|
7140993e6c | ||
|
775d77a3a8 | ||
|
579750fbc0 | ||
|
0b540fbabd | ||
|
75cf46aaa7 | ||
|
26a539bd62 | ||
|
463c3b5139 | ||
|
6d04c0eb7d | ||
|
e6f94378bf | ||
|
207afccd65 | ||
|
6847681ed3 | ||
|
a87c49f0fc | ||
|
cb64a6bac9 | ||
|
6451eb533c | ||
|
355f240779 | ||
|
a91183e1bb | ||
|
a5848682b3 | ||
|
7c2b46be83 | ||
|
c635f2e38c | ||
|
657798d219 | ||
|
b4ca17c531 | ||
|
32cca90ddd | ||
|
8b58b22825 | ||
|
b59737a012 | ||
|
eb99101f35 | ||
|
5bb1b5ef35 | ||
|
4d198f56e2 | ||
|
51f125113d | ||
|
00ae843f78 | ||
|
2bf30ed16d | ||
|
e6988d2f9e | ||
|
008e33254d | ||
|
3dc684f85f | ||
|
17a0bd69c0 | ||
|
70e3ba15b7 | ||
|
420480887e | ||
|
1bd366beb9 | ||
|
79cd6da824 | ||
|
420733b93a | ||
|
7fa4d10fd6 | ||
|
a065039d50 | ||
|
0b3e027bfd | ||
|
3db6662d2f | ||
|
6259cc2e79 | ||
|
a26115154a | ||
|
da6361637d | ||
|
d183779fb5 | ||
|
3a8f47f4db | ||
|
eb70e5a2aa | ||
|
30b9378d2c | ||
|
dc4819e7d0 | ||
|
ff1fa07267 | ||
|
7d18376cf2 | ||
|
bc8d8b235c | ||
|
a94969e47d | ||
|
4ac92a4f9b | ||
|
5e5fecbcfe | ||
|
71cabc2029 | ||
|
aac0f476b2 | ||
|
635fc705f9 | ||
|
31558d5071 | ||
|
97ad0753e0 | ||
|
a997ecbe24 | ||
|
32728b023b | ||
|
ad44fe47c8 | ||
|
1c7e06e980 | ||
|
21d4221df9 | ||
|
972a83d5bc | ||
|
caec255e16 | ||
|
72cb5bdc9a | ||
|
b56dacb6b2 | ||
|
be47cfc471 | ||
|
6d7bd650e9 | ||
|
a81e1b8ac3 | ||
|
4764f91453 | ||
|
74364b9d63 | ||
|
2747d3930b | ||
|
bd3f630617 | ||
|
2a6850c02e | ||
|
2c674bdc0c | ||
|
2ed936af00 | ||
|
89431615b3 | ||
|
bf40fa81e8 | ||
|
1a7b51be6b | ||
|
4fade0fdfe | ||
|
34ad3cfaef | ||
|
92fcb02a57 | ||
|
4eabdf3f57 | ||
|
5ba111dce9 | ||
|
3a615e4e06 | ||
|
2af83ee846 | ||
|
8598b71a73 | ||
|
595b037ab1 | ||
|
5a5512aa0f | ||
|
54605c838b | ||
|
e6e7d7d158 | ||
|
2d9785be6e | ||
|
0199b2c0bb | ||
|
6593d5c05a | ||
|
f9804036b2 | ||
|
7f15ae324d | ||
|
76e2a90392 | ||
|
d1b9338707 | ||
|
bc6c9c826a | ||
|
2e1a903cc7 | ||
|
34f899fc45 | ||
|
3cb9cbb862 | ||
|
e6d73be049 | ||
|
d405bc64ae | ||
|
5501efb1be | ||
|
3d0b733e9a | ||
|
56a8212fdf | ||
|
492b75d84e | ||
|
a71b621bf9 | ||
|
9e487b03e5 | ||
|
60fc6f2456 | ||
|
ad24ee0c15 | ||
|
740a16a563 | ||
|
4d1110986c | ||
|
af726405e1 | ||
|
11ce144efb | ||
|
707cd6576f | ||
|
4913da2e19 | ||
|
78b0e33ba4 | ||
|
0162f39163 | ||
|
5196f96ee3 | ||
|
b840d4897d | ||
|
9994811819 | ||
|
a01bd3cd61 | ||
|
7c205880d2 | ||
|
6b2dff6687 | ||
|
cb89be8682 | ||
|
7c89f7b21d | ||
|
15d854f913 | ||
|
e7a6e86b6c | ||
|
c416fa7ca0 | ||
|
3f6c85637c | ||
|
e0a7372f4f | ||
|
038629517e | ||
|
ee30aa1407 | ||
|
2b149f97a5 | ||
|
30983db679 | ||
|
fa1496ecb8 | ||
|
aa43507478 | ||
|
07ba44cc2c | ||
|
01cfb435f6 | ||
|
5109f9abb3 | ||
|
e0aadb752a | ||
|
db3747d5f0 | ||
|
56f1574433 | ||
|
a0172c262c | ||
|
7d93608186 | ||
|
54b1f218e0 | ||
|
3d94c641b3 | ||
|
96c87fc55d | ||
|
d18314357f | ||
|
f8402a2211 | ||
|
0f394fa8d8 | ||
|
7e7839bb1e | ||
|
c43315e697 | ||
|
837b119e47 | ||
|
282a1e7432 | ||
|
e1807c8851 | ||
|
7e195594b5 | ||
|
079b7a39f1 | ||
|
7e6edb9e1b | ||
|
787466fc40 | ||
|
09f6e8d44a | ||
|
ca3633b896 | ||
|
2f4658657d | ||
|
429c34ca8b | ||
|
4e146d0e54 | ||
|
574f11b552 | ||
|
60a37af0e0 | ||
|
e1ed3bf222 | ||
|
2ffad1b6bb | ||
|
015bda764a | ||
|
60d314b165 | ||
|
a1b0eb7df1 | ||
|
39c62e684e | ||
|
d9f5ef138c | ||
|
a7a9ee7205 | ||
|
a8fe66550b | ||
|
379c825408 | ||
|
367d1672c5 | ||
|
43f6bdf4ed | ||
|
7ab0651e4d | ||
|
81b6137d8a | ||
|
c50b3cfddc | ||
|
bdf32a7174 | ||
|
23a718d8bc | ||
|
0b4e946c82 | ||
|
fea0d08f50 | ||
|
7ae0798364 | ||
|
d7ff697aa6 | ||
|
50aecffe4c | ||
|
ad4da5f37d | ||
|
dc3faeeead | ||
|
8192fab1b8 | ||
|
4bbce7cb9f | ||
|
c3b7657433 | ||
|
df8c258c84 | ||
|
8380a674b9 | ||
|
6875cc33b4 | ||
|
8ad0ec2518 | ||
|
146cd6d3a6 | ||
|
948d596efa | ||
|
4831183207 | ||
|
9f2261ae95 | ||
|
0defa94c6e | ||
|
108907d4f1 | ||
|
ccb2e899b3 | ||
|
0b5115fc8a | ||
|
7109d33e4e | ||
|
02a575a9d6 | ||
|
438fdebc5c | ||
|
0a79bde610 | ||
|
f32b6b6989 | ||
|
9d765e91c6 | ||
|
8e07ee697c | ||
|
ff6e941958 | ||
|
1f12d50aaf | ||
|
d3ee6d9498 | ||
|
2b985a0a91 | ||
|
a3c22325b8 | ||
|
6cb038535e | ||
|
2ea5290ea0 | ||
|
a2a8908e70 | ||
|
2742cbe120 | ||
|
41aa869c33 | ||
|
f9db43a2e9 | ||
|
c0fd71dda6 | ||
|
5459130111 | ||
|
a7defbfc40 | ||
|
d8c2cd449e | ||
|
03959ffcc8 | ||
|
277e56ea44 | ||
|
f4b1ea8a90 | ||
|
da9178096b | ||
|
450984abf3 | ||
|
34dfd83056 | ||
|
a7445011a9 | ||
|
0e9d5ce08c | ||
|
793dc20722 | ||
|
7d52326eb7 | ||
|
00c2455b07 | ||
|
7206f4cd9e | ||
|
c2e83fb3c4 | ||
|
b7b6ed2ff5 | ||
|
b32bafd149 | ||
|
d415643775 | ||
|
bc56a7abd6 | ||
|
6fbc291b19 | ||
|
d1db77e5b0 | ||
|
c61806974f | ||
|
514fa3204f | ||
|
19c71868a0 | ||
|
19ee4d46bc | ||
|
0d6c2bdb42 | ||
|
60693e8c3f | ||
|
eb6888e44c | ||
|
8906cbbb1a | ||
|
b48817fe01 | ||
|
ab83ed8f0f | ||
|
6e0d073cbf | ||
|
5f21213693 | ||
|
a29d7dc4ca | ||
|
b40849acad | ||
|
744bf01147 | ||
|
55189f1fdd | ||
|
cdc7f98150 | ||
|
1ff34fc449 | ||
|
4262882ac9 | ||
|
dfb9db34c3 | ||
|
0bd738b49f | ||
|
93a15a8284 | ||
|
756fafe263 | ||
|
b18d062d51 | ||
|
1bdd0512ae | ||
|
e8ba51f940 | ||
|
c56f5c32f1 | ||
|
ae7e0799fe | ||
|
89b18dca45 | ||
|
ab688368e1 | ||
|
ddc6e79af6 | ||
|
ad5c56c774 | ||
|
1fbbeae9b9 | ||
|
f5db0a5ab0 | ||
|
aa56f96585 | ||
|
0c8e69fb9d | ||
|
3ea6e94e83 | ||
|
52b7742a45 | ||
|
ddd03eab1d | ||
|
4c11c8324e | ||
|
3edea88b13 | ||
|
b57d30a70b | ||
|
8e3ea662e4 | ||
|
626148c117 | ||
|
7f3013f477 | ||
|
8b8a3d60ab | ||
|
68ce3a653e | ||
|
8a3c260eb9 | ||
|
30d00dbd3a | ||
|
779a6e4e35 | ||
|
da5b4c029b | ||
|
9fe721945d | ||
|
aca0572f4d | ||
|
53d130a179 | ||
|
c4af63237c | ||
|
8d6c88e377 | ||
|
5778ac0d23 | ||
|
6aaff7aa12 | ||
|
a4c08084bf | ||
|
eafa5110c0 | ||
|
43a4671c64 | ||
|
a1b17bb553 | ||
|
eb0b9f58f5 | ||
|
237d5c0c06 | ||
|
e97a3ef269 | ||
|
4120907957 | ||
|
319ec320c7 | ||
|
764fe399f3 | ||
|
05ec2fb1c7 | ||
|
25fb5acabe | ||
|
9250d5c624 | ||
|
21b6429205 | ||
|
81d27288f2 | ||
|
17339e933b | ||
|
33df061b53 | ||
|
99951efc80 | ||
|
df2b08a75a | ||
|
62b201c6f6 | ||
|
28dc768ce5 | ||
|
a6691031d5 | ||
|
7ea0200234 | ||
|
7261a074cd | ||
|
b41a39d36e | ||
|
1ff89acda3 | ||
|
59c02dfbed | ||
|
dab3515195 | ||
|
b2657e3ebd | ||
|
b622ebc172 | ||
|
deeba1b900 | ||
|
5646b8a0d9 | ||
|
8291da0bb5 | ||
|
a1a85efc75 | ||
|
4db8a9ea9a | ||
|
e3d3604afc | ||
|
79c6506c5c | ||
|
5c6cf72a4c | ||
|
14144c287c | ||
|
5536f7ad22 | ||
|
30cf5b2458 | ||
|
100e1dc28d | ||
|
5cbe8a8d78 | ||
|
2fd531e253 | ||
|
5f60c519ce | ||
|
b0fbdfb6e9 | ||
|
93dee41c11 | ||
|
c18671c91c | ||
|
a0ffdb7645 | ||
|
ec16a0c1e0 | ||
|
40f580a0b2 | ||
|
5af74a9d80 | ||
|
40a3abbee8 | ||
|
d00e5f4ddb | ||
|
a4d2e3dd9c | ||
|
75d2ef2cc1 | ||
|
f2c973096b | ||
|
2c7742e56f | ||
|
15a0521408 | ||
|
f35077afce | ||
|
7fff670683 | ||
|
375e0ec448 | ||
|
314ec99e5c | ||
|
0678a6b302 | ||
|
ff0145a129 | ||
|
7be33a9237 | ||
|
d136fdbafa | ||
|
7d533d4d4a | ||
|
153a066fbe | ||
|
2a2191049f | ||
|
1ba0173422 | ||
|
1881552348 | ||
|
568fc336e7 | ||
|
06629224c6 | ||
|
a277800868 | ||
|
7cd4380ee4 | ||
|
ae6e2647a3 | ||
|
f6998de6ec | ||
|
1a8d628be5 | ||
|
2291197277 | ||
|
d9c748d92f | ||
|
1dc24fac1b | ||
|
1edfda5417 | ||
|
e2b7f194c3 | ||
|
3fd3c53bd9 | ||
|
95f9f9c5d4 | ||
|
9b483d993b | ||
|
74892a3130 | ||
|
1632a8f364 | ||
|
ec477f0c02 | ||
|
448cd3381b | ||
|
2a52139b6a | ||
|
0cffb564ea | ||
|
e128498518 | ||
|
6fdc01201b | ||
|
3243e37fbc | ||
|
06425c4e6f | ||
|
b90f7bfce5 | ||
|
4a877ad27b | ||
|
26d7c26770 | ||
|
373fe5f510 | ||
|
c57fef7b1e | ||
|
dcdb4be10b | ||
|
74eb7c7ecd | ||
|
79f6e7c3b3 | ||
|
3ba9201663 | ||
|
c49f4dd11e | ||
|
5933cf3586 | ||
|
4f8953adde | ||
|
681176ce31 | ||
|
8cf05ee185 | ||
|
af77b55eea | ||
|
2fdfd96699 | ||
|
95524df6f4 | ||
|
699b5453fb | ||
|
f07e1b269e | ||
|
f09380af76 | ||
|
687dba8adb | ||
|
6f53d20491 | ||
|
ea594550a9 | ||
|
0dbb55cc0c | ||
|
bfe18e74a4 | ||
|
2ac9a9db29 | ||
|
918debe110 | ||
|
74d9a0d8ba | ||
|
47a66ac94b | ||
|
b82b8e10d6 | ||
|
c0c5f1dbcc | ||
|
4bcdbb78b1 | ||
|
adc165723c | ||
|
24fdad5f41 | ||
|
1a8481ca80 | ||
|
1ac858bd38 | ||
|
ec0b1373fe | ||
|
799178a16f | ||
|
fd745836a5 | ||
|
c308829977 | ||
|
4302b8f69d | ||
|
115977046d | ||
|
208aa86196 | ||
|
4795154cf7 | ||
|
489c014fe9 | ||
|
9d15120402 | ||
|
d7b87130f9 | ||
|
80ea415287 | ||
|
406a7cd4c0 | ||
|
92d6530c8f | ||
|
e3d1526b52 | ||
|
eff0a7030c | ||
|
1b7c131c37 | ||
|
bfb35e77b8 | ||
|
baf037e0c4 | ||
|
be94303bad | ||
|
91fb0579f1 | ||
|
1a42e6bf00 | ||
|
2db52c9e2d | ||
|
f6a90ad166 | ||
|
5f623f2f0e | ||
|
e27636b93d | ||
|
a5a713be8a | ||
|
35baf6f018 | ||
|
d8914c38a7 | ||
|
5da1e0fb9b | ||
|
fa4dfd680b | ||
|
71e2db773b | ||
|
e2c053f81b | ||
|
d3c8812e51 | ||
|
9cebf91e28 | ||
|
68cc033942 | ||
|
e5a557369b | ||
|
ee4c4de059 | ||
|
363b8a7bf1 | ||
|
c7870ee2d1 | ||
|
b34a3fd9a4 | ||
|
0c58783a6c | ||
|
0a3ffb0bc8 | ||
|
d03ed69b6e | ||
|
e2b754bad6 | ||
|
eea72befb1 | ||
|
47c4b8157a | ||
|
7d1bf4119a | ||
|
4283cc53a7 | ||
|
662b4f8e49 | ||
|
126d909ca7 | ||
|
87da06037f | ||
|
03d02ad405 | ||
|
67f48d5e60 | ||
|
2cb87d44e0 | ||
|
59d80c32c4 | ||
|
c6724b02d3 | ||
|
c61d34d053 | ||
|
b781c2b7b3 | ||
|
9266d6bbc5 | ||
|
247452b68a | ||
|
2e95fcc32b | ||
|
6f64bd840c | ||
|
70b8a1172f | ||
|
165f7b5684 | ||
|
e60628b51a | ||
|
513e4337eb | ||
|
290ea9f1ee | ||
|
64d26481c3 | ||
|
f7ab87ddcb | ||
|
36f9609a14 | ||
|
d8627f3768 | ||
|
d5cb08011e | ||
|
b5b0bcaf19 | ||
|
17d81099b1 | ||
|
0a6135c2cc | ||
|
cfdd276bdc | ||
|
dccde14614 | ||
|
8782d34f14 | ||
|
e51c632db6 | ||
|
26aab6c926 | ||
|
26f673f30d | ||
|
9cdacc85ec | ||
|
279c8c12e5 | ||
|
d053cc4d39 | ||
|
df691b7a13 | ||
|
fb275ec777 | ||
|
15c3c7c8ab | ||
|
7869e6e96a | ||
|
e6131d48da | ||
|
07925f113a | ||
|
3bb4e0af9f | ||
|
796b2b132d | ||
|
c09f7c341c | ||
|
7f4bc71a23 | ||
|
fbd0b96f49 | ||
|
41e2d43ecc | ||
|
6c07e8a223 | ||
|
54bd8effea | ||
|
7f5a5fecbf | ||
|
626030c42c | ||
|
0d7b8152e8 | ||
|
d8b776bedf | ||
|
9992ae3374 | ||
|
561e7c585b | ||
|
766a38e9e8 | ||
|
01ffcf63e4 | ||
|
770163f40b | ||
|
802da575a8 | ||
|
7c9fd5e611 | ||
|
5b2dba4cdf | ||
|
3f761973e0 | ||
|
2c22d98421 | ||
|
2bb00d2559 | ||
|
74ef2f6fcf | ||
|
d02d93f476 | ||
|
d37b113d0d | ||
|
5e34c9705c | ||
|
b49254aca2 | ||
|
361feb90d4 | ||
|
3c13f13ae2 | ||
|
31ed15a8f6 | ||
|
fc50ee2e2c | ||
|
6fb6b4ee6a | ||
|
4dc0f33341 | ||
|
692cb29c11 | ||
|
f6f6a7814f | ||
|
79c93ce54a | ||
|
468b2f6499 | ||
|
7fea2cfc9c | ||
|
28fe59f8c2 | ||
|
a762d47795 | ||
|
2b268fc589 | ||
|
44f3a79353 | ||
|
1619803a64 | ||
|
711a3afeee | ||
|
f0c31f75b3 | ||
|
261b74d6ad | ||
|
0e81a4679d | ||
|
349c33b478 | ||
|
1d0ca613f9 | ||
|
68165e8fa2 | ||
|
de2986a7c1 | ||
|
82b797738a | ||
|
d149ab662c | ||
|
3282994b8f | ||
|
d978322be8 | ||
|
41198e0b48 | ||
|
d36fea27ad | ||
|
3548a6caed | ||
|
5730eb1206 | ||
|
22e76cc5f2 | ||
|
e354a4af94 | ||
|
5c444b4b96 | ||
|
10a0fedd05 | ||
|
f214e6a31b | ||
|
6da7328d08 | ||
|
f5750c7ab6 | ||
|
1f347df8cf | ||
|
d0115acdf2 | ||
|
05dbcff7c3 | ||
|
923f55d532 | ||
|
8f203c7a1e | ||
|
c26fa76f53 | ||
|
9aea35799d | ||
|
f9dd704134 | ||
|
fbdfc68022 | ||
|
0a082f30d2 | ||
|
677bf7b9bf | ||
|
4a1c1636fe | ||
|
8de37d300c | ||
|
5ef347a4d9 | ||
|
0614aa2eee | ||
|
f7f679bbf9 | ||
|
58f4fbec41 | ||
|
8cad7d61eb | ||
|
97178eca46 | ||
|
32f05861e3 | ||
|
5bc6ce33be | ||
|
e80efa7604 | ||
|
ff9e37ec5f | ||
|
5b9fd4454b | ||
|
3d6b46a14b | ||
|
2a75159d2a | ||
|
1d7437d181 | ||
|
9f10a30067 | ||
|
16d46edfba | ||
|
07e1d3b902 | ||
|
c51a345689 | ||
|
4b0a71918a | ||
|
8524c76f66 | ||
|
5174e7481f | ||
|
1cc8ac7559 | ||
|
745d16b488 | ||
|
5d684b3d7d | ||
|
009970965f | ||
|
a2c80f7017 | ||
|
5a6a403cc9 | ||
|
d4c3df6a09 | ||
|
983e94473f | ||
|
9969266379 | ||
|
18fc5fc1e5 | ||
|
36b0e8f4bb | ||
|
89d4bb1ed4 | ||
|
b185140176 | ||
|
dd5cd5c686 | ||
|
65905edec9 | ||
|
0a4f0663d0 | ||
|
71b478fe98 | ||
|
f2d49ecbb9 | ||
|
06ded49131 | ||
|
de0920da53 | ||
|
4901e97f9f | ||
|
a7774c26fb | ||
|
40054902e9 | ||
|
64f18ab901 | ||
|
5c04e1100d | ||
|
34799263eb | ||
|
6c62b9feac | ||
|
259f373207 | ||
|
f35a943726 | ||
|
dbba338229 | ||
|
66704a78b3 | ||
|
32cd558dda | ||
|
28ef5572ba | ||
|
2eb0a309b5 | ||
|
850b7dc635 | ||
|
f9789e327b | ||
|
2c86f2f4b9 | ||
|
6e8ff5b9ef | ||
|
77d44c233e | ||
|
513845c289 | ||
|
5acf815b79 | ||
|
808ad0f059 | ||
|
fa2b6f07ce | ||
|
e6b486d25f | ||
|
049c131e77 | ||
|
db256f73f5 | ||
|
b220b2d2f0 | ||
|
3a68c4e636 | ||
|
e4c399a1c0 | ||
|
696690c8da | ||
|
0ba26072f7 | ||
|
6b0628a7ee | ||
|
85f5f72832 | ||
|
d4b4b07ab3 | ||
|
d1f35a15e3 | ||
|
fd3a09eee9 | ||
|
ab4f7f3e91 | ||
|
0fd5d100c9 | ||
|
e4150aa8b0 | ||
|
ceb11ae52a | ||
|
e42ea2e383 | ||
|
42c7f39e73 | ||
|
fd496dd546 | ||
|
a8769e375b | ||
|
f40c9f9a16 | ||
|
589cc53ad9 | ||
|
4e4f0501d2 | ||
|
4bb1a191cc | ||
|
c5ef92cf9c | ||
|
d0d429bd8e | ||
|
7f70445174 | ||
|
918888ffb0 | ||
|
d82dceada9 | ||
|
b9b2c4cbd7 | ||
|
654f63b894 | ||
|
c564aab48f | ||
|
683e73ceb9 | ||
|
44a11508ff | ||
|
8821c2f23f | ||
|
e3d1c6588d | ||
|
c1b47e4b23 | ||
|
e84afd9a20 | ||
|
4772178689 | ||
|
ddc6c3e1c3 | ||
|
7a479edc56 | ||
|
32f0f4bd7a | ||
|
f6991c4f57 | ||
|
95a24cd29b | ||
|
02989edb05 | ||
|
90aacefff8 | ||
|
ca5f8c941b | ||
|
4719088d39 | ||
|
545f0a3622 | ||
|
10b82ae7cc | ||
|
5b4ecfc3e4 | ||
|
b03d9030e4 | ||
|
d94ded8d94 | ||
|
75a9ce4696 | ||
|
cd794b981b | ||
|
bc2da3f66a | ||
|
a3962b7adf | ||
|
75aee2085a | ||
|
4dc6d56533 | ||
|
1c0cd2da9e | ||
|
0fa391732b | ||
|
0f8bca03b8 | ||
|
100f7716fd | ||
|
efbbe147e4 | ||
|
4493c9e9f0 | ||
|
dc1cd890ee | ||
|
72e0f5fbf5 | ||
|
823926a025 | ||
|
3c15521fc2 | ||
|
eaed0de486 | ||
|
b42dfc8300 | ||
|
eabfaca08e | ||
|
76d9d32dce | ||
|
9005f93f56 | ||
|
fb1ef71f25 | ||
|
9affcd13bc | ||
|
bb34538da0 | ||
|
989df35b05 | ||
|
0c2c86a8de | ||
|
b754635b81 | ||
|
650cf3521b | ||
|
9fdabe3582 | ||
|
11dbfea897 | ||
|
9aa382ebf5 | ||
|
885919e7d9 | ||
|
bbfda6d33b | ||
|
68777f6163 | ||
|
79e95eadf2 | ||
|
224771b34e | ||
|
80ad6418aa | ||
|
9111ebcd2b | ||
|
acbb69e5ad | ||
|
b659dde35d | ||
|
50c4580f64 | ||
|
23fcbd6c27 | ||
|
022e588c97 | ||
|
3df4a86428 | ||
|
a6e2cf47ed | ||
|
5941dd4338 | ||
|
825fd00a80 | ||
|
102d0a45c8 | ||
|
67ceaa2e43 | ||
|
57f0afbc9c | ||
|
e7bd155300 | ||
|
e684f677a6 | ||
|
2036819442 | ||
|
d2cba96e10 | ||
|
b8506e1e45 | ||
|
87d28d3fc7 | ||
|
807ea6aa70 | ||
|
1fe290fb8c | ||
|
eb426f6ee3 | ||
|
385dda9923 | ||
|
4a7c675d06 | ||
|
42bd77ec17 | ||
|
b32832e237 | ||
|
227dce0177 | ||
|
bced23052c | ||
|
45219a88c1 | ||
|
c553c0270e | ||
|
392ca4c988 | ||
|
1c432b2868 | ||
|
66f176992b | ||
|
bd1e6175af | ||
|
71c3e0c7a8 | ||
|
bf17c7de94 | ||
|
4674424764 | ||
|
2374c88e1b | ||
|
9be2f942c7 | ||
|
cb3e9973bd | ||
|
2ca702c976 | ||
|
a339b50e27 | ||
|
c9e60dc19b | ||
|
e6d04fad6d | ||
|
d94b9a0ab7 | ||
|
eb3c770612 | ||
|
1eea8fdbbf | ||
|
d346cb0a5a | ||
|
9165e6c1e2 | ||
|
eb65ce1a88 | ||
|
a572620765 | ||
|
3f570c4d3a | ||
|
28e9e38dad | ||
|
3418ac9cb9 | ||
|
62e333a0ba | ||
|
27fe9fa9db | ||
|
b2100ea853 | ||
|
671b276532 | ||
|
60a6fdb481 | ||
|
5bc4206593 | ||
|
0368759081 | ||
|
205b9ab73f | ||
|
8153a03c19 | ||
|
319b2c2411 | ||
|
5e95193ed8 | ||
|
46a3038394 | ||
|
441de984b0 | ||
|
16f98ed250 | ||
|
fef10b1638 | ||
|
0f96e2fa4d | ||
|
dea0edbdac | ||
|
673906cfd5 | ||
|
af6c3a79d5 | ||
|
5ac3662699 | ||
|
a0b2d0ef68 | ||
|
a66c377d8a | ||
|
c1dd196acd | ||
|
d9f8d1361f | ||
|
05c9e6db0c | ||
|
743deb14c9 | ||
|
b6f0b4a44f | ||
|
6e0cb2bc86 | ||
|
1749f06674 | ||
|
c3cb687db6 | ||
|
b8d1a0a9ff | ||
|
e4f8cf5fb5 | ||
|
4da6eeb746 | ||
|
8c5ad8fe4b | ||
|
afbee9d68f | ||
|
37f7f1898f | ||
|
fc673fe9c6 | ||
|
d3c0999541 | ||
|
1406cae6c5 | ||
|
12fe1b619f | ||
|
53eac84312 | ||
|
5a07bbb1e3 | ||
|
1fd0c26e1d | ||
|
f2efff64fd | ||
|
5df76b04e2 | ||
|
4b4b65d961 | ||
|
b70beac3c9 | ||
|
4b2bfd4113 | ||
|
b2ea9be73f | ||
|
1040c20330 | ||
|
a53fb162a8 | ||
|
306b21b75e | ||
|
8decffc6b5 | ||
|
57806bed45 | ||
|
487bc77baa | ||
|
9279390e8c | ||
|
9f00e5a2f7 | ||
|
8c96165fb4 | ||
|
a249167539 | ||
|
d6c595d94e | ||
|
068f23b029 | ||
|
bf6b4eda83 | ||
|
a2644fdaba | ||
|
c958186245 | ||
|
8f71a9f051 | ||
|
d82efe37b5 | ||
|
d0380f76c3 | ||
|
2dfaa22c35 | ||
|
2d12bfd1f5 | ||
|
e9a2cb92e3 | ||
|
d5d863d998 | ||
|
4946aad684 | ||
|
7d8507743d | ||
|
c34786358a | ||
|
4ddd78d40a | ||
|
3178ee9f10 | ||
|
a8f292815a | ||
|
154187f1bc | ||
|
78080df6fd | ||
|
80926c8d7e | ||
|
9e1e5cec46 | ||
|
e50ff316ba | ||
|
1348eeb4e3 | ||
|
8bfc36efbe | ||
|
a7a589b785 | ||
|
4ecb6e7bc2 | ||
|
4522362f76 | ||
|
6607455e8f | ||
|
31fd551264 | ||
|
d10e83d15c | ||
|
f29e3bc587 | ||
|
fd047f8323 | ||
|
97e486e139 | ||
|
db2c4cd6fc | ||
|
1f45618954 | ||
|
70d935d1a0 | ||
|
b78110aa1c | ||
|
41f3103a16 | ||
|
be20b5a8b4 | ||
|
8119dd4f62 | ||
|
001db9a19f | ||
|
9e11435923 | ||
|
4a924d6aa8 | ||
|
5aba0377a0 | ||
|
50d3dbe394 | ||
|
2c47407afb | ||
|
748b9afdb4 | ||
|
cc5a254e01 | ||
|
49a995afae | ||
|
6f81544ebe | ||
|
8dbdbe988f | ||
|
1283e85a8e | ||
|
f048649e58 | ||
|
78c14dd93c | ||
|
addc5af96d | ||
|
3ee502c3a4 | ||
|
4601a136a9 | ||
|
8265d0c8e4 | ||
|
6d3cb73324 | ||
|
3c2421d875 | ||
|
8d9c7acb3c | ||
|
0fe0423757 | ||
|
6ee952f3d3 | ||
|
fd4300f841 | ||
|
9fbe97bfd6 | ||
|
f9153b96eb | ||
|
9b93e3e116 | ||
|
a6c10fe49d | ||
|
51ad84e6a9 | ||
|
7519b38df5 | ||
|
a03809e68e | ||
|
fefe82fd54 | ||
|
2cdd264780 | ||
|
e2842f69c3 | ||
|
56c1476e67 | ||
|
3ffbce0bc7 | ||
|
dc126e1b58 | ||
|
ad692d4f61 | ||
|
bb8dc04954 | ||
|
5452979366 | ||
|
510ae91ac0 | ||
|
c23e192b7a | ||
|
dc535ee509 | ||
|
c3d9e8030b | ||
|
50b489478c | ||
|
0390a703af | ||
|
3410a58cd9 | ||
|
23733bd9fe | ||
|
866f54c307 | ||
|
1d9ec09d62 | ||
|
3a82a66954 | ||
|
1b19cc0cf6 | ||
|
fb29638d00 | ||
|
60a5fb96be | ||
|
180e813ac4 | ||
|
752af458a3 | ||
|
f4bfeea5a6 | ||
|
adabb9aeff | ||
|
b9c6be1676 | ||
|
f44ed87646 | ||
|
6fb9d2d157 | ||
|
8679e55206 | ||
|
baab837be4 | ||
|
f120ae9753 | ||
|
b365962bbf | ||
|
888f93281d | ||
|
abc4923059 | ||
|
780053a19e | ||
|
d035e18b9f | ||
|
405400de68 | ||
|
5d54ce3464 | ||
|
b2b82f8310 | ||
|
522a2bdab3 | ||
|
242e3384b2 | ||
|
0a865318a4 | ||
|
30fa9671c8 | ||
|
4d4247f0d8 | ||
|
e0e5ab393f | ||
|
4b207f3dd4 | ||
|
ce61112020 | ||
|
ce278fb4d0 | ||
|
42e458ad69 | ||
|
ed1b163087 | ||
|
fa6365d297 | ||
|
7832c3c581 | ||
|
a6fdb49503 | ||
|
e41dda1b68 | ||
|
2fe4c0793c | ||
|
e45748d515 | ||
|
62521e132b | ||
|
db8c3585dd | ||
|
cb32b9debf | ||
|
491fcef08b | ||
|
ca40eb9481 | ||
|
f11235aaf9 | ||
|
443e3a3c7c | ||
|
ab98d46baa | ||
|
57e335abb8 | ||
|
5f1f9c4d86 | ||
|
9c1c15465e | ||
|
36fcb02b51 | ||
|
ae2efaa4a1 | ||
|
9486c7f3df | ||
|
d52664d11c | ||
|
9b4f76d776 | ||
|
ae9d33cf37 | ||
|
8a777b5d23 | ||
|
240ccc8309 | ||
|
18b20d13be | ||
|
32d89e58ea | ||
|
a1f2d2a719 | ||
|
599dc24862 | ||
|
5faff66fab | ||
|
526fa46edf | ||
|
c61932e0e9 | ||
|
1c68ac1a3a | ||
|
0413736a29 | ||
|
ce47e69b8a | ||
|
2deffbc622 | ||
|
3318db1999 | ||
|
99cce55a8e | ||
|
fbcd3cc965 | ||
|
6a838e9d5e | ||
|
a71d2fa226 | ||
|
6e1a6d1ad6 | ||
|
6d4689e559 | ||
|
f40dc29497 | ||
|
08c70a5192 | ||
|
e4e8f04c95 | ||
|
fb3138f700 | ||
|
aeca16f663 | ||
|
7a07ee9fd9 | ||
|
9c8e835a80 | ||
|
d4ffa04bb6 | ||
|
b96cee1012 | ||
|
119a3803ec | ||
|
ebef35c28c | ||
|
d998fb235a | ||
|
38e0937f45 | ||
|
543132aafa | ||
|
945ec5604d | ||
|
f337e18515 | ||
|
0659ff6233 | ||
|
1273903b05 | ||
|
cc57d39443 | ||
|
e3a67351d5 | ||
|
03b6f6c263 | ||
|
69ee57f88f | ||
|
974b1f9152 | ||
|
8f9705c165 | ||
|
aa44077212 | ||
|
a712d92b52 | ||
|
31941110e8 | ||
|
579ffcc68d | ||
|
30aeb8d2c4 | ||
|
e776a45dfa | ||
|
de74c70778 | ||
|
85c67872a5 | ||
|
07a0518586 | ||
|
db621b8657 | ||
|
44ce51e54f | ||
|
61003b378c | ||
|
963930ea1d | ||
|
36ec8de04f | ||
|
bd0f460c56 | ||
|
69736ef5a1 | ||
|
fe4be8d5db | ||
|
82e45460fa | ||
|
93a8f99b12 | ||
|
e61877b9f9 | ||
|
2b22494f3f | ||
|
edfca7bfed | ||
|
3bf0f7e2f8 | ||
|
3e34c77625 | ||
|
8e992299c6 | ||
|
cb7f1de348 | ||
|
40075a0d39 | ||
|
1e1ff73612 | ||
|
a6f63d096e | ||
|
7339643ec3 | ||
|
8ca4253be4 | ||
|
a0c6450fc1 | ||
|
30d84d15fa | ||
|
3e9810678a | ||
|
dd05955a38 | ||
|
e50de59669 | ||
|
294917ed4d | ||
|
81c6d9912c | ||
|
1951bc89bb | ||
|
1785bac9d2 | ||
|
01e8c3b080 | ||
|
48dda41e2e | ||
|
c0c60fb7a2 | ||
|
6e142a7444 | ||
|
e905e4e079 | ||
|
489546e35c | ||
|
c723ec58ce | ||
|
f4677a7b7b | ||
|
0f3ddb9c03 | ||
|
b161d17bbf | ||
|
c1d15cfeb4 | ||
|
d6172e43d1 | ||
|
b4670f759a | ||
|
39a521fb80 | ||
|
d9e3d15098 | ||
|
e6e762505f | ||
|
e9a38c8eda | ||
|
387193d347 | ||
|
9314fa0e8a | ||
|
8622dffe1e | ||
|
a185b6b182 | ||
|
55564b543a | ||
|
43fc26619d | ||
|
a5c3c2e895 | ||
|
904e6017f2 | ||
|
a5f31162f6 | ||
|
0e61de2920 | ||
|
6704956b22 | ||
|
0de69e306d | ||
|
d4c0930723 | ||
|
0ba3cfb725 | ||
|
e32fecd1e3 | ||
|
fbd7526092 | ||
|
05d1013699 | ||
|
d263bc8e55 | ||
|
c11c100cbb | ||
|
fdcdaf3db5 | ||
|
7de3e37a51 | ||
|
536064ae9a | ||
|
f05debf686 | ||
|
3c0b14a477 | ||
|
0eaee16f7e | ||
|
f3be825d25 | ||
|
5bdaacc049 | ||
|
2760b0764b | ||
|
bf8d33a3f4 | ||
|
88885403ad | ||
|
b41cc8bca3 | ||
|
a6fbc9db11 | ||
|
f5516db8f4 | ||
|
9c3229717f | ||
|
71f3dfbffd | ||
|
a61ee5f093 | ||
|
6f0dd5e9b6 | ||
|
e6109d509b | ||
|
a60d53de29 | ||
|
189342472e | ||
|
c0a227fa39 | ||
|
362d944428 | ||
|
b762f48135 | ||
|
cbe90272b9 | ||
|
fc0b1dc739 | ||
|
c4690a839f | ||
|
9779c0439f | ||
|
56fb1c2f93 | ||
|
d72aa0fa36 | ||
|
e90de3783a | ||
|
efecfd926a | ||
|
be633bf903 | ||
|
260cbddae0 | ||
|
b995a9d316 | ||
|
bf13383c93 | ||
|
a64dc26dd7 | ||
|
39c6d897ed | ||
|
d39e9f6037 | ||
|
493c1a65c0 | ||
|
c2d68612ec | ||
|
1f0d6fb4e9 | ||
|
99512da9da | ||
|
f3cf6e1856 | ||
|
0b57fa4810 | ||
|
c31495c283 | ||
|
fad03fb7c9 | ||
|
761f6a5085 | ||
|
d660e6bd72 | ||
|
06a2a4c04d | ||
|
2e03c9c9c0 | ||
|
a603cc081b | ||
|
13d7e30a75 | ||
|
8d3fd9cc3b | ||
|
841e556f42 | ||
|
170bd0ccb1 | ||
|
5dbd2249dd | ||
|
3fd4343cfd | ||
|
05677d93b3 | ||
|
76b49af81f | ||
|
23efcb1db8 | ||
|
0d80177691 | ||
|
ff175d9af4 | ||
|
4fd25f9e1a | ||
|
77a07b7f2b | ||
|
5a489e7043 | ||
|
a58f42dee0 | ||
|
b63449f299 | ||
|
af64ec4ac0 | ||
|
fb9abee285 | ||
|
288f347e40 | ||
|
74e6ea5a56 | ||
|
95ebe96bc2 | ||
|
0e518bddcb | ||
|
fb3554a351 | ||
|
babeb695c1 | ||
|
e4de02995c | ||
|
2495ded507 | ||
|
47c6e7a52e | ||
|
6aef6cdcd7 | ||
|
ea277bcf4c | ||
|
e7175c261a | ||
|
aedb02bbb1 | ||
|
59d32e6f2f | ||
|
978e5ca9f0 | ||
|
226fc471eb | ||
|
c8c02805f4 | ||
|
326dc5fb86 | ||
|
71b2ab14a0 | ||
|
8f04e17d27 | ||
|
febaefd8dc | ||
|
3ed98cb506 | ||
|
2dda22f700 | ||
|
08fab9559c | ||
|
15c5df0e6e | ||
|
7c0d8f0841 | ||
|
7e4683d417 | ||
|
60247a6443 | ||
|
7c746ab9a3 | ||
|
80547aef70 | ||
|
3152a7ebfe | ||
|
8bff4a297e | ||
|
d2826d92f6 | ||
|
def05f2f0a | ||
|
55360c731a | ||
|
c1d1c26c23 | ||
|
8cced2da35 | ||
|
3fe3f08407 | ||
|
d97337ded7 | ||
|
4fc54450b7 | ||
|
74701810b7 | ||
|
479d95711b | ||
|
06cda0b2c1 | ||
|
a30ef3ed14 | ||
|
c1c61ed590 | ||
|
0c3b3a1631 | ||
|
828f09fdb2 | ||
|
c8b6672d79 | ||
|
607160655d | ||
|
44206ef166 | ||
|
fe3b1511f6 | ||
|
65f0a2ac3c | ||
|
62aec5c359 | ||
|
44c0f3d076 | ||
|
a7b8286e4f | ||
|
e1fae23927 | ||
|
0ed6e3d4bf | ||
|
e0ea76a940 | ||
|
8c5471092c | ||
|
78bf2c8d9b | ||
|
612b21c732 | ||
|
64cb128b06 | ||
|
5d00602ada | ||
|
e9abcc8031 | ||
|
d767ad7a8c | ||
|
786cde781d | ||
|
fc20479ab4 | ||
|
2c82cc3bbc | ||
|
7bae73bcb4 | ||
|
75da5c50ce | ||
|
6c858d6449 | ||
|
2a0ecec28e | ||
|
aa2fef7f72 | ||
|
b99391887d | ||
|
352846c8b4 | ||
|
ce8a0a2d42 | ||
|
7f37b8d1dd | ||
|
aa1ac63c1c | ||
|
eee9e30413 | ||
|
777adf1bae | ||
|
e8d0c7d039 | ||
|
f1836f399f | ||
|
4e9e4d24b1 | ||
|
24c60b7e8a | ||
|
46df47bf31 | ||
|
00ead83da9 | ||
|
8a1908b760 | ||
|
5d905c2952 | ||
|
37a62b0407 | ||
|
271aa79355 | ||
|
c50b251ae4 | ||
|
10ce4eeefa | ||
|
0ded91d987 | ||
|
9689288bdc | ||
|
09c16ac541 | ||
|
559420a461 | ||
|
9f4066faa1 | ||
|
5a9227ce8c | ||
|
15c98bac9e | ||
|
82651ed6cd | ||
|
06cc703887 | ||
|
14dbfdd915 | ||
|
9868a1819c | ||
|
fc5c00e37d | ||
|
d8ceb35cd5 | ||
|
24c513929e | ||
|
b9f6095db5 | ||
|
8ca7c36380 | ||
|
8517e392fe | ||
|
102b5e03d4 |
|
@ -1,7 +1,7 @@
|
|||
# https://github.com/eslint/eslint/blob/master/docs/rules/README.md
|
||||
|
||||
parserOptions:
|
||||
ecmaVersion: 2015
|
||||
ecmaVersion: 2017
|
||||
|
||||
env:
|
||||
browser: true
|
||||
|
@ -9,55 +9,7 @@ env:
|
|||
webextensions: true
|
||||
|
||||
globals:
|
||||
# messaging.js
|
||||
KEEP_CHANNEL_OPEN: false
|
||||
CHROME: false
|
||||
FIREFOX: false
|
||||
OPERA: false
|
||||
URLS: false
|
||||
BG: false
|
||||
notifyAllTabs: false
|
||||
queryTabs: false
|
||||
getTab: false
|
||||
getOwnTab: false
|
||||
getActiveTab: false
|
||||
getActiveTabRealURL: false
|
||||
getTabRealURL: false
|
||||
openURL: false
|
||||
activateTab: false
|
||||
stringAsRegExp: false
|
||||
ignoreChromeError: false
|
||||
tryCatch: false
|
||||
tryRegExp: false
|
||||
tryJSONparse: false
|
||||
debounce: false
|
||||
deepCopy: false
|
||||
onBackgroundReady: false
|
||||
deleteStyleSafe: false
|
||||
getStylesSafe: false
|
||||
saveStyleSafe: false
|
||||
sessionStorageHash: false
|
||||
download: false
|
||||
invokeOrPostpone: false
|
||||
# localization.js
|
||||
template: false
|
||||
t: false
|
||||
o: false
|
||||
tE: false
|
||||
tHTML: false
|
||||
tNodeList: false
|
||||
tDocLoader: false
|
||||
# dom.js
|
||||
onDOMready: false
|
||||
scrollElementIntoView: false
|
||||
enforceInputRange: false
|
||||
animateElement: false
|
||||
$: false
|
||||
$$: false
|
||||
$element: false
|
||||
# prefs.js
|
||||
prefs: false
|
||||
setupLivePrefs: false
|
||||
require: readonly # in polyfill.js
|
||||
|
||||
rules:
|
||||
accessor-pairs: [2]
|
||||
|
@ -70,19 +22,19 @@ rules:
|
|||
brace-style: [2, 1tbs, {allowSingleLine: false}]
|
||||
camelcase: [2, {properties: never}]
|
||||
class-methods-use-this: [2]
|
||||
comma-dangle: [0]
|
||||
comma-dangle: [2, {arrays: always-multiline, objects: always-multiline}]
|
||||
comma-spacing: [2, {before: false, after: true}]
|
||||
comma-style: [2, last]
|
||||
complexity: [0]
|
||||
computed-property-spacing: [2, never]
|
||||
consistent-return: [0]
|
||||
constructor-super: [2]
|
||||
curly: [2]
|
||||
curly: [2, "multi-line"]
|
||||
default-case: [0]
|
||||
dot-location: [2, property]
|
||||
dot-notation: [0]
|
||||
eol-last: [2]
|
||||
eqeqeq: [1, always]
|
||||
eqeqeq: [1, smart]
|
||||
func-call-spacing: [2, never]
|
||||
func-name-matching: [0]
|
||||
func-names: [0]
|
||||
|
@ -93,7 +45,15 @@ rules:
|
|||
id-blacklist: [0]
|
||||
id-length: [0]
|
||||
id-match: [0]
|
||||
indent-legacy: [2, 2, {VariableDeclarator: 0, SwitchCase: 1}]
|
||||
indent: [2, 2, {
|
||||
SwitchCase: 1,
|
||||
ignoreComments: true,
|
||||
ignoredNodes: [
|
||||
"TemplateLiteral > *",
|
||||
"ConditionalExpression",
|
||||
"ForStatement"
|
||||
]
|
||||
}]
|
||||
jsx-quotes: [0]
|
||||
key-spacing: [0]
|
||||
keyword-spacing: [2]
|
||||
|
@ -117,11 +77,11 @@ rules:
|
|||
no-case-declarations: [2]
|
||||
no-class-assign: [2]
|
||||
no-cond-assign: [2, except-parens]
|
||||
no-confusing-arrow: [1, {allowParens: true}]
|
||||
no-confusing-arrow: [0, {allowParens: true}]
|
||||
no-const-assign: [2]
|
||||
no-constant-condition: [0]
|
||||
no-continue: [0]
|
||||
no-control-regex: [2]
|
||||
no-control-regex: [0]
|
||||
no-debugger: [2]
|
||||
no-delete-var: [2]
|
||||
no-div-regex: [0]
|
||||
|
@ -135,9 +95,9 @@ rules:
|
|||
no-empty-function: [0]
|
||||
no-empty-pattern: [2]
|
||||
no-empty: [2, {allowEmptyCatch: true}]
|
||||
no-eq-null: [2]
|
||||
no-eq-null: [0]
|
||||
no-eval: [2]
|
||||
no-ex-assign: [2]
|
||||
no-ex-assign: [0]
|
||||
no-extend-native: [2]
|
||||
no-extra-bind: [2]
|
||||
no-extra-boolean-cast: [2]
|
||||
|
@ -187,6 +147,9 @@ rules:
|
|||
no-proto: [2]
|
||||
no-redeclare: [2]
|
||||
no-regex-spaces: [2]
|
||||
no-restricted-globals: [2, name, event]
|
||||
# `name` and `event` (in Chrome) are built-in globals
|
||||
# but we don't use these globals so it's most likely a mistake/typo
|
||||
no-restricted-imports: [0]
|
||||
no-restricted-modules: [2, domain, freelist, smalloc, sys]
|
||||
no-restricted-syntax: [2, WithStatement]
|
||||
|
@ -207,17 +170,16 @@ rules:
|
|||
no-trailing-spaces: [2]
|
||||
no-undef-init: [2]
|
||||
no-undef: [2]
|
||||
no-undefined: [0]
|
||||
no-underscore-dangle: [0]
|
||||
no-unexpected-multiline: [2]
|
||||
no-unmodified-loop-condition: [1]
|
||||
no-unmodified-loop-condition: [0]
|
||||
no-unneeded-ternary: [2]
|
||||
no-unreachable: [2]
|
||||
no-unsafe-finally: [2]
|
||||
no-unsafe-negation: [2]
|
||||
no-unused-expressions: [1]
|
||||
no-unused-expressions: [2]
|
||||
no-unused-labels: [0]
|
||||
no-unused-vars: [1, {args: after-used, vars: local, argsIgnorePattern: ^_}]
|
||||
no-unused-vars: [2, {args: after-used}]
|
||||
no-use-before-define: [2, nofunc]
|
||||
no-useless-call: [2]
|
||||
no-useless-computed-key: [2]
|
||||
|
@ -232,16 +194,16 @@ rules:
|
|||
object-curly-spacing: [2, never]
|
||||
object-shorthand: [0]
|
||||
one-var-declaration-per-line: [1]
|
||||
one-var: [0]
|
||||
one-var: [2, {initialized: never}]
|
||||
operator-assignment: [2, always]
|
||||
operator-linebreak: [2, after, overrides: {"?": ignore, ":": ignore, "&&": ignore, "||": ignore}]
|
||||
padded-blocks: [2, never]
|
||||
padded-blocks: [0]
|
||||
prefer-numeric-literals: [2]
|
||||
prefer-rest-params: [0]
|
||||
prefer-const: [1, {destructuring: any, ignoreReadBeforeAssign: true}]
|
||||
prefer-const: [1, {destructuring: all, ignoreReadBeforeAssign: true}]
|
||||
quote-props: [0]
|
||||
quotes: [1, single, avoid-escape]
|
||||
radix: [2, as-needed]
|
||||
radix: [2, always]
|
||||
require-jsdoc: [0]
|
||||
require-yield: [2]
|
||||
semi-spacing: [2, {before: false, after: true}]
|
||||
|
@ -263,3 +225,16 @@ rules:
|
|||
wrap-iife: [2, inside]
|
||||
yield-star-spacing: [2, {before: true, after: false}]
|
||||
yoda: [2, never]
|
||||
|
||||
overrides:
|
||||
- files: [tools/*]
|
||||
env:
|
||||
node: true
|
||||
browser: false
|
||||
webextensions: false
|
||||
parserOptions:
|
||||
ecmaVersion: 2017
|
||||
|
||||
- files: ["**/*worker*.js"]
|
||||
env:
|
||||
worker: true
|
2
.gitattributes
vendored
Normal file
2
.gitattributes
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
# Auto detect text files and perform LF normalization
|
||||
* text=auto
|
43
.github/CONTRIBUTING.md
vendored
43
.github/CONTRIBUTING.md
vendored
|
@ -1,33 +1,46 @@
|
|||
# Contributing to Stylus
|
||||
|
||||
1. [Getting Involved](#getting-involved)
|
||||
2. [How to Report Issues](#how-to-report-issues)
|
||||
3. [Adding Tranlations](#adding-translations)
|
||||
4. [Core Style Guide](#core-style-guide)
|
||||
5. [Getting Started](#getting-started)
|
||||
1. [Getting involved](#getting-involved)
|
||||
2. [How to report issues](#how-to-report-issues)
|
||||
3. [Adding translations](#adding-translations)
|
||||
4. [Pull requests](#pull-requests)
|
||||
5. [Scripts](#scripts)
|
||||
6. [Updating locale files](#updating-locale-files-admin-only)
|
||||
7. [Contact us](#contact-us)
|
||||
|
||||
## Getting Involved
|
||||
## Getting involved
|
||||
|
||||
There are a number of ways to get involved with the development of Stylus. Even if you've never contributed to an Open Source project before, we're always looking for help by identifying issues and suggesting improvements.
|
||||
|
||||
## How to Report issues
|
||||
## How to report issues
|
||||
|
||||
When an issue is opened, a template is provided. Please answer these questions as thoroughly as possible. If we were psychic, we'd be hanging out in casinos playing poker until they kicked us out. We can't read your mind! Please provide step-by-step direction on how to reproduce the issue as well as the browser, operating system and versions of each.
|
||||
When an [**issue**](https://github.com/openstyles/stylus/issues) is opened, a template is provided. Please answer these questions as thoroughly as possible. If we were psychic, we'd be hanging out in casinos playing poker until they kicked us out. We can't read your mind! Please provide step-by-step directions on how to reproduce the issue as well as the versions of your operating system, browser and Stylus.
|
||||
|
||||
When adding a feature request, please include
|
||||
When adding a **feature request**, please search through the existing issues to see if it the feature has already been requested, added or rejected.
|
||||
|
||||
## Adding Translations
|
||||
If not, then provide details describing which page the feature will effect, e.g. popup, manager or editor. Then describe the request and explain how you think it would benefit the user experience.
|
||||
|
||||
You can help us translate the extension on [Transifex](https://www.transifex.com/github-7/Stylus). When `messages.json` file is ready to be merged, please open a new bug report in [stylus/issues](https://github.com/openstyles/stylus/issues).
|
||||
|
||||
## Core Style Guide
|
||||
## Adding translations
|
||||
|
||||
* Use the provided `.editorconfig` file with your code editor. Don't know what that is? Then check out http://editorconfig.org/.
|
||||
You can help us translate the extension on [Transifex](https://www.transifex.com/github-7/Stylus).
|
||||
Only the languages supported by the web store are allowed:
|
||||
https://developer.chrome.com/docs/webstore/i18n/#localeTable
|
||||
|
||||
## Getting Started
|
||||
|
||||
## Pull requests
|
||||
|
||||
* First open an issue to discuss your changes.
|
||||
* Then download, fork or clone this repository.
|
||||
<!-- * Use [node.js](http://nodejs.org/) to run `npm install`. -->
|
||||
<!-- * Use [node.js](https://nodejs.org/) to run `npm install`. -->
|
||||
* Use the provided `.editorconfig` file with your code editor. Don't know what that is? Then check out https://editorconfig.org/.
|
||||
* Make any changes within a branch of this repository (not the `master` branch).
|
||||
* Submit a pull request and include a reference to the initial issue with the discussion.
|
||||
|
||||
## Build scripts
|
||||
|
||||
See [BUILD.md](../BUILD.md) for more information.
|
||||
|
||||
## Contact us
|
||||
|
||||
If you prefer a more informal method of getting in touch or starting a conversation, please [join us on Discord](https://discordapp.com/widget?id=379521691774353408) or leave a comment in the [discussion section](https://add0n.com/stylus.html#reviews). We will monitor any discussions there and join in, and it may be a more appropriate venue for opinions and less urgent suggestions.
|
||||
|
|
8
.github/ISSUE_TEMPLATE.md
vendored
8
.github/ISSUE_TEMPLATE.md
vendored
|
@ -1,8 +0,0 @@
|
|||
* **Browser**:
|
||||
* **Operating System**:
|
||||
* **Screenshot**:
|
||||
|
||||
<!--
|
||||
Please make sure you checked that your issue wasn't already addressed.
|
||||
If the issue persists, please help us identifying the cause by providing the above details.
|
||||
-->
|
48
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
48
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
|
@ -0,0 +1,48 @@
|
|||
---
|
||||
name: Bug Report
|
||||
about: Create a report about a bug you experienced while using Stylus.
|
||||
title: "[Bug] Replace with title"
|
||||
assignees: ''
|
||||
---
|
||||
|
||||
<!--
|
||||
⚠⚠ Do not delete this issue template! ⚠⚠
|
||||
Reported issues must use this template and have all the necessary information provided.
|
||||
Incomplete reports are likely to be ignored and closed.
|
||||
-->
|
||||
|
||||
<!--
|
||||
Thank you for taking the time to create a report about a bug.
|
||||
Ensure that there are no other existing reports for this bug.
|
||||
Please check if the issue is resolved after a restart of the browser.
|
||||
Additionally, you should check if the issue persists in a new browser profile.
|
||||
Remember to fill out every section on this report and remove any that are not needed.
|
||||
Finally, place a brief description in the title of this report.
|
||||
-->
|
||||
|
||||
# Bug Report
|
||||
|
||||
### Bug Description
|
||||
<!-- Provide a clear and concise description, which will allow us to properly troubleshoot this bug. -->
|
||||
|
||||
### Screenshots
|
||||
<!-- If applicable, add screenshots to help explain this bug. -->
|
||||
|
||||
### CSS Code
|
||||
<!--
|
||||
If the bug is related to (user)CSS or the editor,
|
||||
please post the code (with a service like pastebin) in this bug report.
|
||||
-->
|
||||
|
||||
### System Information
|
||||
<!--
|
||||
Specify the browser name and version as well as the Stylus version you are using.
|
||||
Please do an online search for help if you are not familiar with how to get this information.
|
||||
-->
|
||||
|
||||
- OS: <!-- e.g. Windows, macOS, Linux -->
|
||||
- Browser: <!-- e.g. Chrome 91, Firefox 90, Edge 91, Safari 14 -->
|
||||
- Stylus Version: <!-- e.g. 1.5.21 -->
|
||||
|
||||
### Additional Context
|
||||
<!-- Provide any additional information about this bug. -->
|
14
.github/workflows/ci.yml
vendored
Normal file
14
.github/workflows/ci.yml
vendored
Normal file
|
@ -0,0 +1,14 @@
|
|||
name: ci
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: '14'
|
||||
- run: npm install
|
||||
- run: npm test
|
8
.gitignore
vendored
8
.gitignore
vendored
|
@ -1,2 +1,8 @@
|
|||
*.zip
|
||||
.DS_Store
|
||||
pull_locales_login.rb
|
||||
.eslintcache
|
||||
.transifexrc
|
||||
.vscode
|
||||
desktop.ini
|
||||
node_modules/
|
||||
yarn.lock
|
||||
|
|
10
.tx/config
Normal file
10
.tx/config
Normal file
|
@ -0,0 +1,10 @@
|
|||
[main]
|
||||
host = https://www.transifex.com
|
||||
|
||||
[Stylus.messages]
|
||||
file_filter = _locales/<lang>/messages.json
|
||||
minimum_perc = 0
|
||||
source_file = _locales/en/messages.json
|
||||
source_lang = en_US
|
||||
type = CHROME
|
||||
|
70
BUILD.md
Normal file
70
BUILD.md
Normal file
|
@ -0,0 +1,70 @@
|
|||
# Build this project
|
||||
|
||||
## Preparation
|
||||
|
||||
1. Install [Node.js](https://nodejs.org/en/).
|
||||
2. Go to the project root, run `npm install`. This will install all required dependencies.
|
||||
|
||||
Extra preparations are needed if you want to pull locale files from Transifex:
|
||||
|
||||
1. Install Transifex client. Follow the instructions on [this page](https://docs.transifex.com/client/installing-the-client).
|
||||
2. You need a `.transifexrc` file in the root folder. Contact another admin if you need one. It includes the API key to use Transifex's API.
|
||||
|
||||
## Generate the ZIP release
|
||||
|
||||
Use the following command to generate a ZIP file that can be submitted to AMO or CWS:
|
||||
|
||||
```
|
||||
npm run zip
|
||||
```
|
||||
|
||||
The zip file includes all the files from the repository **except**:
|
||||
|
||||
* All dot files (e.g. `.eslintrc` & `.gitignore`).
|
||||
* `node_modules` folder.
|
||||
* `tools` folder.
|
||||
* `package.json` file.
|
||||
* `package-lock.json` and/or `yarn.lock` file(s).
|
||||
|
||||
<!-- FIXME: is this statement still true?
|
||||
* `vendor/codemirror/lib` files. This path is excluded because it contains a file modified for development purposes only. Instead, the CodeMirror files are copied directly from `node_modules/codemirror/lib`.
|
||||
-->
|
||||
|
||||
## Tag a release/Bump the version
|
||||
|
||||
Use the `npm version (major | minor | patch)` command to tag a release.
|
||||
|
||||
There are some scripts that will run automatically before/after tagging a version. Includes:
|
||||
|
||||
1. Test.
|
||||
2. Update version number in `manifest.json`.
|
||||
3. Generate the ZIP file.
|
||||
4. Push the tag to github.
|
||||
|
||||
## Translation
|
||||
|
||||
We host locale files (`message.json`) on Transifex. All the files exist in our GitHub repository, but if you need to update the locale files, you will need to install the [Transifex client](https://docs.transifex.com/client/installing-the-client)
|
||||
|
||||
To pull files from Transifex, run
|
||||
|
||||
```
|
||||
npm run update-locales
|
||||
```
|
||||
|
||||
To push files to Transifex:
|
||||
|
||||
```
|
||||
npm run update-transifex
|
||||
```
|
||||
|
||||
## 3rd-party libraries
|
||||
|
||||
3rd-party libraries are managed by `npm`. Since Stylus is built with vanilla JS, we only use libraries that can run in the browser.
|
||||
|
||||
We keep a copy of these libraries inside the `vendor` directory so users can side-load this repository without executing the build script. These files are downloaded from CDN or pulled from npm (`node_modules`).
|
||||
|
||||
To add/update a library to the latest version, run `npm install PACKAGE_NAME@latest`.
|
||||
|
||||
To remove a library, run `npm uninstall PACKAGE_NAME`.
|
||||
|
||||
After the (un)installation, specify files which should be copied in `tools/build-vendor.js` and run `npm run build-vendor` to rebuild the vendor folder.
|
50
README.md
50
README.md
|
@ -1,34 +1,58 @@
|
|||
# Stylus
|
||||
|
||||
Stylus is a fork of Stylish for Chrome, also compatible with Firefox as a WebExtension
|
||||
|
||||
## Highlights
|
||||
|
||||
* In addition to the userstyles.org site, styles with customizable parameters can also be installed from .user.css or .user.styl URLs (see [Usercss format wiki](https://github.com/openstyles/stylus/wiki/Usercss)).
|
||||
* Site styles can be discovered and previewed in the popup using inline search with screenshot thumbnails.
|
||||
* A backup feature which is compatible with other userstyles managers.
|
||||
* Configurable automatic update function for installed styles.
|
||||
* Customizable UI, optional layouts, and tweaks.
|
||||
* Two different optional code validators with user-configurable rules: CSSLint and Stylelint.
|
||||
* Both validators use Web Worker API to run in a separate background thread inside the editor tab without blocking your interaction with the code.
|
||||
* CSSLint is heavily modified compared to the effectively frozen original one and supports various CSS3 features as well as CSS4 Color and CSS Grid syntax.
|
||||
|
||||
## Releases
|
||||
|
||||
1. [Chrome Web Store](https://chrome.google.com/webstore/detail/stylus/clngdbkpkpeebahjckkjfobafhncgmne)
|
||||
2. [Opera add-ons](https://addons.opera.com/extensions/details/stylus/)
|
||||
3. [Firefox add-ons](https://addons.mozilla.org/firefox/addon/styl-us/)
|
||||
1. [Chrome Web Store](https://chrome.google.com/webstore/detail/stylus/clngdbkpkpeebahjckkjfobafhncgmne) (or [beta](https://chrome.google.com/webstore/detail/stylus-beta/apmmpaebfobifelkijhaljbmpcgbjbdo))
|
||||
2. [Firefox add-ons](https://addons.mozilla.org/firefox/addon/styl-us/)
|
||||
3. [Opera add-ons](https://addons.opera.com/extensions/details/stylus/) (see [wiki](https://github.com/openstyles/stylus/wiki/Opera,-Outdated-Stylus) for more recent version)
|
||||
|
||||
## Screen shot
|
||||
## Screenshots
|
||||
|
||||
![screen shot](https://cloud.githubusercontent.com/assets/11704051/24002324/aefd19fe-0a75-11e7-8160-d8731d2a6d03.png)
|
||||
Manager | Editor | Popup search | Popup config | Manager config | Options
|
||||
-|-|-|-|-|-
|
||||
![Style manager](https://user-images.githubusercontent.com/1310400/34453460-214eaa5c-ed67-11e7-843b-d8960b71db6e.png) | ![Style editor](https://user-images.githubusercontent.com/1310400/34459585-3932cd94-ee05-11e7-9a1b-679522dddfb3.png) | ![Popup inline search](https://user-images.githubusercontent.com/1310400/34453463-21a44368-ed67-11e7-93b2-e1c8f5aac868.png) | ![Popup config for usercss](https://user-images.githubusercontent.com/1310400/34453462-218a589a-ed67-11e7-9040-7d0469eeadc3.png) | ![Style manager config for usercss](https://user-images.githubusercontent.com/1310400/34453464-21bdaf9c-ed67-11e7-8517-62d2f02e1918.png) | ![Options](https://user-images.githubusercontent.com/1310400/34453461-216aee4c-ed67-11e7-92db-ea21c1da5826.png)
|
||||
|
||||
## Help
|
||||
|
||||
See the [help docs](http://userstyles.org/help/stylish_chrome) or [ask in userstyles.org forum](https://forum.userstyles.org). For Stylus specific questions and suggestions please use [review section](http://add0n.com/stylus.html#reviews) of the FAQs page.
|
||||
* [Stylus help and FAQ in our Wiki](https://github.com/openstyles/stylus/wiki)
|
||||
* [Discussion section](https://add0n.com/stylus.html#reviews) of our representation on add0n.com
|
||||
* Discord: [![Discord][chat-image]][chat-link]
|
||||
|
||||
[chat-image]: https://img.shields.io/discord/379521691774353408.svg
|
||||
[chat-link]: https://discordapp.com/widget?id=379521691774353408
|
||||
|
||||
## Contributing
|
||||
|
||||
The source is hosted on [GitHub](https://github.com/openstyles/stylus) and pull requests are welcome.
|
||||
|
||||
You can help us translate the extension on [Transifex](https://www.transifex.com/github-7/Stylus). When `messages.json` file is ready to be merged, please open a new bug report in [stylus/issues](https://github.com/openstyles/stylus/issues).
|
||||
You can help us translate the extension on [Transifex](https://www.transifex.com/github-7/Stylus).
|
||||
|
||||
See our [contributing](./.github/CONTRIBUTING.md) page for more details.
|
||||
|
||||
## License
|
||||
|
||||
For copyright status of the "codemirror" directory, see [codemirror/LICENSE](https://github.com/openstyles/stylus/blob/master/src/vendor/codemirror/LICENSE). Everything else is:
|
||||
Inherited code from the original [Stylish](https://github.com/stylish-userstyles/stylish/):
|
||||
|
||||
Copyright (C) 2005-2014 Jason Barnabe <jason.barnabe@gmail.com>
|
||||
Copyright © 2005-2014 [Jason Barnabe](jason.barnabe@gmail.com)
|
||||
|
||||
Copyright (C) 2017 Stylus Team
|
||||
Current Stylus:
|
||||
|
||||
Copyright © 2017-2022 [Stylus Team](https://github.com/openstyles/stylus/graphs/contributors)
|
||||
|
||||
**[GNU GPLv3](./LICENSE)**
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
@ -41,4 +65,8 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
### External libraries
|
||||
|
||||
The licenses of [external libraries](./vendor) used in this project or [modified versions of external libraries](./vendor-overwrites) can be found in their respective directory.
|
||||
|
|
|
@ -1,210 +1,178 @@
|
|||
{
|
||||
"appliesToEverything": {
|
||||
"message": "كل شيء",
|
||||
"description": "Text displayed for styles that apply to all sites"
|
||||
},
|
||||
"enableStyleLabel": {
|
||||
"message": "تمكين",
|
||||
"description": "Label for the button to enable a style"
|
||||
},
|
||||
"styleMissingName": {
|
||||
"message": "أدخل اسمًا.",
|
||||
"description": "Error displayed when user saves without providing a name"
|
||||
},
|
||||
"appliesDomainOption": {
|
||||
"message": "عناوين URL في النطاق",
|
||||
"description": "Option to make the style apply to the entered string as a domain"
|
||||
},
|
||||
"checkForUpdate": {
|
||||
"message": "البحث عن تحديث",
|
||||
"description": "Label for the button to check a single style for an update"
|
||||
},
|
||||
"helpAlt": {
|
||||
"message": "مساعدة",
|
||||
"description": "Alternate text for help buttons"
|
||||
},
|
||||
"findStylesForSite": {
|
||||
"message": "البحث عن المزيد من الأنماط لموقع الويب هذا",
|
||||
"description": "Text for a link that gets a list of styles for the current site"
|
||||
},
|
||||
"manageHeading": {
|
||||
"message": "الأنماط المثبتة",
|
||||
"description": "Heading for the manage page"
|
||||
},
|
||||
"styleEnabledLabel": {
|
||||
"message": "ممكّن",
|
||||
"description": "Label for the enabled state of styles"
|
||||
},
|
||||
"styleToMozillaFormatHelp": {
|
||||
"message": "يمكن استخدام تنسيق موزيلا للرمز باستخدام Stylus للمتصفح فايرفوكس ويمكن إرساله إلى userstyles.org.",
|
||||
"description": "Help info for the Mozilla format header section that converts the code to/from Mozilla format"
|
||||
},
|
||||
"sectionAdd": {
|
||||
"message": "إضافة قسم آخر",
|
||||
"description": "Label for the button to add a section"
|
||||
},
|
||||
"styleSaveLabel": {
|
||||
"message": "حفظ",
|
||||
"description": "Label for save button for style editing"
|
||||
},
|
||||
"appliesAdd": {
|
||||
"message": "إضافة",
|
||||
"description": "Label for the button to add an 'applies' entry"
|
||||
},
|
||||
"appliesRegexpOption": {
|
||||
"message": "عناوين URL التي تطابق regexp",
|
||||
"description": "Option to make the style apply to the entered string as a regular expression"
|
||||
},
|
||||
"styleInstall": {
|
||||
"message": "هل تريد تثبيت '$stylename$' في Stylus؟",
|
||||
"description": "Confirmation when installing a style",
|
||||
"placeholders": {
|
||||
"stylename": {
|
||||
"content": "$1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"disableStyleLabel": {
|
||||
"message": "تعطيل",
|
||||
"description": "Label for the button to disable a style"
|
||||
},
|
||||
"styleCancelEditLabel": {
|
||||
"message": "رجوع للإدارة",
|
||||
"description": "Label for cancel button for style editing"
|
||||
},
|
||||
"styleChangesNotSaved": {
|
||||
"message": "لقد أجريت تغييرات على هذا النمط بدون حفظها.",
|
||||
"description": "Text for the prompt when changes are made to a style and the user tries to leave without saving"
|
||||
},
|
||||
"updateCheckFailServerUnreachable": {
|
||||
"message": "أخفق التحديث - الخادم يتعذر الوصول إليه.",
|
||||
"description": "Text that displays when an update check failed because the update server is unreachable"
|
||||
},
|
||||
"deleteStyleConfirm": {
|
||||
"message": "هل تريد بالتأكيد حذف هذا النمط؟",
|
||||
"description": "Confirmation before deleting a style"
|
||||
},
|
||||
"appliesDisplay": {
|
||||
"message": "ينطبق على: $applies$",
|
||||
"description": "Text on the manage screen to describe what the style applies to",
|
||||
"placeholders": {
|
||||
"applies": {
|
||||
"content": "$1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"styleSectionsTitle": {
|
||||
"message": "الأقسام",
|
||||
"description": "Title for the style sections section"
|
||||
},
|
||||
"editStyleTitle": {
|
||||
"message": "تعديل النمط $stylename$",
|
||||
"description": "Title of the page for editing styles",
|
||||
"placeholders": {
|
||||
"stylename": {
|
||||
"content": "$1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"updateCheckSucceededNoUpdate": {
|
||||
"message": "النمط محدّث.",
|
||||
"description": "Text that displays when an update check completed and no update is available"
|
||||
},
|
||||
"appliesUrlPrefixOption": {
|
||||
"message": "عناوين URL البادئة بـ",
|
||||
"description": "Option to make the style apply to the entered string as a URL prefix"
|
||||
},
|
||||
"sectionHelp": {
|
||||
"message": "تتيح لك الأقسام تحديد أجزاء مختلفة من الرمز لتطبيقها على مجموعات مختلفة من عناوين URL بالنمط نفسه. فعلى سبيل المثال، يمكن لنمط مفرد تغيير الصفحة الرئيسية لموقع ويب بطريقة، مع تغيير بقية أجزاء موقع الويب بطريقة أخرى.",
|
||||
"description": "Help text for sections"
|
||||
},
|
||||
"noStylesForSite": {
|
||||
"message": "لم يتم تثبيت أي أنماط لموقع الويب هذا.",
|
||||
"description": "Text displayed when no styles are installed for the current site"
|
||||
},
|
||||
"appliesDisplayTruncatedSuffix": {
|
||||
"message": "والمزيد",
|
||||
"description": "Text added to appliesDisplay when there are more sites for the style than are displayed"
|
||||
},
|
||||
"appliesRemove": {
|
||||
"message": "إزالة",
|
||||
"description": "Label for the button to remove an 'applies' entry"
|
||||
},
|
||||
"appliesLabel": {
|
||||
"message": "ينطبق على",
|
||||
"description": "Label for 'applies to' fields on the edit/add screen"
|
||||
},
|
||||
"openManage": {
|
||||
"message": "إدارة الأنماط المثبتة",
|
||||
"description": "Link to open the manage page."
|
||||
},
|
||||
"updateCheckFailBadResponseCode": {
|
||||
"message": "أخفق التحديث - استجاب الخادم بالرمز $code$",
|
||||
"description": "Text that displays when an update check failed because the response code indicates an error",
|
||||
"placeholders": {
|
||||
"code": {
|
||||
"content": "$1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"appliesSpecify": {
|
||||
"message": "تحديد",
|
||||
"description": "Label for the button to make a style apply only to specific sites"
|
||||
},
|
||||
"installUpdate": {
|
||||
"message": "تثبيت التحديث",
|
||||
"description": "Label for the button to install an update for a single style"
|
||||
},
|
||||
"sectionRemove": {
|
||||
"message": "إزالة القسم",
|
||||
"description": "Label for the button to remove a section"
|
||||
},
|
||||
"updateCompleted": {
|
||||
"message": "اكتمل التحديث.",
|
||||
"description": "Text that displays when an update completed"
|
||||
},
|
||||
"checkingForUpdate": {
|
||||
"message": "جارٍ البحث...",
|
||||
"description": "Text to display when checking a style for an update"
|
||||
},
|
||||
"sectionCode": {
|
||||
"message": "الرمز",
|
||||
"description": "Label for the code for a section"
|
||||
},
|
||||
"appliesHelp": {
|
||||
"message": "استخدم عناصر تحكم 'ينطبق على' لتقييد عناوين URL التي ينطبق عليها الرمز في هذا القسم.",
|
||||
"description": "Help text for 'applies to' section"
|
||||
},
|
||||
"editStyleHeading": {
|
||||
"message": "تعديل النمط",
|
||||
"description": "Title of the page for editing styles"
|
||||
},
|
||||
"appliesUrlOption": {
|
||||
"message": "عنوان URL",
|
||||
"description": "Option to make the style apply to the entered string as a URL"
|
||||
},
|
||||
"addStyleTitle": {
|
||||
"message": "إضافة نمط",
|
||||
"description": "Title of the page for adding styles"
|
||||
},
|
||||
"checkAllUpdates": {
|
||||
"message": "البحث عن تحديثات لكل الأنماط",
|
||||
"description": "Label for the button to check all styles for updates"
|
||||
},
|
||||
"deleteStyleLabel": {
|
||||
"message": "حذف",
|
||||
"description": "Label for the button to delete a style"
|
||||
},
|
||||
"addStyleLabel": {
|
||||
"message": "كتابة نمط جديد",
|
||||
"description": "Label for the button to go to the add style page"
|
||||
},
|
||||
"editStyleLabel": {
|
||||
"message": "تعديل",
|
||||
"description": "Label for the button to go to the edit style page"
|
||||
},
|
||||
"description": {
|
||||
"message": "يمكنك تغيير نمط الويب باستخدام Stylus، وهي أداة لإدارة أنماط المستخدم. وتتيح Stylus لك بسهولة تثبيت المظاهر والأشكال الخارجية لكل من Google، وFacebook وYouTube وOrkut فضلاً عن الكثير جدًا من مواقع الويب الأخرى.",
|
||||
"description": "Extension description"
|
||||
}
|
||||
}
|
||||
"InaccessibleFileHint": {
|
||||
"message": "Stylus لا يستطيع الوصول الى بعض انواع الملفات ( ملفات pdf و json )"
|
||||
},
|
||||
"addStyleLabel": {
|
||||
"message": "كتابة نمط جديد"
|
||||
},
|
||||
"addStyleTitle": {
|
||||
"message": "إضافة نمط"
|
||||
},
|
||||
"appliesAdd": {
|
||||
"message": "إضافة"
|
||||
},
|
||||
"appliesDisplay": {
|
||||
"message": "ينطبق على: $applies$",
|
||||
"placeholders": {
|
||||
"applies": {
|
||||
"content": "$1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"appliesDisplayTruncatedSuffix": {
|
||||
"message": "و المزيد"
|
||||
},
|
||||
"appliesDomainOption": {
|
||||
"message": "عناوين URL في النطاق"
|
||||
},
|
||||
"appliesHelp": {
|
||||
"message": "استخدم عناصر تحكم 'ينطبق على' لتقييد عناوين URL التي ينطبق عليها الرمز في هذا القسم."
|
||||
},
|
||||
"appliesLabel": {
|
||||
"message": "ينطبق على"
|
||||
},
|
||||
"appliesRegexpOption": {
|
||||
"message": "عناوين URL التي تطابق regexp"
|
||||
},
|
||||
"appliesRemove": {
|
||||
"message": "إزالة"
|
||||
},
|
||||
"appliesSpecify": {
|
||||
"message": "تحديد"
|
||||
},
|
||||
"appliesToEverything": {
|
||||
"message": "كل شيء"
|
||||
},
|
||||
"appliesUrlOption": {
|
||||
"message": "عنوان URL"
|
||||
},
|
||||
"appliesUrlPrefixOption": {
|
||||
"message": "عناوين URL البادئة بـ"
|
||||
},
|
||||
"checkAllUpdates": {
|
||||
"message": "البحث عن تحديثات لكل الأنماط"
|
||||
},
|
||||
"checkForUpdate": {
|
||||
"message": "البحث عن تحديث"
|
||||
},
|
||||
"checkingForUpdate": {
|
||||
"message": "جارٍ البحث..."
|
||||
},
|
||||
"confirmDelete": {
|
||||
"message": "حذف"
|
||||
},
|
||||
"confirmSave": {
|
||||
"message": "حفظ"
|
||||
},
|
||||
"deleteStyleConfirm": {
|
||||
"message": "هل تريد بالتأكيد حذف هذا النمط؟"
|
||||
},
|
||||
"deleteStyleLabel": {
|
||||
"message": "حذف"
|
||||
},
|
||||
"description": {
|
||||
"message": "يمكنك تغيير نمط الويب باستخدام Stylus، وهي أداة لإدارة أنماط المستخدم. وتتيح Stylus لك بسهولة تثبيت المظاهر والأشكال الخارجية لكل من Google، وFacebook وYouTube وOrkut فضلاً عن الكثير جدًا من مواقع الويب الأخرى."
|
||||
},
|
||||
"disableStyleLabel": {
|
||||
"message": "تعطيل"
|
||||
},
|
||||
"editDeleteText": {
|
||||
"message": "حذف"
|
||||
},
|
||||
"editStyleHeading": {
|
||||
"message": "تعديل النمط"
|
||||
},
|
||||
"editStyleLabel": {
|
||||
"message": "تعديل"
|
||||
},
|
||||
"editStyleTitle": {
|
||||
"message": "تعديل النمط $stylename$",
|
||||
"placeholders": {
|
||||
"stylename": {
|
||||
"content": "$1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"enableStyleLabel": {
|
||||
"message": "تمكين"
|
||||
},
|
||||
"genericAdd": {
|
||||
"message": "إضافة"
|
||||
},
|
||||
"genericEnabledLabel": {
|
||||
"message": "ممكّن"
|
||||
},
|
||||
"helpAlt": {
|
||||
"message": "مساعدة"
|
||||
},
|
||||
"installUpdate": {
|
||||
"message": "تثبيت التحديث"
|
||||
},
|
||||
"manageHeading": {
|
||||
"message": "الأنماط المثبتة"
|
||||
},
|
||||
"noStylesForSite": {
|
||||
"message": "لم يتم تثبيت أي أنماط لموقع الويب هذا."
|
||||
},
|
||||
"openManage": {
|
||||
"message": "إدارة الأنماط المثبتة"
|
||||
},
|
||||
"optionsSyncUrl": {
|
||||
"message": "عنوان URL"
|
||||
},
|
||||
"sectionAdd": {
|
||||
"message": "إضافة قسم آخر"
|
||||
},
|
||||
"sectionCode": {
|
||||
"message": "الرمز"
|
||||
},
|
||||
"sectionRemove": {
|
||||
"message": "إزالة القسم"
|
||||
},
|
||||
"sections": {
|
||||
"message": "الأقسام"
|
||||
},
|
||||
"styleCancelEditLabel": {
|
||||
"message": "رجوع للإدارة"
|
||||
},
|
||||
"styleChangesNotSaved": {
|
||||
"message": "لقد أجريت تغييرات على هذا النمط بدون حفظها."
|
||||
},
|
||||
"styleEnabledLabel": {
|
||||
"message": "ممكّن"
|
||||
},
|
||||
"styleInstall": {
|
||||
"message": "هل تريد تثبيت '$stylename$' في Stylus؟",
|
||||
"placeholders": {
|
||||
"stylename": {
|
||||
"content": "$1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"styleMissingName": {
|
||||
"message": "أدخل اسمًا"
|
||||
},
|
||||
"styleSaveLabel": {
|
||||
"message": "حفظ"
|
||||
},
|
||||
"styleToMozillaFormatHelp": {
|
||||
"message": "يمكن استخدام تنسيق موزيلا للرمز باستخدام Stylus للمتصفح فايرفوكس ويمكن إرساله إلى userstyles.org."
|
||||
},
|
||||
"updateCheckFailBadResponseCode": {
|
||||
"message": "أخفق التحديث - استجاب الخادم بالرمز $code$",
|
||||
"placeholders": {
|
||||
"code": {
|
||||
"content": "$1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"updateCheckFailServerUnreachable": {
|
||||
"message": "أخفق التحديث - الخادم يتعذر الوصول إليه."
|
||||
},
|
||||
"updateCheckSucceededNoUpdate": {
|
||||
"message": "النمط محدّث."
|
||||
},
|
||||
"updateCompleted": {
|
||||
"message": "اكتمل التحديث."
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
278
_locales/bg_BG/messages.json
Normal file
278
_locales/bg_BG/messages.json
Normal file
|
@ -0,0 +1,278 @@
|
|||
{
|
||||
"addStyleLabel": {
|
||||
"message": "Напиши нов стил"
|
||||
},
|
||||
"addStyleTitle": {
|
||||
"message": "Добави стил"
|
||||
},
|
||||
"appliesAdd": {
|
||||
"message": "Добави"
|
||||
},
|
||||
"appliesDisplay": {
|
||||
"message": "Прилага се към: $applies$",
|
||||
"placeholders": {
|
||||
"applies": {
|
||||
"content": "$1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"appliesDisplayTruncatedSuffix": {
|
||||
"message": "и още"
|
||||
},
|
||||
"appliesDomainOption": {
|
||||
"message": "URLи на домейна"
|
||||
},
|
||||
"appliesHelp": {
|
||||
"message": "Използвайте \"Прилага се към\", за да ограничете адресите, за които ще работи кодът в тази секция."
|
||||
},
|
||||
"appliesLabel": {
|
||||
"message": "Прилага се към"
|
||||
},
|
||||
"appliesRegexpOption": {
|
||||
"message": "Адреси, съвпадащи с regexp"
|
||||
},
|
||||
"appliesRemove": {
|
||||
"message": "Премахни"
|
||||
},
|
||||
"appliesSpecify": {
|
||||
"message": "Уточни"
|
||||
},
|
||||
"appliesToEverything": {
|
||||
"message": "Всички"
|
||||
},
|
||||
"appliesUrlPrefixOption": {
|
||||
"message": "URL започващи с"
|
||||
},
|
||||
"applyAllUpdates": {
|
||||
"message": "Приложи всички промени"
|
||||
},
|
||||
"checkAllUpdates": {
|
||||
"message": "Провери всички стилове за обновления"
|
||||
},
|
||||
"checkForUpdate": {
|
||||
"message": "Провери за обновление"
|
||||
},
|
||||
"checkingForUpdate": {
|
||||
"message": "Проверявам..."
|
||||
},
|
||||
"cm_indentWithTabs": {
|
||||
"message": "Използвай табулация с умно отместване"
|
||||
},
|
||||
"cm_keyMap": {
|
||||
"message": "Клавишни комбинации"
|
||||
},
|
||||
"cm_lineWrapping": {
|
||||
"message": "Автоматично пренасяне"
|
||||
},
|
||||
"cm_smartIndent": {
|
||||
"message": "Използвай умно отместване"
|
||||
},
|
||||
"cm_tabSize": {
|
||||
"message": "Размер на табулацията"
|
||||
},
|
||||
"cm_theme": {
|
||||
"message": "Тема"
|
||||
},
|
||||
"confirmNo": {
|
||||
"message": "Не"
|
||||
},
|
||||
"confirmStop": {
|
||||
"message": "Спри"
|
||||
},
|
||||
"confirmYes": {
|
||||
"message": "Да"
|
||||
},
|
||||
"dbError": {
|
||||
"message": "Грешка в базата данни на Stylus. Желаеш ли да посетиш уебстраницата с възможни решения?"
|
||||
},
|
||||
"defaultTheme": {
|
||||
"message": "по подразбиране"
|
||||
},
|
||||
"deleteStyleConfirm": {
|
||||
"message": "Наистина ли искаш да изтриеш този стил?"
|
||||
},
|
||||
"deleteStyleLabel": {
|
||||
"message": "Изтрий"
|
||||
},
|
||||
"description": {
|
||||
"message": "Промени уеба със Stylus, мениджър на потребителски стилове. Stylus ти позволява лесно да инсталираш теми и скинове за много популярни сайтове."
|
||||
},
|
||||
"disableAllStyles": {
|
||||
"message": "Изключи всички стилове"
|
||||
},
|
||||
"disableStyleLabel": {
|
||||
"message": "Забрани"
|
||||
},
|
||||
"editGotoLine": {
|
||||
"message": "Иди на ред (или ред:кол)"
|
||||
},
|
||||
"editStyleHeading": {
|
||||
"message": "Промени стила"
|
||||
},
|
||||
"editStyleLabel": {
|
||||
"message": "Редактирай"
|
||||
},
|
||||
"editStyleTitle": {
|
||||
"message": "Редактирай стил $stylename$",
|
||||
"placeholders": {
|
||||
"stylename": {
|
||||
"content": "$1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"enableStyleLabel": {
|
||||
"message": "Разреши"
|
||||
},
|
||||
"exportLabel": {
|
||||
"message": "Експорт"
|
||||
},
|
||||
"helpAlt": {
|
||||
"message": "Помощ"
|
||||
},
|
||||
"helpKeyMapCommand": {
|
||||
"message": "Напиши име на команда"
|
||||
},
|
||||
"helpKeyMapHotkey": {
|
||||
"message": "Натисни клавишна комбинация"
|
||||
},
|
||||
"importAppendLabel": {
|
||||
"message": "Добави към стил"
|
||||
},
|
||||
"importAppendTooltip": {
|
||||
"message": "Добави импортирания стил към текущия"
|
||||
},
|
||||
"importLabel": {
|
||||
"message": "Импорт"
|
||||
},
|
||||
"importReplaceLabel": {
|
||||
"message": "Презапиши стила"
|
||||
},
|
||||
"importReplaceTooltip": {
|
||||
"message": "Презапишете съдържанието на текущия стил с импортирания"
|
||||
},
|
||||
"installButton": {
|
||||
"message": "Инсталирай стил"
|
||||
},
|
||||
"installButtonInstalled": {
|
||||
"message": "Стилът е инсталиран"
|
||||
},
|
||||
"installButtonReinstall": {
|
||||
"message": "Преинсталирай стила"
|
||||
},
|
||||
"installButtonUpdate": {
|
||||
"message": "Обнови стила"
|
||||
},
|
||||
"installUpdate": {
|
||||
"message": "Инсталирай обновление"
|
||||
},
|
||||
"installUpdateFrom": {
|
||||
"message": "В момента стилът се обновява от $url$",
|
||||
"placeholders": {
|
||||
"url": {
|
||||
"content": "$1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"installUpdateFromLabel": {
|
||||
"message": "Провери за обновления"
|
||||
},
|
||||
"license": {
|
||||
"message": "Лиценз"
|
||||
},
|
||||
"linkGetHelp": {
|
||||
"message": "Получете помощ"
|
||||
},
|
||||
"linkGetStyles": {
|
||||
"message": "Вземете стилове"
|
||||
},
|
||||
"linkTranslate": {
|
||||
"message": "Преведете"
|
||||
},
|
||||
"linterCSSLintIncompatible": {
|
||||
"message": "CSSLint не поддържа $preprocessorname$ preprocessor",
|
||||
"placeholders": {
|
||||
"preprocessorname": {
|
||||
"content": "$1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"linterCSSLintSettings": {
|
||||
"message": "(Укажете правилата: 0 = забранен; 1 = предупреждения; 2 = грешки)"
|
||||
},
|
||||
"linterConfigPopupTitle": {
|
||||
"message": "Настройте конфигурация за $linter$ правила",
|
||||
"placeholders": {
|
||||
"linter": {
|
||||
"content": "$1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"linterConfigTooltip": {
|
||||
"message": "Щракнете, за да конфигурирате този linter"
|
||||
},
|
||||
"linterInvalidConfigError": {
|
||||
"message": "Не е записано заради тези неправилни настройки"
|
||||
},
|
||||
"linterIssues": {
|
||||
"message": "Проблеми"
|
||||
},
|
||||
"linterIssuesHelp": {
|
||||
"message": "Тези проблеми бяха намерени от $link$:",
|
||||
"placeholders": {
|
||||
"link": {
|
||||
"content": "$1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"linterJSONError": {
|
||||
"message": "Невалиден JSON формат"
|
||||
},
|
||||
"linterResetMessage": {
|
||||
"message": "За да върнете погрешно нулиране, натиснете Ctrl-Z (или Cmd-Z) в текстовия прозорец"
|
||||
},
|
||||
"linterRulesLink": {
|
||||
"message": "Вижте пълния списък с правила"
|
||||
},
|
||||
"liveReloadError": {
|
||||
"message": "Получи се грешка докато наблюдавахме файла"
|
||||
},
|
||||
"liveReloadLabel": {
|
||||
"message": "Преглед на живо"
|
||||
},
|
||||
"manageFilters": {
|
||||
"message": "Филтри"
|
||||
},
|
||||
"manageHeading": {
|
||||
"message": "Инсталирани стилове"
|
||||
},
|
||||
"manageNewStyleAsUsercss": {
|
||||
"message": "като Потребителскиcss"
|
||||
},
|
||||
"manageNewUI": {
|
||||
"message": "Нова подредба на UI"
|
||||
},
|
||||
"manageOnlyDisabled": {
|
||||
"message": "Само забранените стилове"
|
||||
},
|
||||
"manageOnlyEnabled": {
|
||||
"message": "Само разрешените стилове"
|
||||
},
|
||||
"manageOnlyExternal": {
|
||||
"message": "Само външните стилове"
|
||||
},
|
||||
"manageOnlyLocal": {
|
||||
"message": "Само локалните стилове"
|
||||
},
|
||||
"manageOnlyLocalTooltip": {
|
||||
"message": "(стиловете не инсталирани чрез страницата на userstyles.org)"
|
||||
},
|
||||
"manageOnlyNonUsercss": {
|
||||
"message": "Само не-Потребителскитеcss стилове"
|
||||
},
|
||||
"manageOnlyUpdates": {
|
||||
"message": "Само с обновления или проблеми"
|
||||
},
|
||||
"manageOnlyUsercss": {
|
||||
"message": "Само Потребителскиcss стилове"
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
100
_locales/da/messages.json
Normal file
100
_locales/da/messages.json
Normal file
|
@ -0,0 +1,100 @@
|
|||
{
|
||||
"addStyleLabel": {
|
||||
"message": "Skriv ny stil"
|
||||
},
|
||||
"addStyleTitle": {
|
||||
"message": "Tilføj stil"
|
||||
},
|
||||
"alphaChannel": {
|
||||
"message": "Gennemsigtighed"
|
||||
},
|
||||
"appliesAdd": {
|
||||
"message": "Tilføj"
|
||||
},
|
||||
"appliesDisplay": {
|
||||
"message": "Anvendes på: $applies$",
|
||||
"placeholders": {
|
||||
"applies": {
|
||||
"content": "$1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"appliesDisplayTruncatedSuffix": {
|
||||
"message": "og mere"
|
||||
},
|
||||
"appliesDomainOption": {
|
||||
"message": "URL'er på domænet"
|
||||
},
|
||||
"appliesHelp": {
|
||||
"message": "Brug 'Anvendt på'-styring til at begrænse hvilke URL'er koden i denne sektion anvendes på."
|
||||
},
|
||||
"appliesLabel": {
|
||||
"message": "Anvendes på"
|
||||
},
|
||||
"appliesLineWidgetLabel": {
|
||||
"message": "Vis 'Anvendes på'-info"
|
||||
},
|
||||
"appliesRegexpOption": {
|
||||
"message": "URL'er der matcher regexp'en"
|
||||
},
|
||||
"appliesRemove": {
|
||||
"message": "Fjern"
|
||||
},
|
||||
"appliesRemoveError": {
|
||||
"message": "Kan ikke fjerne sidste 'Anvendes på'-optegnelse"
|
||||
},
|
||||
"appliesSpecify": {
|
||||
"message": "Specificér"
|
||||
},
|
||||
"appliesToEverything": {
|
||||
"message": "Alt"
|
||||
},
|
||||
"appliesUrlPrefixOption": {
|
||||
"message": "URL'er der starter med"
|
||||
},
|
||||
"applyAllUpdates": {
|
||||
"message": "Anvend alle opdateringer"
|
||||
},
|
||||
"author": {
|
||||
"message": "Forfatter"
|
||||
},
|
||||
"bckpInstStyles": {
|
||||
"message": "Eksportér stil"
|
||||
},
|
||||
"checkAllUpdates": {
|
||||
"message": "Tjek alle stiler for opdateringer"
|
||||
},
|
||||
"checkAllUpdatesForce": {
|
||||
"message": "Tjek igen, jeg redigerede ikke nogen stil!"
|
||||
},
|
||||
"checkForUpdate": {
|
||||
"message": "Tjek efter opdatering"
|
||||
},
|
||||
"checkingForUpdate": {
|
||||
"message": "Tjekker..."
|
||||
},
|
||||
"clickToUninstall": {
|
||||
"message": "Klik for at afinstallere"
|
||||
},
|
||||
"cm_autoCloseBrackets": {
|
||||
"message": "Luk automatisk paranteser og citationstegn"
|
||||
},
|
||||
"cm_autoCloseBracketsTooltip": {
|
||||
"message": "Tilføj automatisk et lukket par når man åbner en af ()[]{}''\"\""
|
||||
},
|
||||
"cm_autocompleteOnTyping": {
|
||||
"message": "Autoudfyld på indtastning"
|
||||
},
|
||||
"cm_colorpicker": {
|
||||
"message": "Farvevælgere for CSS-farver"
|
||||
},
|
||||
"cm_indentWithTabs": {
|
||||
"message": "Brug tabs med smart indrykning"
|
||||
},
|
||||
"cm_keyMap": {
|
||||
"message": "Tastegenveje"
|
||||
},
|
||||
"genericAdd": {
|
||||
"message": "Tilføj"
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
64
_locales/en_GB/messages.json
Normal file
64
_locales/en_GB/messages.json
Normal file
|
@ -0,0 +1,64 @@
|
|||
{
|
||||
"appliesRemoveError": {
|
||||
"message": "Cannot remove last 'applies to' entry"
|
||||
},
|
||||
"checkAllUpdatesForce": {
|
||||
"message": "Check again—I didn't edit any styles!"
|
||||
},
|
||||
"cm_autoCloseBrackets": {
|
||||
"message": "Auto-close brackets and quotes"
|
||||
},
|
||||
"cm_colorpicker": {
|
||||
"message": "Colour pickers for CSS colours"
|
||||
},
|
||||
"cm_resizeGripHint": {
|
||||
"message": "Double-click to maximise/restore the height"
|
||||
},
|
||||
"colorpickerTooltip": {
|
||||
"message": "Open colour picker"
|
||||
},
|
||||
"description": {
|
||||
"message": "Redesign the web with Stylus, a user-style manager. Stylus allows you to easily install themes and skins for many popular sites."
|
||||
},
|
||||
"editGotoLine": {
|
||||
"message": "Go to line (or line:col)"
|
||||
},
|
||||
"editStyleHeading": {
|
||||
"message": "Edit style"
|
||||
},
|
||||
"license": {
|
||||
"message": "Licence"
|
||||
},
|
||||
"manageFaviconsGray": {
|
||||
"message": "Greyed out"
|
||||
},
|
||||
"optionsBadgeDisabled": {
|
||||
"message": "Background colour when disabled"
|
||||
},
|
||||
"optionsBadgeNormal": {
|
||||
"message": "Background colour"
|
||||
},
|
||||
"optionsUpdateImportNote": {
|
||||
"message": "When importing style backups from an old version or from Stylish, do a one-time check for updates manually in the styles manager to ensure all styles are updated."
|
||||
},
|
||||
"optionsUpdateInterval": {
|
||||
"message": "Userstyle auto-update interval in hours (specify 0 to disable)"
|
||||
},
|
||||
"styleInstallFailed": {
|
||||
"message": "Failed to install userstyle\n$error$",
|
||||
"placeholders": {
|
||||
"error": {
|
||||
"content": "$1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"styleRegexpPartialExplanation": {
|
||||
"message": "This style uses partially matching regexps in violation of <a href='https://developer.mozilla.org/docs/Web/CSS/@document'>CSS4 @document specification</a> which requires a full URL match. The affected CSS sections were not applied to the page. This style was probably created in Stylish-for-Chrome, which incorrectly checks 'regexp()' rules since the very first version (known bug)."
|
||||
},
|
||||
"styleUpdateDiscardChanges": {
|
||||
"message": "The style has been changed outside the editor. Would you like to reload the style?"
|
||||
},
|
||||
"usercssConfigIncomplete": {
|
||||
"message": "The style was updated or deleted after the configuration dialogue was shown. These variables were not saved to avoid corrupting the style's metadata:"
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
1352
_locales/es_419/messages.json
Normal file
1352
_locales/es_419/messages.json
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -1,226 +1,184 @@
|
|||
{
|
||||
"appliesToEverything": {
|
||||
"message": "Kaikki",
|
||||
"description": "Text displayed for styles that apply to all sites"
|
||||
},
|
||||
"enableStyleLabel": {
|
||||
"message": "Aktivoi",
|
||||
"description": "Label for the button to enable a style"
|
||||
},
|
||||
"styleMissingName": {
|
||||
"message": "Syötä nimi.",
|
||||
"description": "Error displayed when user saves without providing a name"
|
||||
},
|
||||
"appliesDomainOption": {
|
||||
"message": "URL ositteita domainilla",
|
||||
"description": "Option to make the style apply to the entered string as a domain"
|
||||
},
|
||||
"checkForUpdate": {
|
||||
"message": "Hae päivityksiä",
|
||||
"description": "Label for the button to check a single style for an update"
|
||||
},
|
||||
"updateAllCheckSucceededNoUpdate": {
|
||||
"message": "All styles are up to date.",
|
||||
"description": "Text that displays when an update all check completed and no updates are available"
|
||||
},
|
||||
"helpAlt": {
|
||||
"message": "Apu",
|
||||
"description": "Alternate text for help buttons"
|
||||
},
|
||||
"findStylesForSite": {
|
||||
"message": "Hae lisää tyylejä tälle sivustolle",
|
||||
"description": "Text for a link that gets a list of styles for the current site"
|
||||
},
|
||||
"manageHeading": {
|
||||
"message": "Asennetut Tyylit",
|
||||
"description": "Heading for the manage page"
|
||||
},
|
||||
"styleEnabledLabel": {
|
||||
"message": "Aktivoitu",
|
||||
"description": "Label for the enabled state of styles"
|
||||
},
|
||||
"styleToMozillaFormatHelp": {
|
||||
"message": "Mozilla formaattia koodista voidaan käyttää Stylish Firefoxille ohjelmassa ja voidaan lähettää userstyles.orgiin.",
|
||||
"description": "Help info for the Mozilla format header section that converts the code to/from Mozilla format"
|
||||
},
|
||||
"sectionAdd": {
|
||||
"message": "Lisää uusi osio",
|
||||
"description": "Label for the button to add a section"
|
||||
},
|
||||
"styleSaveLabel": {
|
||||
"message": "Tallenna",
|
||||
"description": "Label for save button for style editing"
|
||||
},
|
||||
"appliesAdd": {
|
||||
"message": "Lisää",
|
||||
"description": "Label for the button to add an 'applies' entry"
|
||||
},
|
||||
"appliesRegexpOption": {
|
||||
"message": "URL ositteet jotka vastaavat regexpiä",
|
||||
"description": "Option to make the style apply to the entered string as a regular expression"
|
||||
},
|
||||
"styleInstall": {
|
||||
"message": "Asennetaanko '$stylename$' Stylusiin?",
|
||||
"description": "Confirmation when installing a style",
|
||||
"placeholders": {
|
||||
"stylename": {
|
||||
"content": "$1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"disableStyleLabel": {
|
||||
"message": "Poista Käytöstä",
|
||||
"description": "Label for the button to disable a style"
|
||||
},
|
||||
"prefShowBadge": {
|
||||
"message": "Show number of styles active for the current site on the toolbar button",
|
||||
"description": "Label for the checkbox controlling toolbar badge text."
|
||||
},
|
||||
"styleCancelEditLabel": {
|
||||
"message": "Takaisin hallintapaneeliin",
|
||||
"description": "Label for cancel button for style editing"
|
||||
},
|
||||
"styleChangesNotSaved": {
|
||||
"message": "Olet tehnyt muutoksia tähän tyyliin tallentamatta.",
|
||||
"description": "Text for the prompt when changes are made to a style and the user tries to leave without saving"
|
||||
},
|
||||
"updateCheckFailServerUnreachable": {
|
||||
"message": "Päivitys epäonnistui: ei voitu yhdistää palvelimeen.",
|
||||
"description": "Text that displays when an update check failed because the update server is unreachable"
|
||||
},
|
||||
"deleteStyleConfirm": {
|
||||
"message": "Oletko varma että haluat poistaa tämän tyylin?",
|
||||
"description": "Confirmation before deleting a style"
|
||||
},
|
||||
"styleBadRegexp": {
|
||||
"message": "Regexp ei kelpaa.",
|
||||
"description": "Validation message for a bad regexp in a style"
|
||||
},
|
||||
"appliesDisplay": {
|
||||
"message": "Kooskee: $applies$",
|
||||
"description": "Text on the manage screen to describe what the style applies to",
|
||||
"placeholders": {
|
||||
"applies": {
|
||||
"content": "$1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"styleSectionsTitle": {
|
||||
"message": "Osiot",
|
||||
"description": "Title for the style sections section"
|
||||
},
|
||||
"editStyleTitle": {
|
||||
"message": "Muokkaa Tyyliä $stylename$",
|
||||
"description": "Title of the page for editing styles",
|
||||
"placeholders": {
|
||||
"stylename": {
|
||||
"content": "$1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"updateCheckSucceededNoUpdate": {
|
||||
"message": "Tyyli on ajan tasalla.",
|
||||
"description": "Text that displays when an update check completed and no update is available"
|
||||
},
|
||||
"appliesUrlPrefixOption": {
|
||||
"message": "URL osoitteet jotka alkavat",
|
||||
"description": "Option to make the style apply to the entered string as a URL prefix"
|
||||
},
|
||||
"popupStylesFirst": {
|
||||
"message": "List styles before commands in the toolbar button menu",
|
||||
"description": "Label for the checkbox controlling section order in the popup."
|
||||
},
|
||||
"sectionHelp": {
|
||||
"message": "Osiot antavat sinun tarkentaa koodin eri osia niin että ne koskevat eri URL osoitteita samassa tyylissä. Esimerkiksi, yksi tyyli voi muokata kotisivua yhdellä tavalla kun se muokkaa koko muuta sivustoa toisella tavalla.",
|
||||
"description": "Help text for sections"
|
||||
},
|
||||
"noStylesForSite": {
|
||||
"message": "Ei asennettuja tyylejä tällä sivustolla.",
|
||||
"description": "Text displayed when no styles are installed for the current site"
|
||||
},
|
||||
"appliesDisplayTruncatedSuffix": {
|
||||
"message": "ja lisää",
|
||||
"description": "Text added to appliesDisplay when there are more sites for the style than are displayed"
|
||||
},
|
||||
"appliesRemove": {
|
||||
"message": "Poista",
|
||||
"description": "Label for the button to remove an 'applies' entry"
|
||||
},
|
||||
"manageTitle": {
|
||||
"message": "Tyylikäs",
|
||||
"description": "Title for the manage page"
|
||||
},
|
||||
"appliesLabel": {
|
||||
"message": "Koskee",
|
||||
"description": "Label for 'applies to' fields on the edit/add screen"
|
||||
},
|
||||
"openManage": {
|
||||
"message": "Hallitse asennettuja tyylejä",
|
||||
"description": "Link to open the manage page."
|
||||
},
|
||||
"updateCheckFailBadResponseCode": {
|
||||
"message": "Päivitys epäonnistui: palvelin vastasi koodilla $code$.",
|
||||
"description": "Text that displays when an update check failed because the response code indicates an error",
|
||||
"placeholders": {
|
||||
"code": {
|
||||
"content": "$1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"appliesSpecify": {
|
||||
"message": "Tarkenna",
|
||||
"description": "Label for the button to make a style apply only to specific sites"
|
||||
},
|
||||
"installUpdate": {
|
||||
"message": "Asenna päivitys",
|
||||
"description": "Label for the button to install an update for a single style"
|
||||
},
|
||||
"sectionRemove": {
|
||||
"message": "Poista osio",
|
||||
"description": "Label for the button to remove a section"
|
||||
},
|
||||
"updateCompleted": {
|
||||
"message": "Päivitys suoritettu.",
|
||||
"description": "Text that displays when an update completed"
|
||||
},
|
||||
"checkingForUpdate": {
|
||||
"message": "Tarkistetaan...",
|
||||
"description": "Text to display when checking a style for an update"
|
||||
},
|
||||
"sectionCode": {
|
||||
"message": "Koodi",
|
||||
"description": "Label for the code for a section"
|
||||
},
|
||||
"appliesHelp": {
|
||||
"message": "Käytä 'Koskee' kontrolleja rajoittaaksesi mitä URL osoitteisiin tämä osio koodista koskee.",
|
||||
"description": "Help text for 'applies to' section"
|
||||
},
|
||||
"editStyleHeading": {
|
||||
"message": "Muokkaa Tyyliä",
|
||||
"description": "Title of the page for editing styles"
|
||||
},
|
||||
"addStyleTitle": {
|
||||
"message": "Lisää Tyyli",
|
||||
"description": "Title of the page for adding styles"
|
||||
},
|
||||
"checkAllUpdates": {
|
||||
"message": "Tarkista kaikki tyylit päivityksien varalta",
|
||||
"description": "Label for the button to check all styles for updates"
|
||||
},
|
||||
"deleteStyleLabel": {
|
||||
"message": "Poista",
|
||||
"description": "Label for the button to delete a style"
|
||||
},
|
||||
"addStyleLabel": {
|
||||
"message": "Uusi Tyyli",
|
||||
"description": "Label for the button to go to the add style page"
|
||||
},
|
||||
"editStyleLabel": {
|
||||
"message": "Muokkaa",
|
||||
"description": "Label for the button to go to the edit style page"
|
||||
},
|
||||
"description": {
|
||||
"message": "Uudelleen stailaa netti Stylusillä, käyttäjän tyyli hallintapaneelilla. Stylus antaa sinun helposti asentaa teemoja ja skinejä palvelluille kuten Google, Facebook, YouTube, Orkut, ja monelle, monelle muulle sivustolle.",
|
||||
"description": "Extension description"
|
||||
}
|
||||
}
|
||||
"addStyleLabel": {
|
||||
"message": "Uusi Tyyli"
|
||||
},
|
||||
"addStyleTitle": {
|
||||
"message": "Lisää Tyyli"
|
||||
},
|
||||
"appliesAdd": {
|
||||
"message": "Lisää"
|
||||
},
|
||||
"appliesDisplay": {
|
||||
"message": "Kooskee: $applies$",
|
||||
"placeholders": {
|
||||
"applies": {
|
||||
"content": "$1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"appliesDisplayTruncatedSuffix": {
|
||||
"message": "ja lisää"
|
||||
},
|
||||
"appliesDomainOption": {
|
||||
"message": "URL ositteita domainilla"
|
||||
},
|
||||
"appliesHelp": {
|
||||
"message": "Käytä 'Koskee' kontrolleja rajoittaaksesi mitä URL osoitteisiin tämä osio koodista koskee."
|
||||
},
|
||||
"appliesLabel": {
|
||||
"message": "Koskee"
|
||||
},
|
||||
"appliesRegexpOption": {
|
||||
"message": "URL ositteet jotka vastaavat regexpiä"
|
||||
},
|
||||
"appliesRemove": {
|
||||
"message": "Poista"
|
||||
},
|
||||
"appliesSpecify": {
|
||||
"message": "Tarkenna"
|
||||
},
|
||||
"appliesToEverything": {
|
||||
"message": "Kaikki"
|
||||
},
|
||||
"appliesUrlPrefixOption": {
|
||||
"message": "URL osoitteet jotka alkavat"
|
||||
},
|
||||
"checkAllUpdates": {
|
||||
"message": "Tarkista kaikki tyylit päivityksien varalta"
|
||||
},
|
||||
"checkForUpdate": {
|
||||
"message": "Hae päivityksiä"
|
||||
},
|
||||
"checkingForUpdate": {
|
||||
"message": "Tarkistetaan..."
|
||||
},
|
||||
"confirmDelete": {
|
||||
"message": "Poista"
|
||||
},
|
||||
"confirmSave": {
|
||||
"message": "Tallenna"
|
||||
},
|
||||
"deleteStyleConfirm": {
|
||||
"message": "Oletko varma että haluat poistaa tämän tyylin?"
|
||||
},
|
||||
"deleteStyleLabel": {
|
||||
"message": "Poista"
|
||||
},
|
||||
"description": {
|
||||
"message": "Uudelleen stailaa netti Stylusillä, käyttäjän tyyli hallintapaneelilla. Stylus antaa sinun helposti asentaa teemoja ja skinejä palvelluille kuten Google, Facebook, YouTube, Orkut, ja monelle, monelle muulle sivustolle."
|
||||
},
|
||||
"disableStyleLabel": {
|
||||
"message": "Poista Käytöstä"
|
||||
},
|
||||
"editDeleteText": {
|
||||
"message": "Poista"
|
||||
},
|
||||
"editStyleHeading": {
|
||||
"message": "Muokkaa Tyyliä"
|
||||
},
|
||||
"editStyleLabel": {
|
||||
"message": "Muokkaa"
|
||||
},
|
||||
"editStyleTitle": {
|
||||
"message": "Muokkaa Tyyliä $stylename$",
|
||||
"placeholders": {
|
||||
"stylename": {
|
||||
"content": "$1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"enableStyleLabel": {
|
||||
"message": "Aktivoi"
|
||||
},
|
||||
"genericAdd": {
|
||||
"message": "Lisää"
|
||||
},
|
||||
"genericEnabledLabel": {
|
||||
"message": "Aktivoitu"
|
||||
},
|
||||
"helpAlt": {
|
||||
"message": "Apu"
|
||||
},
|
||||
"installUpdate": {
|
||||
"message": "Asenna päivitys"
|
||||
},
|
||||
"manageHeading": {
|
||||
"message": "Asennetut Tyylit"
|
||||
},
|
||||
"manageTitle": {
|
||||
"message": "Tyylikäs"
|
||||
},
|
||||
"noStylesForSite": {
|
||||
"message": "Ei asennettuja tyylejä tällä sivustolla."
|
||||
},
|
||||
"openManage": {
|
||||
"message": "Hallitse asennettuja tyylejä"
|
||||
},
|
||||
"popupStylesFirst": {
|
||||
"message": "List styles before commands in the toolbar button menu"
|
||||
},
|
||||
"prefShowBadge": {
|
||||
"message": "Show number of styles active for the current site on the toolbar button"
|
||||
},
|
||||
"sectionAdd": {
|
||||
"message": "Lisää uusi osio"
|
||||
},
|
||||
"sectionCode": {
|
||||
"message": "Koodi"
|
||||
},
|
||||
"sectionRemove": {
|
||||
"message": "Poista osio"
|
||||
},
|
||||
"sections": {
|
||||
"message": "Osiot"
|
||||
},
|
||||
"styleBadRegexp": {
|
||||
"message": "Regexp ei kelpaa."
|
||||
},
|
||||
"styleCancelEditLabel": {
|
||||
"message": "Takaisin hallintapaneeliin"
|
||||
},
|
||||
"styleChangesNotSaved": {
|
||||
"message": "Olet tehnyt muutoksia tähän tyyliin tallentamatta."
|
||||
},
|
||||
"styleEnabledLabel": {
|
||||
"message": "Aktivoitu"
|
||||
},
|
||||
"styleInstall": {
|
||||
"message": "Asennetaanko '$stylename$' Stylusiin?",
|
||||
"placeholders": {
|
||||
"stylename": {
|
||||
"content": "$1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"styleMissingName": {
|
||||
"message": "Syötä nimi"
|
||||
},
|
||||
"styleSaveLabel": {
|
||||
"message": "Tallenna"
|
||||
},
|
||||
"styleToMozillaFormatHelp": {
|
||||
"message": "Mozilla formaattia koodista voidaan käyttää Stylish Firefoxille ohjelmassa ja voidaan lähettää userstyles.orgiin."
|
||||
},
|
||||
"updateAllCheckSucceededNoUpdate": {
|
||||
"message": "All styles are up to date."
|
||||
},
|
||||
"updateCheckFailBadResponseCode": {
|
||||
"message": "Päivitys epäonnistui: palvelin vastasi koodilla $code$.",
|
||||
"placeholders": {
|
||||
"code": {
|
||||
"content": "$1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"updateCheckFailServerUnreachable": {
|
||||
"message": "Päivitys epäonnistui: ei voitu yhdistää palvelimeen."
|
||||
},
|
||||
"updateCheckSucceededNoUpdate": {
|
||||
"message": "Tyyli on ajan tasalla."
|
||||
},
|
||||
"updateCompleted": {
|
||||
"message": "Päivitys suoritettu."
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
97
_locales/fy/messages.json
Normal file
97
_locales/fy/messages.json
Normal file
|
@ -0,0 +1,97 @@
|
|||
{
|
||||
"addStyleLabel": {
|
||||
"message": "Nije styl skriuwe"
|
||||
},
|
||||
"addStyleTitle": {
|
||||
"message": "Styl tafoegje"
|
||||
},
|
||||
"appliesAdd": {
|
||||
"message": "Tafoegje"
|
||||
},
|
||||
"appliesDisplay": {
|
||||
"message": "Fan tapassing op: $applies$",
|
||||
"placeholders": {
|
||||
"applies": {
|
||||
"content": "$1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"appliesDisplayTruncatedSuffix": {
|
||||
"message": "en mear"
|
||||
},
|
||||
"appliesDomainOption": {
|
||||
"message": "URL’s op it domein"
|
||||
},
|
||||
"appliesHelp": {
|
||||
"message": "Brûk de ‘Fan tapassing op’-funksjes om de URL’s foar de koade yn dizze seksje te beheinen."
|
||||
},
|
||||
"appliesLabel": {
|
||||
"message": "Fan tapassing op"
|
||||
},
|
||||
"appliesRegexpOption": {
|
||||
"message": "URL’s oerienkommend mei de regexp"
|
||||
},
|
||||
"appliesRemove": {
|
||||
"message": "Fuortsmite"
|
||||
},
|
||||
"appliesSpecify": {
|
||||
"message": "Spesifisearje"
|
||||
},
|
||||
"appliesToEverything": {
|
||||
"message": "Alles"
|
||||
},
|
||||
"appliesUrlPrefixOption": {
|
||||
"message": "URL’s begjinnend mei"
|
||||
},
|
||||
"applyAllUpdates": {
|
||||
"message": "Alle fernijingen tapasse"
|
||||
},
|
||||
"checkAllUpdates": {
|
||||
"message": "Alle stilen kontrolearje op fernijingen"
|
||||
},
|
||||
"checkForUpdate": {
|
||||
"message": "Kontrolearje op fernijing"
|
||||
},
|
||||
"checkingForUpdate": {
|
||||
"message": "Kontrolearje..."
|
||||
},
|
||||
"cm_indentWithTabs": {
|
||||
"message": "Ljepblêden mei tûke ynspringing brûke"
|
||||
},
|
||||
"cm_keyMap": {
|
||||
"message": "Toetseboerdyndieling"
|
||||
},
|
||||
"cm_lineWrapping": {
|
||||
"message": "Teksttebekrin"
|
||||
},
|
||||
"cm_smartIndent": {
|
||||
"message": "Tûke ynspringing brûke"
|
||||
},
|
||||
"cm_tabSize": {
|
||||
"message": "Ljepblêdgrutte"
|
||||
},
|
||||
"cm_theme": {
|
||||
"message": "Tema"
|
||||
},
|
||||
"confirmNo": {
|
||||
"message": "Nee"
|
||||
},
|
||||
"confirmStop": {
|
||||
"message": "Stoppe"
|
||||
},
|
||||
"confirmYes": {
|
||||
"message": "Ja"
|
||||
},
|
||||
"dbError": {
|
||||
"message": "Der is in flater bard by it brûken fan de Stylus-database. Wolle jo in webside mei mooglike oplossingen besykje?"
|
||||
},
|
||||
"defaultTheme": {
|
||||
"message": "standert"
|
||||
},
|
||||
"deleteStyleConfirm": {
|
||||
"message": "Binne jo wis dat jo dizze styl fuortsmite wolle?"
|
||||
},
|
||||
"deleteStyleLabel": {
|
||||
"message": "Fuortsmite"
|
||||
}
|
||||
}
|
52
_locales/gl/messages.json
Normal file
52
_locales/gl/messages.json
Normal file
|
@ -0,0 +1,52 @@
|
|||
{
|
||||
"addStyleTitle": {
|
||||
"message": "Engadir Estilo"
|
||||
},
|
||||
"alphaChannel": {
|
||||
"message": "Opacidade"
|
||||
},
|
||||
"appliesAdd": {
|
||||
"message": "Engadir"
|
||||
},
|
||||
"appliesDisplay": {
|
||||
"message": "Aplica a: $applies$",
|
||||
"placeholders": {
|
||||
"applies": {
|
||||
"content": "$1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"appliesDisplayTruncatedSuffix": {
|
||||
"message": "e mais"
|
||||
},
|
||||
"appliesDomainOption": {
|
||||
"message": "URLs no dominio"
|
||||
},
|
||||
"appliesLabel": {
|
||||
"message": "Aplica para"
|
||||
},
|
||||
"appliesLineWidgetWarning": {
|
||||
"message": "Non funciona con CSS minificado"
|
||||
},
|
||||
"appliesRegexpOption": {
|
||||
"message": "URLs que concorden co regexp"
|
||||
},
|
||||
"appliesRemove": {
|
||||
"message": "Suprimir"
|
||||
},
|
||||
"appliesSpecify": {
|
||||
"message": "Especificar"
|
||||
},
|
||||
"appliesToEverything": {
|
||||
"message": "Todo"
|
||||
},
|
||||
"appliesUrlPrefixOption": {
|
||||
"message": "URLs que comecen por"
|
||||
},
|
||||
"applyAllUpdates": {
|
||||
"message": "Aplicar tódalas actualizacións"
|
||||
},
|
||||
"author": {
|
||||
"message": "Autor"
|
||||
}
|
||||
}
|
1040
_locales/he/messages.json
Normal file
1040
_locales/he/messages.json
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
1356
_locales/ko/messages.json
Normal file
1356
_locales/ko/messages.json
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
860
_locales/ro/messages.json
Normal file
860
_locales/ro/messages.json
Normal file
|
@ -0,0 +1,860 @@
|
|||
{
|
||||
"addStyleLabel": {
|
||||
"message": "Scrieți o temă nouă"
|
||||
},
|
||||
"addStyleTitle": {
|
||||
"message": "Adăugați o temă"
|
||||
},
|
||||
"alphaChannel": {
|
||||
"message": "Opacitate"
|
||||
},
|
||||
"appliesAdd": {
|
||||
"message": "Adăugați"
|
||||
},
|
||||
"appliesDisplay": {
|
||||
"message": "Aplicabil pentru: $applies$",
|
||||
"placeholders": {
|
||||
"applies": {
|
||||
"content": "$1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"appliesDisplayTruncatedSuffix": {
|
||||
"message": "mai mult"
|
||||
},
|
||||
"appliesDomainOption": {
|
||||
"message": "URLs din domain"
|
||||
},
|
||||
"appliesHelp": {
|
||||
"message": "Folosiți 'Aplicabil pentru' pentru a limita pe ce URLs va fi aplicată temă."
|
||||
},
|
||||
"appliesLabel": {
|
||||
"message": "Aplicabil pentru"
|
||||
},
|
||||
"appliesLineWidgetLabel": {
|
||||
"message": "Arată informații despre 'Aplicabil pentru'"
|
||||
},
|
||||
"appliesLineWidgetWarning": {
|
||||
"message": "Nu funcționează cu CSS minimizat"
|
||||
},
|
||||
"appliesRegexpOption": {
|
||||
"message": "URLs găsite cu regexp"
|
||||
},
|
||||
"appliesRemove": {
|
||||
"message": "Ștergeți"
|
||||
},
|
||||
"appliesRemoveError": {
|
||||
"message": "Nu se poate șterge 'aplicabil pentru'"
|
||||
},
|
||||
"appliesSpecify": {
|
||||
"message": "Specificați"
|
||||
},
|
||||
"appliesToEverything": {
|
||||
"message": "Totul"
|
||||
},
|
||||
"appliesUrlPrefixOption": {
|
||||
"message": "URL-uri începănd cu"
|
||||
},
|
||||
"applyAllUpdates": {
|
||||
"message": "Aplicați toate update-urile"
|
||||
},
|
||||
"author": {
|
||||
"message": "Autor"
|
||||
},
|
||||
"bckpInstStyles": {
|
||||
"message": "Exportați teme"
|
||||
},
|
||||
"checkAllUpdates": {
|
||||
"message": "Verificați toate temele pentru update-uri"
|
||||
},
|
||||
"checkAllUpdatesForce": {
|
||||
"message": "Verifică iar, nu am modificat temele!"
|
||||
},
|
||||
"checkForUpdate": {
|
||||
"message": "Verificați pentru update-uri"
|
||||
},
|
||||
"checkingForUpdate": {
|
||||
"message": "Verficare..."
|
||||
},
|
||||
"clickToUninstall": {
|
||||
"message": "Click pentru dezinstalare"
|
||||
},
|
||||
"cm_autoCloseBrackets": {
|
||||
"message": "Închideți automat parantezele și ghilimelele"
|
||||
},
|
||||
"cm_autoCloseBracketsTooltip": {
|
||||
"message": "Închideți automat când deschizideți una dintre ()[]{}''\"\""
|
||||
},
|
||||
"cm_autocompleteOnTyping": {
|
||||
"message": "Autocompletare în timpul scrierii"
|
||||
},
|
||||
"cm_colorpicker": {
|
||||
"message": "Alegere de culori pentru CSS"
|
||||
},
|
||||
"cm_indentWithTabs": {
|
||||
"message": "Folosiți tab-uri cu autoindentare"
|
||||
},
|
||||
"cm_matchHighlightSelection": {
|
||||
"message": "Doar selecție"
|
||||
},
|
||||
"cm_matchHighlightToken": {
|
||||
"message": "Token-ul de sub cursor"
|
||||
},
|
||||
"cm_resizeGripHint": {
|
||||
"message": "Dublu click pentru a maximiza sau restaura înălțimea"
|
||||
},
|
||||
"cm_selectByTokens": {
|
||||
"message": "Dublu-click pentru a selecta simbolurile"
|
||||
},
|
||||
"cm_selectByTokensTooltip": {
|
||||
"message": "Exemple de simboluri: .foo-bar-2 #aabbcc 0.32 !important\nCand inactiv: cuvinte delimitate cu punctuatie sunt selectate."
|
||||
},
|
||||
"cm_smartIndent": {
|
||||
"message": "Folosiți indentare inteligentă"
|
||||
},
|
||||
"cm_tabSize": {
|
||||
"message": "Mărimea tab-urilor"
|
||||
},
|
||||
"cm_theme": {
|
||||
"message": "Temă pentru cod"
|
||||
},
|
||||
"colorpickerSwitchFormatTooltip": {
|
||||
"message": "Schimbați formatul: HEX -> RGB -> HSL.\nShift-click pentru inversarea direcției.\nDe asemenea cu PgUp (PageUp), PgDn (PageDown)."
|
||||
},
|
||||
"colorpickerTooltip": {
|
||||
"message": "Deschideți color picker"
|
||||
},
|
||||
"configOnChange": {
|
||||
"message": "la schimbare"
|
||||
},
|
||||
"configOnChangeTooltip": {
|
||||
"message": "Autosalvare și aplicare a modificărilor automată"
|
||||
},
|
||||
"configureStyle": {
|
||||
"message": "Modificați"
|
||||
},
|
||||
"configureStyleOnHomepage": {
|
||||
"message": "Modificați pe pagina homepage"
|
||||
},
|
||||
"confirmDefault": {
|
||||
"message": "Folosiți default"
|
||||
},
|
||||
"confirmDelete": {
|
||||
"message": "Ștergeți"
|
||||
},
|
||||
"confirmDiscardChanges": {
|
||||
"message": "Pierdeți modificările?"
|
||||
},
|
||||
"confirmNo": {
|
||||
"message": "Nu"
|
||||
},
|
||||
"confirmSave": {
|
||||
"message": "Salvați"
|
||||
},
|
||||
"confirmYes": {
|
||||
"message": "Da"
|
||||
},
|
||||
"dateInstalled": {
|
||||
"message": "Data instalării"
|
||||
},
|
||||
"dateUpdated": {
|
||||
"message": "Data updatării"
|
||||
},
|
||||
"dbError": {
|
||||
"message": "O eroare în baza de date a apărut. Doriți să vizitați pagina web pentru o soluție?"
|
||||
},
|
||||
"deleteStyleConfirm": {
|
||||
"message": "Sunteți sigur că doriți să ștergeți această temă?"
|
||||
},
|
||||
"deleteStyleLabel": {
|
||||
"message": "Ștergeți"
|
||||
},
|
||||
"description": {
|
||||
"message": "Stilizați internetul cu Stylus, un manager de teme. Stylus vă permite să instalați cu ușurință teme pentru multe site-uri populare."
|
||||
},
|
||||
"disableAllStyles": {
|
||||
"message": "Dezactivați toate temele"
|
||||
},
|
||||
"disableStyleLabel": {
|
||||
"message": "Dezactivați"
|
||||
},
|
||||
"dragDropMessage": {
|
||||
"message": "Drag and drop backup-ul oriunde pentru import."
|
||||
},
|
||||
"editDeleteText": {
|
||||
"message": "Ștergeți"
|
||||
},
|
||||
"editGotoLine": {
|
||||
"message": "Mergeți la linia"
|
||||
},
|
||||
"editStyleHeading": {
|
||||
"message": "Modificați tema"
|
||||
},
|
||||
"editStyleLabel": {
|
||||
"message": "Modificați"
|
||||
},
|
||||
"editStyleTitle": {
|
||||
"message": "Modificați tema $stylename$",
|
||||
"placeholders": {
|
||||
"stylename": {
|
||||
"content": "$1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"enableStyleLabel": {
|
||||
"message": "Activați"
|
||||
},
|
||||
"externalLink": {
|
||||
"message": "Link extern"
|
||||
},
|
||||
"externalSupport": {
|
||||
"message": "Suport"
|
||||
},
|
||||
"externalUsercssDocument": {
|
||||
"message": "Documentație pentru Usercss"
|
||||
},
|
||||
"filteredStyles": {
|
||||
"message": "$numShown$ vizualizabile din $numTotal$ ",
|
||||
"placeholders": {
|
||||
"numShown": {
|
||||
"content": "$1"
|
||||
},
|
||||
"numTotal": {
|
||||
"content": "$2"
|
||||
}
|
||||
}
|
||||
},
|
||||
"filteredStylesAllHidden": {
|
||||
"message": "Filtrele aplicate nu au găsit nicio temă"
|
||||
},
|
||||
"findStyles": {
|
||||
"message": "Găsiți teme"
|
||||
},
|
||||
"genericAdd": {
|
||||
"message": "Adaugă"
|
||||
},
|
||||
"genericClone": {
|
||||
"message": "Clonează"
|
||||
},
|
||||
"genericDisabledLabel": {
|
||||
"message": "Dezactivat"
|
||||
},
|
||||
"genericEnabledLabel": {
|
||||
"message": "Activat"
|
||||
},
|
||||
"genericError": {
|
||||
"message": "Eroare"
|
||||
},
|
||||
"genericHistoryLabel": {
|
||||
"message": "Historic"
|
||||
},
|
||||
"genericNext": {
|
||||
"message": "Următor"
|
||||
},
|
||||
"genericPrevious": {
|
||||
"message": "Precedent"
|
||||
},
|
||||
"genericResetLabel": {
|
||||
"message": "Resetați"
|
||||
},
|
||||
"genericSavedMessage": {
|
||||
"message": "Salvat"
|
||||
},
|
||||
"genericTitle": {
|
||||
"message": "Titlu"
|
||||
},
|
||||
"genericUnknown": {
|
||||
"message": "Necunoscut"
|
||||
},
|
||||
"helpAlt": {
|
||||
"message": "Ajutor"
|
||||
},
|
||||
"helpKeyMapCommand": {
|
||||
"message": "Tastați un nume de comandă"
|
||||
},
|
||||
"helpKeyMapHotkey": {
|
||||
"message": "Tastați o hotkey"
|
||||
},
|
||||
"importAppendLabel": {
|
||||
"message": "Concatenare la temă"
|
||||
},
|
||||
"importAppendTooltip": {
|
||||
"message": "Concatenați tema importată la cea curentă"
|
||||
},
|
||||
"importReplaceLabel": {
|
||||
"message": "Scrieți peste tema curentă"
|
||||
},
|
||||
"importReplaceTooltip": {
|
||||
"message": "Scrieți peste tema curentă conținutul temei importate"
|
||||
},
|
||||
"importReportLegendAdded": {
|
||||
"message": "adăugat"
|
||||
},
|
||||
"importReportLegendIdentical": {
|
||||
"message": "cele identice au fost sărite"
|
||||
},
|
||||
"importReportLegendInvalid": {
|
||||
"message": "cele invalide au fost ignorate"
|
||||
},
|
||||
"importReportLegendUpdatedBoth": {
|
||||
"message": "meta info și codul au fost updatate"
|
||||
},
|
||||
"importReportLegendUpdatedCode": {
|
||||
"message": "cod updatat"
|
||||
},
|
||||
"importReportLegendUpdatedMeta": {
|
||||
"message": "meta info updatată"
|
||||
},
|
||||
"importReportTitle": {
|
||||
"message": "Importul temelor finalizat"
|
||||
},
|
||||
"importReportUnchanged": {
|
||||
"message": "Nimic nu a fost schimbat."
|
||||
},
|
||||
"importReportUndone": {
|
||||
"message": "temele au fost înlocuite cu variantele precedente"
|
||||
},
|
||||
"importReportUndoneTitle": {
|
||||
"message": "Importarea a fost anulată"
|
||||
},
|
||||
"installButton": {
|
||||
"message": "Instalați tema"
|
||||
},
|
||||
"installButtonInstalled": {
|
||||
"message": "Tema a fost instalată"
|
||||
},
|
||||
"installButtonReinstall": {
|
||||
"message": "Reinstalați tema"
|
||||
},
|
||||
"installUpdate": {
|
||||
"message": "Instalați update-uri"
|
||||
},
|
||||
"installUpdateFrom": {
|
||||
"message": "Tema este updatată de la $url$",
|
||||
"placeholders": {
|
||||
"url": {
|
||||
"content": "$1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"installUpdateFromLabel": {
|
||||
"message": "Verificați update-urile"
|
||||
},
|
||||
"license": {
|
||||
"message": "Licență"
|
||||
},
|
||||
"linkGetHelp": {
|
||||
"message": "Găsiți ajutor"
|
||||
},
|
||||
"linkGetStyles": {
|
||||
"message": "Căutați teme"
|
||||
},
|
||||
"linkTranslate": {
|
||||
"message": "Traduce"
|
||||
},
|
||||
"linterCSSLintIncompatible": {
|
||||
"message": "CSSLint nu suportă preprocesorul $preprocessorname$ ",
|
||||
"placeholders": {
|
||||
"preprocessorname": {
|
||||
"content": "$1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"linterCSSLintSettings": {
|
||||
"message": "(Setați regula ca: 0 = dezactivat; 1 = avertisment; 2 = eroare)"
|
||||
},
|
||||
"linterConfigPopupTitle": {
|
||||
"message": "Setați $linter$ pentru configurarea regulilor",
|
||||
"placeholders": {
|
||||
"linter": {
|
||||
"content": "$1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"linterConfigTooltip": {
|
||||
"message": "Click pentru a configura linter-ul"
|
||||
},
|
||||
"linterInvalidConfigError": {
|
||||
"message": "Nu a fost salvat din cauza acestor setări invalide:"
|
||||
},
|
||||
"linterIssues": {
|
||||
"message": "Probleme"
|
||||
},
|
||||
"linterIssuesHelp": {
|
||||
"message": "Aceste probleme au fost găsite te $link$:",
|
||||
"placeholders": {
|
||||
"link": {
|
||||
"content": "$1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"linterResetMessage": {
|
||||
"message": "Pentru a reveni la varianta precedentă, apăsați Ctrl-Z (sau Cmd-Z) în text box"
|
||||
},
|
||||
"linterRulesLink": {
|
||||
"message": "Vizualizați lista completă de reguli"
|
||||
},
|
||||
"liveReloadError": {
|
||||
"message": "A avut loc o eroare în timpul monitorizării acestui fișier"
|
||||
},
|
||||
"manageFavicons": {
|
||||
"message": "Favicons în coloana 'se aplică la'"
|
||||
},
|
||||
"manageFaviconsGray": {
|
||||
"message": "Hașurat"
|
||||
},
|
||||
"manageFaviconsHelp": {
|
||||
"message": "Stylus folosește un serviciu extern https://icons.duckduckgo.com"
|
||||
},
|
||||
"manageFilters": {
|
||||
"message": "Filtre"
|
||||
},
|
||||
"manageHeading": {
|
||||
"message": "Teme instalate"
|
||||
},
|
||||
"manageMaxTargets": {
|
||||
"message": "Numărul obiectelor la care se aplică"
|
||||
},
|
||||
"manageNewUI": {
|
||||
"message": "UI layout pentru mesajele noi"
|
||||
},
|
||||
"manageOnlyDisabled": {
|
||||
"message": "Doar teme dezactivate"
|
||||
},
|
||||
"manageOnlyEnabled": {
|
||||
"message": "Doar temele activate"
|
||||
},
|
||||
"manageOnlyExternal": {
|
||||
"message": "Doar teme externe"
|
||||
},
|
||||
"manageOnlyLocal": {
|
||||
"message": "Doar temele create local"
|
||||
},
|
||||
"manageOnlyLocalTooltip": {
|
||||
"message": "(temele neinstalate prin userstyles.org)"
|
||||
},
|
||||
"manageOnlyNonUsercss": {
|
||||
"message": "Doar teme non-Usercss"
|
||||
},
|
||||
"manageOnlyUpdates": {
|
||||
"message": "Doar cu update-uri sau erori"
|
||||
},
|
||||
"manageOnlyUsercss": {
|
||||
"message": "Doar teme Usercss"
|
||||
},
|
||||
"menuShowBadge": {
|
||||
"message": "Afișați numărul temelor active"
|
||||
},
|
||||
"meta_invalidCheckboxDefault": {
|
||||
"message": "@var checkbox invalidă: valuarea trebuie să fie 0 sau 1"
|
||||
},
|
||||
"noStylesForSite": {
|
||||
"message": "Nicio temă instalată pentru acest site."
|
||||
},
|
||||
"openManage": {
|
||||
"message": "Managerul"
|
||||
},
|
||||
"openOptions": {
|
||||
"message": "Opțiuni"
|
||||
},
|
||||
"openStylesManager": {
|
||||
"message": "Deschideți managerul de teme"
|
||||
},
|
||||
"optionsActions": {
|
||||
"message": "Acțiuni"
|
||||
},
|
||||
"optionsAdvanced": {
|
||||
"message": "Avansat"
|
||||
},
|
||||
"optionsAdvancedContextDelete": {
|
||||
"message": "Adaugați 'Ștergeți' în meniul de click dreapta"
|
||||
},
|
||||
"optionsAdvancedExposeIframes": {
|
||||
"message": "Expuneți iframes via HTML[stylus-iframe]"
|
||||
},
|
||||
"optionsAdvancedNewStyleAsUsercss": {
|
||||
"message": "Scrieți temă nouă în formatul usercss"
|
||||
},
|
||||
"optionsBadgeDisabled": {
|
||||
"message": "Culoare de fundal pentru modul inactiv"
|
||||
},
|
||||
"optionsBadgeNormal": {
|
||||
"message": "Culoare de fundal"
|
||||
},
|
||||
"optionsCheck": {
|
||||
"message": "Updatați temele"
|
||||
},
|
||||
"optionsCheckUpdate": {
|
||||
"message": "Verificați și instalează toate update-urile"
|
||||
},
|
||||
"optionsCustomizeBadge": {
|
||||
"message": "Bulinuța de pe iconița din toolbar"
|
||||
},
|
||||
"optionsCustomizeUpdate": {
|
||||
"message": "Update-uri"
|
||||
},
|
||||
"optionsHeading": {
|
||||
"message": "Opțiuni"
|
||||
},
|
||||
"optionsIconDark": {
|
||||
"message": "Teme întunecate pentru browser"
|
||||
},
|
||||
"optionsIconLight": {
|
||||
"message": "Teme albe pentru browser"
|
||||
},
|
||||
"optionsOpen": {
|
||||
"message": "Deschideți"
|
||||
},
|
||||
"optionsOpenManager": {
|
||||
"message": "Managerul de teme"
|
||||
},
|
||||
"optionsPopupWidth": {
|
||||
"message": "Mărimea ferestrei popup (în pixeli)"
|
||||
},
|
||||
"optionsReset": {
|
||||
"message": "Resetați opțiunile"
|
||||
},
|
||||
"optionsResetButton": {
|
||||
"message": "Resetați opțiunile"
|
||||
},
|
||||
"optionsSubheading": {
|
||||
"message": "Mai multe opțiuni"
|
||||
},
|
||||
"optionsUpdateImportNote": {
|
||||
"message": "Atunci când sunt importate teme din backup-uri din versiuni mai vechi sau din Stylish, verifică upate-urile manual pentru a fi sigur că toate temele sunt la zi."
|
||||
},
|
||||
"optionsUpdateInterval": {
|
||||
"message": "Intervalul de autoupdate în ore (0 pentru dezactivat)"
|
||||
},
|
||||
"paginationCurrent": {
|
||||
"message": "Pagina curentă"
|
||||
},
|
||||
"paginationEstimated": {
|
||||
"message": "Număr estimat de pagini"
|
||||
},
|
||||
"paginationNext": {
|
||||
"message": "Pagina următoare"
|
||||
},
|
||||
"paginationPrevious": {
|
||||
"message": "Pagina precedentă"
|
||||
},
|
||||
"paginationTotal": {
|
||||
"message": "Număr total de pagini"
|
||||
},
|
||||
"parseUsercssError": {
|
||||
"message": "Stylus nu a putut analiza usercss-ul"
|
||||
},
|
||||
"popupBorders": {
|
||||
"message": "Adăugați bordură albă pe margini"
|
||||
},
|
||||
"popupBordersTooltip": {
|
||||
"message": "Folositor pentru teme întunecate in noul Chrome deoarece nu mai colorează bordurile"
|
||||
},
|
||||
"popupHotkeysInfo": {
|
||||
"message": "<1>-<9>, <0>, de asemenea îm numpad - activează/dezactivează tema numărul N (0 este 10)\n<A>-<Z> activează/dezactivează prima temă cu un nume care începe cu o litera\n<Shift> deschide editorul și nu activează/dezactivează ceva\n<Numpad +> activează temele listate\n<Numpad –> dezactiveaza temele listate\n<Numpad *> și <`> (backtick) - activează/dezactivează temele activate inițial; nu se aplică altor teme activate când popup-ul este deschid pentru a permite restaurarea seleției inițiale pentru a permite testări; dezactivează tot, apoi activează/dezactivează, spre exemplu<Numpad –> <Numpad *>\nMai multe informații sunt avabile în wiki"
|
||||
},
|
||||
"popupHotkeysTooltip": {
|
||||
"message": "Click pentru a vedea hotkeys avabile"
|
||||
},
|
||||
"popupManageTooltip": {
|
||||
"message": "Shift-click sau right-click pentru a deschide managerurl cu teme aplicabile site-ului curent"
|
||||
},
|
||||
"popupOpenEditInWindow": {
|
||||
"message": "Deschide editorul în alt window"
|
||||
},
|
||||
"popupOpenEditInWindowTooltip": {
|
||||
"message": "Activ când tabul editorului este detașat de browser,\nși dezactivat când un singur tab cu editor este atașat la alt window."
|
||||
},
|
||||
"popupStylesFirst": {
|
||||
"message": "Temele înaintea comenzilor"
|
||||
},
|
||||
"prefShowBadge": {
|
||||
"message": "Numărul de teme active pentru site-ul curent"
|
||||
},
|
||||
"previewTooltip": {
|
||||
"message": "Aplică temporar modificările fără a salva.\nSalvează tema pentru a face schimbările permanente."
|
||||
},
|
||||
"replace": {
|
||||
"message": "Înlocuiți"
|
||||
},
|
||||
"replaceAll": {
|
||||
"message": "Înlocuiți tot"
|
||||
},
|
||||
"replaceWith": {
|
||||
"message": "Înlocuiți cu"
|
||||
},
|
||||
"retrieveBckp": {
|
||||
"message": "Importați teme"
|
||||
},
|
||||
"search": {
|
||||
"message": "Căutați"
|
||||
},
|
||||
"searchNumberOfResults": {
|
||||
"message": "Număr de rezultate"
|
||||
},
|
||||
"searchNumberOfResults2": {
|
||||
"message": "Număr de rezultate în cod și în 'aplicabil pentru'"
|
||||
},
|
||||
"searchRegexp": {
|
||||
"message": "Folosiți sintaxă /re/ pentru căutare tip regexp"
|
||||
},
|
||||
"searchResultInstallCount": {
|
||||
"message": "Număr total de instalări"
|
||||
},
|
||||
"searchResultNoneFound": {
|
||||
"message": "Nicio tema găsită pentru acest site."
|
||||
},
|
||||
"searchResultUpdated": {
|
||||
"message": "Updatate"
|
||||
},
|
||||
"searchResultWeeklyCount": {
|
||||
"message": "Instalări săptămânale"
|
||||
},
|
||||
"sectionAdd": {
|
||||
"message": "Adăugați o altă secțiune"
|
||||
},
|
||||
"sectionCode": {
|
||||
"message": "Cod"
|
||||
},
|
||||
"sectionRemove": {
|
||||
"message": "Ștergeți secțiunea"
|
||||
},
|
||||
"sectionRestore": {
|
||||
"message": "Restaurează o secțiune ștearsă"
|
||||
},
|
||||
"sections": {
|
||||
"message": "Secțiuni"
|
||||
},
|
||||
"shortcutsNote": {
|
||||
"message": "Creeați keyboard shortcuts"
|
||||
},
|
||||
"sortDateNewestFirst": {
|
||||
"message": "cele mai noi la început"
|
||||
},
|
||||
"sortDateOldestFirst": {
|
||||
"message": "cel mai vechi la început"
|
||||
},
|
||||
"sortLabel": {
|
||||
"message": "Alegeți o sortare care să fie aplicată temelor instalate"
|
||||
},
|
||||
"sortLabelTitleAsc": {
|
||||
"message": "Titlu crescător"
|
||||
},
|
||||
"sortLabelTitleDesc": {
|
||||
"message": "Titlu descrescător"
|
||||
},
|
||||
"sortStylesHelp": {
|
||||
"message": "Alegeți ce fel de sortare doriți să fie aplicată temelor instalate, din cadrul meniului dropdown. În mod implicit se aplică sortare alfabetică (A la Z) titlurilor temelor. Sortarea de tip \"Titlu descrescător\" va aplica sortare descrescătoare (Z la A) titlurilor.\nSunt alte presets care permit sortări după mai multe criterii. Este ca și cum ați sorta un tabel cu mai multe coloane iar fiecare categorie (între semnele +) reprezintă o coloană, sau un grup..\nSpre exemplu, dacă se alege \"Activată (prima) + Titlu\", atunci toate temele vor fi grupate astfel încât cele active sunt cap de listă, iar apoi temele sunt sortate alfabetic."
|
||||
},
|
||||
"sortStylesHelpTitle": {
|
||||
"message": "Sortare conținut"
|
||||
},
|
||||
"styleBadRegexp": {
|
||||
"message": "Regexp invalid."
|
||||
},
|
||||
"styleBeautify": {
|
||||
"message": "Înfrumusețați"
|
||||
},
|
||||
"styleBeautifyIndentConditional": {
|
||||
"message": "Indentare @media, @supports"
|
||||
},
|
||||
"styleBeautifyPreserveNewlines": {
|
||||
"message": "Menține linii noi"
|
||||
},
|
||||
"styleCancelEditLabel": {
|
||||
"message": "Înapoi la manager"
|
||||
},
|
||||
"styleChangesNotSaved": {
|
||||
"message": "Ați modificat tema fără a o salva."
|
||||
},
|
||||
"styleEnabledLabel": {
|
||||
"message": "Activat"
|
||||
},
|
||||
"styleFromMozillaFormatError": {
|
||||
"message": "Importul din formatul Mozilla eșuat"
|
||||
},
|
||||
"styleFromMozillaFormatPrompt": {
|
||||
"message": "Paste cod în format Mozilla"
|
||||
},
|
||||
"styleInstall": {
|
||||
"message": "Instalați '$stylename$' în Stylus?",
|
||||
"placeholders": {
|
||||
"stylename": {
|
||||
"content": "$1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"styleInstallFailed": {
|
||||
"message": "Instalarea temei eșuată!\n$error$",
|
||||
"placeholders": {
|
||||
"error": {
|
||||
"content": "$1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"styleInstallOverwrite": {
|
||||
"message": "'$stylename$' este deja instalată. Scrieți peste?\nVersiune: $oldVersion$ -> $newVersion$",
|
||||
"placeholders": {
|
||||
"newVersion": {
|
||||
"content": "$3"
|
||||
},
|
||||
"oldVersion": {
|
||||
"content": "$2"
|
||||
},
|
||||
"stylename": {
|
||||
"content": "$1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"styleMissingName": {
|
||||
"message": "Introduceți un nume"
|
||||
},
|
||||
"styleMozillaFormatHeading": {
|
||||
"message": "Format Mozilla"
|
||||
},
|
||||
"styleNotAppliedRegexpProblemTooltip": {
|
||||
"message": "Tema nu a fost aplicată din cauza incorectei aplicări a 'regexp()'"
|
||||
},
|
||||
"styleRegexpInvalidExplanation": {
|
||||
"message": "Unele reguli 'regexp()' care nu au putut fi compilate."
|
||||
},
|
||||
"styleRegexpPartialExplanation": {
|
||||
"message": "Această temă folosește regexp parțiale care încalcă <a href='https://developer.mozilla.org/docs/Web/CSS/@document'> specificațiile CSS4 @document</a> care are nevoie de o potrivire regexp exactă. Părțile afectate de CSS nu au fost aplicate paginii. Cel mai probabil tema a fost creată în Stylish-for-Chrome care verifică incorect 'regexp()' de la prima sa versiune (bug cunoscut)."
|
||||
},
|
||||
"styleRegexpProblemTooltip": {
|
||||
"message": " Numărul de secțiuni care nu au fost aplicate din cauza utilizării incorecte a 'regexp()'"
|
||||
},
|
||||
"styleRegexpTestFull": {
|
||||
"message": "Taburi găsite"
|
||||
},
|
||||
"styleRegexpTestInvalid": {
|
||||
"message": "Invalid regexps au fost sărite"
|
||||
},
|
||||
"styleRegexpTestNone": {
|
||||
"message": "Niciun tab nu se potrivește căutării"
|
||||
},
|
||||
"styleRegexpTestNote": {
|
||||
"message": "Notă: folosiți \\ pentru ignorarea caracterelor speciale în regexp, care va fi transformat automat în \\\\ în codul temei, urmând specificațiile pentru text citat în CSS."
|
||||
},
|
||||
"styleRegexpTestPartial": {
|
||||
"message": "Potrivire parțială, deci ignorată"
|
||||
},
|
||||
"styleRegexpTestTitle": {
|
||||
"message": "Listă cu taburi deschise care se potrivesc căutării (click URL pentru a activa tabul)"
|
||||
},
|
||||
"styleSaveLabel": {
|
||||
"message": "Salvați"
|
||||
},
|
||||
"styleToMozillaFormatHelp": {
|
||||
"message": "Formatul Mozilla al codului poate fi uploadat pe userstyles.org și folosit de clasicul Stylish pentru Firefox."
|
||||
},
|
||||
"styleToMozillaFormatTitle": {
|
||||
"message": "Scrieți în format Mozilla"
|
||||
},
|
||||
"styleUpdate": {
|
||||
"message": "Sunteți sigur că doriți să faceți update la '$stylename$'?",
|
||||
"placeholders": {
|
||||
"stylename": {
|
||||
"content": "$1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"styleUpdateDiscardChanges": {
|
||||
"message": "Tema a fost modificată în afara editorului. Doriți să reâncărcați tema?"
|
||||
},
|
||||
"stylusUnavailableForURL": {
|
||||
"message": "Stylus nu funcționează în astfel de pagini."
|
||||
},
|
||||
"stylusUnavailableForURLdetails": {
|
||||
"message": "Ca o măsură de securitate, browser-ul împiedică extensiile să afecteze paginile corespunzătoare browser-ului (precum chrome://version, adresa unui nou tab începând cu Chrome 61, about:addons, în Firefox etc) și de asemenea paginile altor extensii. De asemenea este restricționat accesul la galeriile de extensii (Chrome Web Store sau AMO)."
|
||||
},
|
||||
"syncStorageErrorSaving": {
|
||||
"message": "Valoarea nu a putut fi salvată. Încercați să reduceți dimensiunea textului."
|
||||
},
|
||||
"toggleStyle": {
|
||||
"message": "Activați/Dezactivați tema"
|
||||
},
|
||||
"undoGlobal": {
|
||||
"message": "Undo în toate secțiunile"
|
||||
},
|
||||
"unreachableAMO": {
|
||||
"message": "Firefox împiedică accesul la site."
|
||||
},
|
||||
"unreachableAMOHint": {
|
||||
"message": "Pentru a permite accesul deschideți <about:config>, right-click pe listă, click 'New', apoi 'Boolean', paste <privacy.resistFingerprinting.block_mozAddonManager> și click OK, <true>, OK, reâncărcați pagina <addons.mozilla.org>."
|
||||
},
|
||||
"unreachableContentScript": {
|
||||
"message": "Nu s-a putut comunica cu pagina. Reîncărcați tabul."
|
||||
},
|
||||
"unreachableFileHint": {
|
||||
"message": "Stylus poate accesa file:// URLs doar când este activată opțiunea respectivă din pagina cu setări chrome://extensions"
|
||||
},
|
||||
"unreachableMozSiteHintOldFF": {
|
||||
"message": "Doar Firefox 59 sau mai nou poate fi configurat să permită WebExtension-urilor să adauge elemente la site-uri CSP-protected precum acesta."
|
||||
},
|
||||
"updateAllCheckSucceededNoUpdate": {
|
||||
"message": "Niciun update găsit."
|
||||
},
|
||||
"updateAllCheckSucceededSomeEdited": {
|
||||
"message": "Unele teme care au update-uri nu au fost updatate pentru a nu pierde modificări locale. Update-urile pot fi forțate individual sau prin a reverifica update-urile pentru toate temele (modificările locale vor fi pierdute)."
|
||||
},
|
||||
"updateCheckFailBadResponseCode": {
|
||||
"message": "Update eșuat: server-ul a răspuns cu acest cod $code$.",
|
||||
"placeholders": {
|
||||
"code": {
|
||||
"content": "$1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"updateCheckFailServerUnreachable": {
|
||||
"message": "Update eșuat: server-ul nu este avabil."
|
||||
},
|
||||
"updateCheckHistory": {
|
||||
"message": "Historicul update-urilor"
|
||||
},
|
||||
"updateCheckManualUpdateForce": {
|
||||
"message": "Instalați update-urile (modificările locale vor fi șterse)"
|
||||
},
|
||||
"updateCheckManualUpdateHint": {
|
||||
"message": "Update-ul forțat va șterge toate modificările locale."
|
||||
},
|
||||
"updateCheckSkippedLocallyEdited": {
|
||||
"message": "Tema a fost editată local."
|
||||
},
|
||||
"updateCheckSkippedMaybeLocallyEdited": {
|
||||
"message": "Tema poate a fost modificată local."
|
||||
},
|
||||
"updateCheckSucceededNoUpdate": {
|
||||
"message": "Tema este cu update-urile la zi."
|
||||
},
|
||||
"updateCompleted": {
|
||||
"message": "Update realizat."
|
||||
},
|
||||
"updatesCurrentlyInstalled": {
|
||||
"message": "Update-uri instalate:"
|
||||
},
|
||||
"usercssAvoidOverwriting": {
|
||||
"message": "Vă rugăm să modificați valoarea @name și @namespace pentru a împiedica scrierea peste o temă existentă."
|
||||
},
|
||||
"usercssConfigIncomplete": {
|
||||
"message": "Tema a fost updatată sau ștearsă după ce configurațiile au fost afișate. Aceste variabile nu au fost salvate pentru a nu corupe metadata temei."
|
||||
},
|
||||
"usercssEditorNamePlaceholder": {
|
||||
"message": "Specificați @name"
|
||||
},
|
||||
"usercssReplaceTemplateConfirmation": {
|
||||
"message": "Înlocuiți tema de bază a formatului Usercss cu acest cod?"
|
||||
},
|
||||
"usercssReplaceTemplateSectionBody": {
|
||||
"message": "Introduce cod aici..."
|
||||
},
|
||||
"versionInvalidOlder": {
|
||||
"message": "Versiunea este mai veche decât cea instalată."
|
||||
},
|
||||
"writeStyleFor": {
|
||||
"message": "Scrieți temă pentru: "
|
||||
},
|
||||
"writeStyleForURL": {
|
||||
"message": "acest URL"
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -1,416 +1,335 @@
|
|||
{
|
||||
"appliesToEverything": {
|
||||
"message": "Све",
|
||||
"description": "Text displayed for styles that apply to all sites"
|
||||
},
|
||||
"linterIssues": {
|
||||
"message": "Проблеми",
|
||||
"description": "Label for the CSS linter issues block on the style edit page"
|
||||
},
|
||||
"defaultTheme": {
|
||||
"message": "подразумевано",
|
||||
"description": "Default CodeMirror CSS theme option on the edit style page"
|
||||
},
|
||||
"exportLabel": {
|
||||
"message": "Извези",
|
||||
"description": "Label for the button to export a style ('edit' page) or all styles ('manage' page)"
|
||||
},
|
||||
"cm_tabSize": {
|
||||
"message": "Величина картице",
|
||||
"description": "Label for the text box controlling tab size option for the style editor."
|
||||
},
|
||||
"enableStyleLabel": {
|
||||
"message": "Омогући",
|
||||
"description": "Label for the button to enable a style"
|
||||
},
|
||||
"styleMissingName": {
|
||||
"message": "Унесите назив",
|
||||
"description": "Error displayed when user saves without providing a name"
|
||||
},
|
||||
"appliesDomainOption": {
|
||||
"message": "УРЛ адресе на домену",
|
||||
"description": "Option to make the style apply to the entered string as a domain"
|
||||
},
|
||||
"checkForUpdate": {
|
||||
"message": "Проверите ажурирање",
|
||||
"description": "Label for the button to check a single style for an update"
|
||||
},
|
||||
"importAppendLabel": {
|
||||
"message": "Додај стилу",
|
||||
"description": "Label for the button to import a style and append to the existing sections"
|
||||
},
|
||||
"updateAllCheckSucceededNoUpdate": {
|
||||
"message": "Сви стилови су ажурирани.",
|
||||
"description": "Text that displays when an update all check completed and no updates are available"
|
||||
},
|
||||
"styleFromMozillaFormatPrompt": {
|
||||
"message": "Налепи код у Mozilla формату",
|
||||
"description": "Prompt in the dialog displayed after clicking 'Import from Mozilla format' button"
|
||||
},
|
||||
"helpAlt": {
|
||||
"message": "Помоћ",
|
||||
"description": "Alternate text for help buttons"
|
||||
},
|
||||
"search": {
|
||||
"message": "Претражи",
|
||||
"description": "Label before the search input field in the editor shown on Ctrl-F"
|
||||
},
|
||||
"confirmYes": {
|
||||
"message": "Да",
|
||||
"description": "'Yes' button in a confirm dialog"
|
||||
},
|
||||
"findStylesForSite": {
|
||||
"message": "Пронађи још стилова за овај сајт",
|
||||
"description": "Text for a link that gets a list of styles for the current site"
|
||||
},
|
||||
"manageHeading": {
|
||||
"message": "Инсталирани стилови",
|
||||
"description": "Heading for the manage page"
|
||||
},
|
||||
"styleBeautify": {
|
||||
"message": "Улепшај",
|
||||
"description": "Label for the CSS-beautifier button on the edit style page"
|
||||
},
|
||||
"styleEnabledLabel": {
|
||||
"message": "Омогућено",
|
||||
"description": "Label for the enabled state of styles"
|
||||
},
|
||||
"styleToMozillaFormatHelp": {
|
||||
"message": "Mozilla формат кода се може користити у Stylish за Firefox и може се послати на userstyles.org.",
|
||||
"description": "Help info for the Mozilla format header section that converts the code to/from Mozilla format"
|
||||
},
|
||||
"sectionAdd": {
|
||||
"message": "Додај нови одељак",
|
||||
"description": "Label for the button to add a section"
|
||||
},
|
||||
"styleSaveLabel": {
|
||||
"message": "Сачувај",
|
||||
"description": "Label for save button for style editing"
|
||||
},
|
||||
"confirmStop": {
|
||||
"message": "Заустави",
|
||||
"description": "'Stop' button in a confirm dialog"
|
||||
},
|
||||
"writeStyleForURL": {
|
||||
"message": "ову УРЛ адресу",
|
||||
"description": "Text for link in toolbar pop-up to write a new style for the current URL"
|
||||
},
|
||||
"appliesAdd": {
|
||||
"message": "Додај",
|
||||
"description": "Label for the button to add an 'applies' entry"
|
||||
},
|
||||
"appliesRegexpOption": {
|
||||
"message": "УРЛ адресе које одговарају регуларном изразу",
|
||||
"description": "Option to make the style apply to the entered string as a regular expression"
|
||||
},
|
||||
"styleInstall": {
|
||||
"message": "Инсталирати '$stylename$' у Stylus?",
|
||||
"description": "Confirmation when installing a style",
|
||||
"placeholders": {
|
||||
"stylename": {
|
||||
"content": "$1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"manageText": {
|
||||
"message": "<a href='https://userstyles.org'>Преузмите стилове са userstyles.org</a> | <a href='http://add0n.com/stylus.html'>Помоћ</a>",
|
||||
"description": "Help text on the manage page"
|
||||
},
|
||||
"linterIssuesHelp": {
|
||||
"message": "Проблем пронађен од стране $link$:",
|
||||
"description": "Help popup message for the selected CSS linter issues block on the style edit page",
|
||||
"placeholders": {
|
||||
"link": {
|
||||
"content": "$1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"searchStyles": {
|
||||
"message": "Претражи садржај",
|
||||
"description": "Label for the search filter textbox on the Manage styles page"
|
||||
},
|
||||
"disableStyleLabel": {
|
||||
"message": "Онемогући",
|
||||
"description": "Label for the button to disable a style"
|
||||
},
|
||||
"prefShowBadge": {
|
||||
"message": "Прикажи број активних стилова за тренутни сајт на дугмету на алатној траци",
|
||||
"description": "Label for the checkbox controlling toolbar badge text."
|
||||
},
|
||||
"menuShowBadge": {
|
||||
"message": "Прикажи број активних стилова",
|
||||
"description": "Label (must be very short) for the checkbox in the toolbar button context menu controlling toolbar badge text."
|
||||
},
|
||||
"cm_lineWrapping": {
|
||||
"message": "Преламање текста",
|
||||
"description": "Label for the checkbox controlling word wrap option for the style editor."
|
||||
},
|
||||
"styleCancelEditLabel": {
|
||||
"message": "Назад на управљање",
|
||||
"description": "Label for cancel button for style editing"
|
||||
},
|
||||
"styleChangesNotSaved": {
|
||||
"message": "Направили сте измене овог стила које нисте сачували.",
|
||||
"description": "Text for the prompt when changes are made to a style and the user tries to leave without saving"
|
||||
},
|
||||
"importLabel": {
|
||||
"message": "Увези",
|
||||
"description": "Label for the button to import a style ('edit' page) or all styles ('manage' page)"
|
||||
},
|
||||
"updateCheckFailServerUnreachable": {
|
||||
"message": "Ажурирање није успело: сервер није доступан.",
|
||||
"description": "Text that displays when an update check failed because the update server is unreachable"
|
||||
},
|
||||
"manageFilters": {
|
||||
"message": "Филтери",
|
||||
"description": "Label for filters container"
|
||||
},
|
||||
"applyAllUpdates": {
|
||||
"message": "Примени сва ажурирања",
|
||||
"description": "Label for the button to apply all detected updates"
|
||||
},
|
||||
"deleteStyleConfirm": {
|
||||
"message": "Да ли сте сигурни да желите да избришете овај стил?",
|
||||
"description": "Confirmation before deleting a style"
|
||||
},
|
||||
"styleBadRegexp": {
|
||||
"message": "Регуларни израз је неисправан.",
|
||||
"description": "Validation message for a bad regexp in a style"
|
||||
},
|
||||
"optionsHeading": {
|
||||
"message": "Опције",
|
||||
"description": "Heading for options section on manage page."
|
||||
},
|
||||
"appliesDisplay": {
|
||||
"message": "Примењује се на: $applies$",
|
||||
"description": "Text on the manage screen to describe what the style applies to",
|
||||
"placeholders": {
|
||||
"applies": {
|
||||
"content": "$1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"styleUpdate": {
|
||||
"message": "Да ли сте сигурни да желите да ажурирате '$stylename$'?",
|
||||
"description": "Confirmation when updating a style",
|
||||
"placeholders": {
|
||||
"stylename": {
|
||||
"content": "$1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"styleSectionsTitle": {
|
||||
"message": "Одељци",
|
||||
"description": "Title for the style sections section"
|
||||
},
|
||||
"editStyleTitle": {
|
||||
"message": "Уреди стил $stylename$",
|
||||
"description": "Title of the page for editing styles",
|
||||
"placeholders": {
|
||||
"stylename": {
|
||||
"content": "$1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"updateCheckSucceededNoUpdate": {
|
||||
"message": "Стил је ажуриран.",
|
||||
"description": "Text that displays when an update check completed and no update is available"
|
||||
},
|
||||
"appliesUrlPrefixOption": {
|
||||
"message": "УРЛ адресе које почињу са",
|
||||
"description": "Option to make the style apply to the entered string as a URL prefix"
|
||||
},
|
||||
"searchRegexp": {
|
||||
"message": "Користи /re/ синтаксу за претрагу регуларним изразом",
|
||||
"description": "Label after the search input field in the editor shown on Ctrl-F"
|
||||
},
|
||||
"importReplaceTooltip": {
|
||||
"message": "Одбаци садржај тренутног стила и упиши преко њега увезени стил",
|
||||
"description": "Label for the button to import and overwrite current style"
|
||||
},
|
||||
"popupStylesFirst": {
|
||||
"message": "Излистај стилове пре команди у менију дугмета на алатној траци",
|
||||
"description": "Label for the checkbox controlling section order in the popup."
|
||||
},
|
||||
"sectionHelp": {
|
||||
"message": "Одељци вам омогућавају да дефинишете различите делове кода који се примењују на раличите скупове УРЛ-ова у истом стилу. На пример, један исти стил може променити почетну страницу једног сајта на један начин а остатак сајта на други начин.",
|
||||
"description": "Help text for sections"
|
||||
},
|
||||
"noStylesForSite": {
|
||||
"message": "Нема инсталираних стилова за овај сајт.",
|
||||
"description": "Text displayed when no styles are installed for the current site"
|
||||
},
|
||||
"appliesDisplayTruncatedSuffix": {
|
||||
"message": "и још",
|
||||
"description": "Text added to appliesDisplay when there are more sites for the style than are displayed"
|
||||
},
|
||||
"appliesRemove": {
|
||||
"message": "Уклони",
|
||||
"description": "Label for the button to remove an 'applies' entry"
|
||||
},
|
||||
"styleToMozillaFormatTitle": {
|
||||
"message": "Стил у Mozilla формату",
|
||||
"description": "Title of the popup with the style code in Mozilla format, shown after pressing the Export button on Edit style page"
|
||||
},
|
||||
"writeStyleFor": {
|
||||
"message": "Упиши стил за:",
|
||||
"description": "Label for toolbar pop-up that precedes the links to write a new style"
|
||||
},
|
||||
"replace": {
|
||||
"message": "Замени",
|
||||
"description": "Label before the replace input field in the editor shown on Ctrl-H"
|
||||
},
|
||||
"appliesLabel": {
|
||||
"message": "Примењује се на",
|
||||
"description": "Label for 'applies to' fields on the edit/add screen"
|
||||
},
|
||||
"openManage": {
|
||||
"message": "Управљај инсталираним стиловима",
|
||||
"description": "Link to open the manage page."
|
||||
},
|
||||
"updateCheckFailBadResponseCode": {
|
||||
"message": "Ажурирање није успело: сервер је одговорио кодом $code$.",
|
||||
"description": "Text that displays when an update check failed because the response code indicates an error",
|
||||
"placeholders": {
|
||||
"code": {
|
||||
"content": "$1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"appliesSpecify": {
|
||||
"message": "Детаљније",
|
||||
"description": "Label for the button to make a style apply only to specific sites"
|
||||
},
|
||||
"installUpdate": {
|
||||
"message": "Инсталирај ажурирање",
|
||||
"description": "Label for the button to install an update for a single style"
|
||||
},
|
||||
"styleMozillaFormatHeading": {
|
||||
"message": "Mozilla формат",
|
||||
"description": "Heading for the section with buttons to import/export Mozilla format of the style"
|
||||
},
|
||||
"sectionRemove": {
|
||||
"message": "Уклони одељак",
|
||||
"description": "Label for the button to remove a section"
|
||||
},
|
||||
"disableAllStyles": {
|
||||
"message": "Искључи све стилове",
|
||||
"description": "Label for the checkbox that turns all enabled styles off."
|
||||
},
|
||||
"undoGlobal": {
|
||||
"message": "Опозови (свеобухватно)",
|
||||
"description": "CSS-beautify global Undo button label"
|
||||
},
|
||||
"updateCompleted": {
|
||||
"message": "Ажурирање је комплетирано.",
|
||||
"description": "Text that displays when an update completed"
|
||||
},
|
||||
"checkingForUpdate": {
|
||||
"message": "Проверавање...",
|
||||
"description": "Text to display when checking a style for an update"
|
||||
},
|
||||
"sectionCode": {
|
||||
"message": "Код",
|
||||
"description": "Label for the code for a section"
|
||||
},
|
||||
"cm_smartIndent": {
|
||||
"message": "Користи паметно увлачење редова",
|
||||
"description": "Label for the checkbox controlling smart indentation option for the style editor."
|
||||
},
|
||||
"appliesHelp": {
|
||||
"message": "Употреба 'Примењује се на' одређује опсег УРЛ адреса на које се код у овом одељку примењује.",
|
||||
"description": "Help text for 'applies to' section"
|
||||
},
|
||||
"editStyleHeading": {
|
||||
"message": "Уреди стил",
|
||||
"description": "Title of the page for editing styles"
|
||||
},
|
||||
"appliesUrlOption": {
|
||||
"message": "УРЛ",
|
||||
"description": "Option to make the style apply to the entered string as a URL"
|
||||
},
|
||||
"stylusUnavailableForURL": {
|
||||
"message": "Stylus не ради на страницама као што је ова.",
|
||||
"description": "Note in the toolbar pop-up when on a URL Stylus can't affect"
|
||||
},
|
||||
"addStyleTitle": {
|
||||
"message": "Додај стил",
|
||||
"description": "Title of the page for adding styles"
|
||||
},
|
||||
"importReplaceLabel": {
|
||||
"message": "Упиши преко стила",
|
||||
"description": "Label for the button to import and overwrite current style"
|
||||
},
|
||||
"dbError": {
|
||||
"message": "Дошло је до грешке користећи Stylus базу података. Да ли желите да посетите веб страницу са могућим решењима?",
|
||||
"description": "Prompt when a DB error is encountered"
|
||||
},
|
||||
"importAppendTooltip": {
|
||||
"message": "Додај увезени стил тренутном стилу",
|
||||
"description": "Tooltip for the button to import a style and append to the existing sections"
|
||||
},
|
||||
"helpKeyMapHotkey": {
|
||||
"message": "Притисни пречицу",
|
||||
"description": "Placeholder text of inputbox in keymap help popup on the edit style page. Must be very short"
|
||||
},
|
||||
"replaceAll": {
|
||||
"message": "Замени све",
|
||||
"description": "Label before the replace input field in the editor shown on 'replaceAll' hotkey"
|
||||
},
|
||||
"editGotoLine": {
|
||||
"message": "Иди на ред (или line:col)",
|
||||
"description": "Go to line or line:column on Ctrl-G in style code editor"
|
||||
},
|
||||
"checkAllUpdates": {
|
||||
"message": "Проверите ажурирања за све стилове",
|
||||
"description": "Label for the button to check all styles for updates"
|
||||
},
|
||||
"confirmNo": {
|
||||
"message": "Не",
|
||||
"description": "'No' button in a confirm dialog"
|
||||
},
|
||||
"undo": {
|
||||
"message": "Опозови",
|
||||
"description": "Button label"
|
||||
},
|
||||
"cm_keyMap": {
|
||||
"message": "Мапа тастера",
|
||||
"description": "Label for the drop-down list controlling the keymap for the style editor."
|
||||
},
|
||||
"cm_indentWithTabs": {
|
||||
"message": "Користи картице са паметним увлачењем редова",
|
||||
"description": "Label for the checkbox controlling tabs with smart indentation option for the style editor."
|
||||
},
|
||||
"replaceWith": {
|
||||
"message": "Замени са",
|
||||
"description": "Label before the replace-with input field in the editor shown on Ctrl-H etc."
|
||||
},
|
||||
"deleteStyleLabel": {
|
||||
"message": "Избриши",
|
||||
"description": "Label for the button to delete a style"
|
||||
},
|
||||
"addStyleLabel": {
|
||||
"message": "Упиши нови стил",
|
||||
"description": "Label for the button to go to the add style page"
|
||||
},
|
||||
"manageOnlyEnabled": {
|
||||
"message": "Само омогућени стилови",
|
||||
"description": "Checkbox to show only enabled styles"
|
||||
},
|
||||
"editStyleLabel": {
|
||||
"message": "Уреди",
|
||||
"description": "Label for the button to go to the edit style page"
|
||||
},
|
||||
"cm_theme": {
|
||||
"message": "Тема",
|
||||
"description": "Label for the style editor's CSS theme."
|
||||
},
|
||||
"helpKeyMapCommand": {
|
||||
"message": "Укуцај име команде",
|
||||
"description": "Placeholder text of inputbox in keymap help popup on the edit style page. Must be very short"
|
||||
},
|
||||
"description": {
|
||||
"message": "Измените стил интернет мреже управљачем корисничких стилова. Stylus вам омогућава да лако инсталирате теме и скинове за многе популарне сајтове.",
|
||||
"description": "Extension description"
|
||||
}
|
||||
}
|
||||
"addStyleLabel": {
|
||||
"message": "Упиши нови стил"
|
||||
},
|
||||
"addStyleTitle": {
|
||||
"message": "Додај стил"
|
||||
},
|
||||
"appliesAdd": {
|
||||
"message": "Додај"
|
||||
},
|
||||
"appliesDisplay": {
|
||||
"message": "Примењује се на: $applies$",
|
||||
"placeholders": {
|
||||
"applies": {
|
||||
"content": "$1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"appliesDisplayTruncatedSuffix": {
|
||||
"message": "и још"
|
||||
},
|
||||
"appliesDomainOption": {
|
||||
"message": "УРЛ адресе на домену"
|
||||
},
|
||||
"appliesHelp": {
|
||||
"message": "Употреба 'Примењује се на' одређује опсег УРЛ адреса на које се код у овом одељку примењује."
|
||||
},
|
||||
"appliesLabel": {
|
||||
"message": "Примењује се на"
|
||||
},
|
||||
"appliesRegexpOption": {
|
||||
"message": "УРЛ адресе које одговарају регуларном изразу"
|
||||
},
|
||||
"appliesRemove": {
|
||||
"message": "Уклони"
|
||||
},
|
||||
"appliesSpecify": {
|
||||
"message": "Детаљније"
|
||||
},
|
||||
"appliesToEverything": {
|
||||
"message": "Све"
|
||||
},
|
||||
"appliesUrlOption": {
|
||||
"message": "УРЛ"
|
||||
},
|
||||
"appliesUrlPrefixOption": {
|
||||
"message": "УРЛ адресе које почињу са"
|
||||
},
|
||||
"applyAllUpdates": {
|
||||
"message": "Примени сва ажурирања"
|
||||
},
|
||||
"checkAllUpdates": {
|
||||
"message": "Проверите ажурирања за све стилове"
|
||||
},
|
||||
"checkForUpdate": {
|
||||
"message": "Проверите ажурирање"
|
||||
},
|
||||
"checkingForUpdate": {
|
||||
"message": "Проверавање..."
|
||||
},
|
||||
"cm_indentWithTabs": {
|
||||
"message": "Користи картице са паметним увлачењем редова"
|
||||
},
|
||||
"cm_keyMap": {
|
||||
"message": "Мапа тастера"
|
||||
},
|
||||
"cm_lineWrapping": {
|
||||
"message": "Преламање текста"
|
||||
},
|
||||
"cm_smartIndent": {
|
||||
"message": "Користи паметно увлачење редова"
|
||||
},
|
||||
"cm_tabSize": {
|
||||
"message": "Величина картице"
|
||||
},
|
||||
"cm_theme": {
|
||||
"message": "Тема"
|
||||
},
|
||||
"confirmDelete": {
|
||||
"message": "Избриши"
|
||||
},
|
||||
"confirmNo": {
|
||||
"message": "Не"
|
||||
},
|
||||
"confirmSave": {
|
||||
"message": "Сачувај"
|
||||
},
|
||||
"confirmStop": {
|
||||
"message": "Заустави"
|
||||
},
|
||||
"confirmYes": {
|
||||
"message": "Да"
|
||||
},
|
||||
"dbError": {
|
||||
"message": "Дошло је до грешке користећи Stylus базу података. Да ли желите да посетите веб страницу са могућим решењима?"
|
||||
},
|
||||
"defaultTheme": {
|
||||
"message": "подразумевано"
|
||||
},
|
||||
"deleteStyleConfirm": {
|
||||
"message": "Да ли сте сигурни да желите да избришете овај стил?"
|
||||
},
|
||||
"deleteStyleLabel": {
|
||||
"message": "Избриши"
|
||||
},
|
||||
"description": {
|
||||
"message": "Измените стил интернет мреже управљачем корисничких стилова. Stylus вам омогућава да лако инсталирате теме и скинове за многе популарне сајтове."
|
||||
},
|
||||
"disableAllStyles": {
|
||||
"message": "Искључи све стилове"
|
||||
},
|
||||
"disableStyleLabel": {
|
||||
"message": "Онемогући"
|
||||
},
|
||||
"editDeleteText": {
|
||||
"message": "Избриши"
|
||||
},
|
||||
"editGotoLine": {
|
||||
"message": "Иди на ред (или line:col)"
|
||||
},
|
||||
"editStyleHeading": {
|
||||
"message": "Уреди стил"
|
||||
},
|
||||
"editStyleLabel": {
|
||||
"message": "Уреди"
|
||||
},
|
||||
"editStyleTitle": {
|
||||
"message": "Уреди стил $stylename$",
|
||||
"placeholders": {
|
||||
"stylename": {
|
||||
"content": "$1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"enableStyleLabel": {
|
||||
"message": "Омогући"
|
||||
},
|
||||
"exportLabel": {
|
||||
"message": "Извези"
|
||||
},
|
||||
"genericAdd": {
|
||||
"message": "Додај"
|
||||
},
|
||||
"genericEnabledLabel": {
|
||||
"message": "Омогућено"
|
||||
},
|
||||
"helpAlt": {
|
||||
"message": "Помоћ"
|
||||
},
|
||||
"helpKeyMapCommand": {
|
||||
"message": "Укуцај име команде"
|
||||
},
|
||||
"helpKeyMapHotkey": {
|
||||
"message": "Притисни пречицу"
|
||||
},
|
||||
"importAppendLabel": {
|
||||
"message": "Додај стилу"
|
||||
},
|
||||
"importAppendTooltip": {
|
||||
"message": "Додај увезени стил тренутном стилу"
|
||||
},
|
||||
"importLabel": {
|
||||
"message": "Увези"
|
||||
},
|
||||
"importReplaceLabel": {
|
||||
"message": "Упиши преко стила"
|
||||
},
|
||||
"importReplaceTooltip": {
|
||||
"message": "Одбаци садржај тренутног стила и упиши преко њега увезени стил"
|
||||
},
|
||||
"installUpdate": {
|
||||
"message": "Инсталирај ажурирање"
|
||||
},
|
||||
"linkGetHelp": {
|
||||
"message": "Помоћ"
|
||||
},
|
||||
"linkGetStyles": {
|
||||
"message": "Преузмите стилове"
|
||||
},
|
||||
"linterIssues": {
|
||||
"message": "Проблеми"
|
||||
},
|
||||
"linterIssuesHelp": {
|
||||
"message": "Проблем пронађен од стране $link$:",
|
||||
"placeholders": {
|
||||
"link": {
|
||||
"content": "$1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"manageFilters": {
|
||||
"message": "Филтери"
|
||||
},
|
||||
"manageHeading": {
|
||||
"message": "Инсталирани стилови"
|
||||
},
|
||||
"manageOnlyEnabled": {
|
||||
"message": "Само омогућени стилови"
|
||||
},
|
||||
"menuShowBadge": {
|
||||
"message": "Прикажи број активних стилова"
|
||||
},
|
||||
"noStylesForSite": {
|
||||
"message": "Нема инсталираних стилова за овај сајт."
|
||||
},
|
||||
"openManage": {
|
||||
"message": "Управљај инсталираним стиловима"
|
||||
},
|
||||
"openOptions": {
|
||||
"message": "Опције"
|
||||
},
|
||||
"optionsHeading": {
|
||||
"message": "Опције"
|
||||
},
|
||||
"optionsSyncUrl": {
|
||||
"message": "УРЛ"
|
||||
},
|
||||
"popupStylesFirst": {
|
||||
"message": "Излистај стилове пре команди у менију дугмета на алатној траци"
|
||||
},
|
||||
"prefShowBadge": {
|
||||
"message": "Прикажи број активних стилова за тренутни сајт на дугмету на алатној траци"
|
||||
},
|
||||
"replace": {
|
||||
"message": "Замени"
|
||||
},
|
||||
"replaceAll": {
|
||||
"message": "Замени све"
|
||||
},
|
||||
"replaceWith": {
|
||||
"message": "Замени са"
|
||||
},
|
||||
"search": {
|
||||
"message": "Претражи"
|
||||
},
|
||||
"searchRegexp": {
|
||||
"message": "Користи /re/ синтаксу за претрагу регуларним изразом"
|
||||
},
|
||||
"sectionAdd": {
|
||||
"message": "Додај нови одељак"
|
||||
},
|
||||
"sectionCode": {
|
||||
"message": "Код"
|
||||
},
|
||||
"sectionRemove": {
|
||||
"message": "Уклони одељак"
|
||||
},
|
||||
"sections": {
|
||||
"message": "Одељци"
|
||||
},
|
||||
"styleBadRegexp": {
|
||||
"message": "Регуларни израз је неисправан."
|
||||
},
|
||||
"styleBeautify": {
|
||||
"message": "Улепшај"
|
||||
},
|
||||
"styleCancelEditLabel": {
|
||||
"message": "Назад на управљање"
|
||||
},
|
||||
"styleChangesNotSaved": {
|
||||
"message": "Направили сте измене овог стила које нисте сачували."
|
||||
},
|
||||
"styleEnabledLabel": {
|
||||
"message": "Омогућено"
|
||||
},
|
||||
"styleFromMozillaFormatPrompt": {
|
||||
"message": "Налепи код у Mozilla формату"
|
||||
},
|
||||
"styleInstall": {
|
||||
"message": "Инсталирати '$stylename$' у Stylus?",
|
||||
"placeholders": {
|
||||
"stylename": {
|
||||
"content": "$1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"styleMissingName": {
|
||||
"message": "Унесите назив"
|
||||
},
|
||||
"styleMozillaFormatHeading": {
|
||||
"message": "Mozilla формат"
|
||||
},
|
||||
"styleSaveLabel": {
|
||||
"message": "Сачувај"
|
||||
},
|
||||
"styleToMozillaFormatHelp": {
|
||||
"message": "Mozilla формат кода се може користити у Stylish за Firefox и може се послати на userstyles.org."
|
||||
},
|
||||
"styleToMozillaFormatTitle": {
|
||||
"message": "Стил у Mozilla формату"
|
||||
},
|
||||
"styleUpdate": {
|
||||
"message": "Да ли сте сигурни да желите да ажурирате '$stylename$'?",
|
||||
"placeholders": {
|
||||
"stylename": {
|
||||
"content": "$1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"stylusUnavailableForURL": {
|
||||
"message": "Stylus не ради на страницама као што је ова."
|
||||
},
|
||||
"undo": {
|
||||
"message": "Опозови"
|
||||
},
|
||||
"undoGlobal": {
|
||||
"message": "Опозови (свеобухватно)"
|
||||
},
|
||||
"updateAllCheckSucceededNoUpdate": {
|
||||
"message": "Сви стилови су ажурирани."
|
||||
},
|
||||
"updateCheckFailBadResponseCode": {
|
||||
"message": "Ажурирање није успело: сервер је одговорио кодом $code$.",
|
||||
"placeholders": {
|
||||
"code": {
|
||||
"content": "$1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"updateCheckFailServerUnreachable": {
|
||||
"message": "Ажурирање није успело: сервер није доступан."
|
||||
},
|
||||
"updateCheckSucceededNoUpdate": {
|
||||
"message": "Стил је ажуриран."
|
||||
},
|
||||
"updateCompleted": {
|
||||
"message": "Ажурирање је комплетирано."
|
||||
},
|
||||
"writeStyleFor": {
|
||||
"message": "Упиши стил за:"
|
||||
},
|
||||
"writeStyleForURL": {
|
||||
"message": "ову УРЛ адресу"
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,71 +1,67 @@
|
|||
{
|
||||
"appliesToEverything": {
|
||||
"message": "అన్నిటికీ",
|
||||
"description": "Text displayed for styles that apply to all sites"
|
||||
},
|
||||
"enableStyleLabel": {
|
||||
"message": "చేతనించు",
|
||||
"description": "Label for the button to enable a style"
|
||||
},
|
||||
"helpAlt": {
|
||||
"message": "సహాయం",
|
||||
"description": "Alternate text for help buttons"
|
||||
},
|
||||
"manageHeading": {
|
||||
"message": "స్థాపిత శైలులు",
|
||||
"description": "Heading for the manage page"
|
||||
},
|
||||
"styleSaveLabel": {
|
||||
"message": "భద్రపరచు",
|
||||
"description": "Label for save button for style editing"
|
||||
},
|
||||
"appliesAdd": {
|
||||
"message": "చేర్చు",
|
||||
"description": "Label for the button to add an 'applies' entry"
|
||||
},
|
||||
"disableStyleLabel": {
|
||||
"message": "అచేతనించు",
|
||||
"description": "Label for the button to disable a style"
|
||||
},
|
||||
"deleteStyleConfirm": {
|
||||
"message": "మీరు నజంగానే ఈ శైలిని తొలగించాలనుకుంటున్నారా?",
|
||||
"description": "Confirmation before deleting a style"
|
||||
},
|
||||
"appliesDisplay": {
|
||||
"message": "వేటికి వర్తిస్తుంది; $applies$",
|
||||
"description": "Text on the manage screen to describe what the style applies to",
|
||||
"placeholders": {
|
||||
"applies": {
|
||||
"content": "$1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"styleSectionsTitle": {
|
||||
"message": "విభాగాలు",
|
||||
"description": "Title for the style sections section"
|
||||
},
|
||||
"appliesDisplayTruncatedSuffix": {
|
||||
"message": "ఇంకా మరిన్ని",
|
||||
"description": "Text added to appliesDisplay when there are more sites for the style than are displayed"
|
||||
},
|
||||
"appliesRemove": {
|
||||
"message": "తొలగించు",
|
||||
"description": "Label for the button to remove an 'applies' entry"
|
||||
},
|
||||
"manageTitle": {
|
||||
"message": "స్టైలిష్",
|
||||
"description": "Title for the manage page"
|
||||
},
|
||||
"deleteStyleLabel": {
|
||||
"message": "తొలగించు",
|
||||
"description": "Label for the button to delete a style"
|
||||
},
|
||||
"addStyleLabel": {
|
||||
"message": "క్రొత్త స్టైల్ వ్రాయండి",
|
||||
"description": "Label for the button to go to the add style page"
|
||||
},
|
||||
"editStyleLabel": {
|
||||
"message": "మార్చు",
|
||||
"description": "Label for the button to go to the edit style page"
|
||||
}
|
||||
}
|
||||
"addStyleLabel": {
|
||||
"message": "క్రొత్త స్టైల్ వ్రాయండి"
|
||||
},
|
||||
"appliesAdd": {
|
||||
"message": "చేర్చు"
|
||||
},
|
||||
"appliesDisplay": {
|
||||
"message": "వేటికి వర్తిస్తుంది; $applies$",
|
||||
"placeholders": {
|
||||
"applies": {
|
||||
"content": "$1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"appliesDisplayTruncatedSuffix": {
|
||||
"message": "ఇంకా మరిన్ని"
|
||||
},
|
||||
"appliesRemove": {
|
||||
"message": "తొలగించు"
|
||||
},
|
||||
"appliesToEverything": {
|
||||
"message": "అన్నిటికీ"
|
||||
},
|
||||
"confirmDelete": {
|
||||
"message": "తొలగించు"
|
||||
},
|
||||
"confirmSave": {
|
||||
"message": "భద్రపరచు"
|
||||
},
|
||||
"deleteStyleConfirm": {
|
||||
"message": "మీరు నజంగానే ఈ శైలిని తొలగించాలనుకుంటున్నారా?"
|
||||
},
|
||||
"deleteStyleLabel": {
|
||||
"message": "తొలగించు"
|
||||
},
|
||||
"disableStyleLabel": {
|
||||
"message": "అచేతనించు"
|
||||
},
|
||||
"editDeleteText": {
|
||||
"message": "తొలగించు"
|
||||
},
|
||||
"editStyleLabel": {
|
||||
"message": "మార్చు"
|
||||
},
|
||||
"enableStyleLabel": {
|
||||
"message": "చేతనించు"
|
||||
},
|
||||
"genericAdd": {
|
||||
"message": "చేర్చు"
|
||||
},
|
||||
"helpAlt": {
|
||||
"message": "సహాయం"
|
||||
},
|
||||
"manageHeading": {
|
||||
"message": "స్థాపిత శైలులు"
|
||||
},
|
||||
"manageTitle": {
|
||||
"message": "స్టైలిష్"
|
||||
},
|
||||
"sections": {
|
||||
"message": "విభాగాలు"
|
||||
},
|
||||
"styleSaveLabel": {
|
||||
"message": "భద్రపరచు"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,206 +1,791 @@
|
|||
{
|
||||
"appliesToEverything": {
|
||||
"message": "Her şey",
|
||||
"description": "Text displayed for styles that apply to all sites"
|
||||
},
|
||||
"enableStyleLabel": {
|
||||
"message": "Etkinleştir",
|
||||
"description": "Label for the button to enable a style"
|
||||
},
|
||||
"styleMissingName": {
|
||||
"message": "Bir ad girin.",
|
||||
"description": "Error displayed when user saves without providing a name"
|
||||
},
|
||||
"appliesDomainOption": {
|
||||
"message": "Alan adındaki URLler",
|
||||
"description": "Option to make the style apply to the entered string as a domain"
|
||||
},
|
||||
"checkForUpdate": {
|
||||
"message": "Güncellemeleri denetle",
|
||||
"description": "Label for the button to check a single style for an update"
|
||||
},
|
||||
"helpAlt": {
|
||||
"message": "Yardım",
|
||||
"description": "Alternate text for help buttons"
|
||||
},
|
||||
"findStylesForSite": {
|
||||
"message": "Bu site için başka stiller bul",
|
||||
"description": "Text for a link that gets a list of styles for the current site"
|
||||
},
|
||||
"manageHeading": {
|
||||
"message": "Yüklü Stiller",
|
||||
"description": "Heading for the manage page"
|
||||
},
|
||||
"styleEnabledLabel": {
|
||||
"message": "Etkin",
|
||||
"description": "Label for the enabled state of styles"
|
||||
},
|
||||
"styleToMozillaFormatHelp": {
|
||||
"message": "Kodun Mozilla biçimi, Firefox için Stylish ile kullanılabilir ve userstyles.org sitesine gönderilebilir.",
|
||||
"description": "Help info for the Mozilla format header section that converts the code to/from Mozilla format"
|
||||
},
|
||||
"sectionAdd": {
|
||||
"message": "Başka bölüm ekle",
|
||||
"description": "Label for the button to add a section"
|
||||
},
|
||||
"styleSaveLabel": {
|
||||
"message": "Kaydet",
|
||||
"description": "Label for save button for style editing"
|
||||
},
|
||||
"appliesAdd": {
|
||||
"message": "Ekleyin",
|
||||
"description": "Label for the button to add an 'applies' entry"
|
||||
},
|
||||
"appliesRegexpOption": {
|
||||
"message": "regexp ile eşleşen URL'ler",
|
||||
"description": "Option to make the style apply to the entered string as a regular expression"
|
||||
},
|
||||
"styleInstall": {
|
||||
"message": "'$stylename$' Stylus'e yüklensin mi?",
|
||||
"description": "Confirmation when installing a style",
|
||||
"placeholders": {
|
||||
"stylename": {
|
||||
"content": "$1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"disableStyleLabel": {
|
||||
"message": "Devre dışı bırak",
|
||||
"description": "Label for the button to disable a style"
|
||||
},
|
||||
"styleCancelEditLabel": {
|
||||
"message": "Yönetim sayfasına dön",
|
||||
"description": "Label for cancel button for style editing"
|
||||
},
|
||||
"styleChangesNotSaved": {
|
||||
"message": "Bu stilde yaptığınız, kaydedilmemiş değişiklikler var.",
|
||||
"description": "Text for the prompt when changes are made to a style and the user tries to leave without saving"
|
||||
},
|
||||
"updateCheckFailServerUnreachable": {
|
||||
"message": "Güncellenemedi: sunucuya erişilemiyor.",
|
||||
"description": "Text that displays when an update check failed because the update server is unreachable"
|
||||
},
|
||||
"deleteStyleConfirm": {
|
||||
"message": "Bu stili silmek istediğinizden emin misiniz?",
|
||||
"description": "Confirmation before deleting a style"
|
||||
},
|
||||
"appliesDisplay": {
|
||||
"message": "Şuraya uygulanır: $applies$",
|
||||
"description": "Text on the manage screen to describe what the style applies to",
|
||||
"placeholders": {
|
||||
"applies": {
|
||||
"content": "$1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"styleSectionsTitle": {
|
||||
"message": "Bölümler",
|
||||
"description": "Title for the style sections section"
|
||||
},
|
||||
"editStyleTitle": {
|
||||
"message": "$stylename$ Stilini Düzenleyin",
|
||||
"description": "Title of the page for editing styles",
|
||||
"placeholders": {
|
||||
"stylename": {
|
||||
"content": "$1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"updateCheckSucceededNoUpdate": {
|
||||
"message": "Stil güncel.",
|
||||
"description": "Text that displays when an update check completed and no update is available"
|
||||
},
|
||||
"appliesUrlPrefixOption": {
|
||||
"message": "Şununla başlayan URL'ler:",
|
||||
"description": "Option to make the style apply to the entered string as a URL prefix"
|
||||
},
|
||||
"sectionHelp": {
|
||||
"message": "Bölümler, aynı stil içindeki farklı URL kümelerine uygulanacak farklı kod parçaları tanımlamanıza olanak sağlar. Örneğin, tek bir stil bir sitenin ana sayfasını belirli bir şekilde değiştirirken, sayfanın kalan kısmını farklı bir şekilde değiştirebilir.",
|
||||
"description": "Help text for sections"
|
||||
},
|
||||
"noStylesForSite": {
|
||||
"message": "Bu site için hiçbir stil yüklenmedi.",
|
||||
"description": "Text displayed when no styles are installed for the current site"
|
||||
},
|
||||
"appliesDisplayTruncatedSuffix": {
|
||||
"message": "ve diğerleri",
|
||||
"description": "Text added to appliesDisplay when there are more sites for the style than are displayed"
|
||||
},
|
||||
"appliesRemove": {
|
||||
"message": "Kaldır",
|
||||
"description": "Label for the button to remove an 'applies' entry"
|
||||
},
|
||||
"appliesLabel": {
|
||||
"message": "Şuraya uygulanır",
|
||||
"description": "Label for 'applies to' fields on the edit/add screen"
|
||||
},
|
||||
"openManage": {
|
||||
"message": "Yüklü stilleri yönet",
|
||||
"description": "Link to open the manage page."
|
||||
},
|
||||
"updateCheckFailBadResponseCode": {
|
||||
"message": "Güncellenemedi: sunucu yanıt olarak $code$ kodunu gönderdi.",
|
||||
"description": "Text that displays when an update check failed because the response code indicates an error",
|
||||
"placeholders": {
|
||||
"code": {
|
||||
"content": "$1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"appliesSpecify": {
|
||||
"message": "Belirt",
|
||||
"description": "Label for the button to make a style apply only to specific sites"
|
||||
},
|
||||
"installUpdate": {
|
||||
"message": "Güncellemeyi yükle",
|
||||
"description": "Label for the button to install an update for a single style"
|
||||
},
|
||||
"sectionRemove": {
|
||||
"message": "Bölümü kaldır",
|
||||
"description": "Label for the button to remove a section"
|
||||
},
|
||||
"updateCompleted": {
|
||||
"message": "Güncelleme tamamlandı.",
|
||||
"description": "Text that displays when an update completed"
|
||||
},
|
||||
"checkingForUpdate": {
|
||||
"message": "Kontrol ediliyor...",
|
||||
"description": "Text to display when checking a style for an update"
|
||||
},
|
||||
"sectionCode": {
|
||||
"message": "Kod",
|
||||
"description": "Label for the code for a section"
|
||||
},
|
||||
"appliesHelp": {
|
||||
"message": "Bu bölümdeki kodun hangi URLlere uygulanacağını sınırlamak için 'Şuraya uygulanır' denetimlerini kullanın.",
|
||||
"description": "Help text for 'applies to' section"
|
||||
},
|
||||
"editStyleHeading": {
|
||||
"message": "Stili Düzenle",
|
||||
"description": "Title of the page for editing styles"
|
||||
},
|
||||
"addStyleTitle": {
|
||||
"message": "Stil Ekleyin",
|
||||
"description": "Title of the page for adding styles"
|
||||
},
|
||||
"checkAllUpdates": {
|
||||
"message": "Tüm stiller için güncellemeleri denetle",
|
||||
"description": "Label for the button to check all styles for updates"
|
||||
},
|
||||
"deleteStyleLabel": {
|
||||
"message": "Sil",
|
||||
"description": "Label for the button to delete a style"
|
||||
},
|
||||
"addStyleLabel": {
|
||||
"message": "Yeni stil oluşturun",
|
||||
"description": "Label for the button to go to the add style page"
|
||||
},
|
||||
"editStyleLabel": {
|
||||
"message": "Düzenle",
|
||||
"description": "Label for the button to go to the edit style page"
|
||||
},
|
||||
"description": {
|
||||
"message": "Kullanıcı stil yöneticisi Stylus ile Web'in stilini yenileyin. Stylus Google, Facebook, YouTube, Orkut ve diğer pek çok site için temalar ve görünüm yüklemenize imkân tanır.",
|
||||
"description": "Extension description"
|
||||
}
|
||||
}
|
||||
"addStyleLabel": {
|
||||
"message": "Yeni stil oluşturun"
|
||||
},
|
||||
"addStyleTitle": {
|
||||
"message": "Stil Ekleyin"
|
||||
},
|
||||
"alphaChannel": {
|
||||
"message": "Opaklık"
|
||||
},
|
||||
"appliesAdd": {
|
||||
"message": "Ekleyin"
|
||||
},
|
||||
"appliesDisplay": {
|
||||
"message": "Şuraya uygulanır: $applies$",
|
||||
"placeholders": {
|
||||
"applies": {
|
||||
"content": "$1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"appliesDisplayTruncatedSuffix": {
|
||||
"message": "ve diğerleri"
|
||||
},
|
||||
"appliesDomainOption": {
|
||||
"message": "Alan adındaki URLler"
|
||||
},
|
||||
"appliesHelp": {
|
||||
"message": "Bu bölümdeki kodun hangi URLlere uygulanacağını sınırlamak için 'Şuraya uygulanır' denetimlerini kullanın."
|
||||
},
|
||||
"appliesLabel": {
|
||||
"message": "Şuraya uygulanır"
|
||||
},
|
||||
"appliesLineWidgetWarning": {
|
||||
"message": "Küçültülmüş CSS ile çalışmaz"
|
||||
},
|
||||
"appliesRegexpOption": {
|
||||
"message": "regexp ile eşleşen URL'ler"
|
||||
},
|
||||
"appliesRemove": {
|
||||
"message": "Kaldır"
|
||||
},
|
||||
"appliesSpecify": {
|
||||
"message": "Belirt"
|
||||
},
|
||||
"appliesToEverything": {
|
||||
"message": "Her şey"
|
||||
},
|
||||
"appliesUrlPrefixOption": {
|
||||
"message": "Şununla başlayan URL'ler:"
|
||||
},
|
||||
"applyAllUpdates": {
|
||||
"message": "Tüm güncellemeleri uygula"
|
||||
},
|
||||
"author": {
|
||||
"message": "Yazar"
|
||||
},
|
||||
"backupButtons": {
|
||||
"message": "Yedek"
|
||||
},
|
||||
"bckpInstStyles": {
|
||||
"message": "Dışa aktar"
|
||||
},
|
||||
"checkAllUpdates": {
|
||||
"message": "Tüm stiller için güncellemeleri denetle"
|
||||
},
|
||||
"checkAllUpdatesForce": {
|
||||
"message": "Tekrar kontrol et, herhangi bir stil düzenlemedim!"
|
||||
},
|
||||
"checkForUpdate": {
|
||||
"message": "Güncellemeleri denetle"
|
||||
},
|
||||
"checkingForUpdate": {
|
||||
"message": "Kontrol ediliyor..."
|
||||
},
|
||||
"clickToUninstall": {
|
||||
"message": "Kaldırmak için tıklayın"
|
||||
},
|
||||
"cm_autoCloseBrackets": {
|
||||
"message": "Parantezleri ve tırnak işaretlerini otomatik olarak kapat"
|
||||
},
|
||||
"cm_autoCloseBracketsTooltip": {
|
||||
"message": "()[]{}''\"\" Açılışlarından birini yazarken otomatik olarak bir kapanış çifti ekleyin"
|
||||
},
|
||||
"cm_autocompleteOnTyping": {
|
||||
"message": "Yazarken tamamla"
|
||||
},
|
||||
"cm_colorpicker": {
|
||||
"message": "CSS renk seçicileri"
|
||||
},
|
||||
"cm_indentWithTabs": {
|
||||
"message": "Akıllı girintili tab kullan"
|
||||
},
|
||||
"cm_keyMap": {
|
||||
"message": "Tuşeşlem"
|
||||
},
|
||||
"cm_lineWrapping": {
|
||||
"message": "Kelime kaydırma"
|
||||
},
|
||||
"cm_matchHighlight": {
|
||||
"message": "Vurgulama"
|
||||
},
|
||||
"cm_matchHighlightSelection": {
|
||||
"message": "Yalnızca seçim"
|
||||
},
|
||||
"cm_matchHighlightToken": {
|
||||
"message": "İmleç altındaki token"
|
||||
},
|
||||
"cm_resizeGripHint": {
|
||||
"message": "Yüksekliği en üst düzeye çıkarmak/geri yüklemek için çift tıklayın"
|
||||
},
|
||||
"cm_selectByTokens": {
|
||||
"message": "Çift tıklamak tokenleri seçer"
|
||||
},
|
||||
"cm_selectByTokensTooltip": {
|
||||
"message": "Token örnekleri: .foo-bar-2 #aabbcc 0.32 !important\nDevre dışı bırakıldığında: noktalama işareti ile ayrılmış kelimeler seçilir."
|
||||
},
|
||||
"cm_smartIndent": {
|
||||
"message": "Akıllı girinti kullanma"
|
||||
},
|
||||
"cm_tabSize": {
|
||||
"message": "Tab büyüklüğü"
|
||||
},
|
||||
"cm_theme": {
|
||||
"message": "Tema"
|
||||
},
|
||||
"colorpickerSwitchFormatTooltip": {
|
||||
"message": "Format değişimleri: HEX -> RGB -> HSL.\nYönü ters çevirmek için Shift tuşunu basılı tutup tıklatın.\nAyrıca PgUp (PageUp), PgDn (PageDown) tuşları ile."
|
||||
},
|
||||
"colorpickerTooltip": {
|
||||
"message": "Renk seçiciyi aç"
|
||||
},
|
||||
"configOnChange": {
|
||||
"message": "değişiklikte"
|
||||
},
|
||||
"configOnChangeTooltip": {
|
||||
"message": "Otomatik kaydetme ve değişiklikleri otomatik olarak uygulama"
|
||||
},
|
||||
"configureStyle": {
|
||||
"message": "Yapılandır"
|
||||
},
|
||||
"configureStyleOnHomepage": {
|
||||
"message": "Ana sayfada yapılandır"
|
||||
},
|
||||
"confirmCancel": {
|
||||
"message": "İptal"
|
||||
},
|
||||
"confirmClose": {
|
||||
"message": "Kapat"
|
||||
},
|
||||
"confirmDefault": {
|
||||
"message": "Öntanımlıyı kullan"
|
||||
},
|
||||
"confirmDelete": {
|
||||
"message": "Sil"
|
||||
},
|
||||
"confirmDiscardChanges": {
|
||||
"message": "Değişiklikleri iptal et?"
|
||||
},
|
||||
"confirmNo": {
|
||||
"message": "Hayır"
|
||||
},
|
||||
"confirmOK": {
|
||||
"message": "Tamam"
|
||||
},
|
||||
"confirmSave": {
|
||||
"message": "Kaydet"
|
||||
},
|
||||
"confirmStop": {
|
||||
"message": "Dur"
|
||||
},
|
||||
"confirmYes": {
|
||||
"message": "Evet"
|
||||
},
|
||||
"connectingDropbox": {
|
||||
"message": "Dropbox'a bağlanıyor..."
|
||||
},
|
||||
"connectingDropboxNotAllowed": {
|
||||
"message": "Dropbox'a bağlanmak yalnızca doğrudan web mağazasından yüklenen uygulamalarda kullanılabilir"
|
||||
},
|
||||
"copied": {
|
||||
"message": "Kopyalandı"
|
||||
},
|
||||
"copy": {
|
||||
"message": "Kopyala"
|
||||
},
|
||||
"dateInstalled": {
|
||||
"message": "Kurulum tarihi"
|
||||
},
|
||||
"dateUpdated": {
|
||||
"message": "Güncelleme tarihi"
|
||||
},
|
||||
"dbError": {
|
||||
"message": "Stylus veritabanı kullanılırken bir hata oluştu. Olası çözümler içeren bir web sayfasını ziyaret etmek ister misiniz?"
|
||||
},
|
||||
"defaultTheme": {
|
||||
"message": "öntanımlı"
|
||||
},
|
||||
"deleteStyleConfirm": {
|
||||
"message": "Bu stili silmek istediğinizden emin misiniz?"
|
||||
},
|
||||
"deleteStyleLabel": {
|
||||
"message": "Sil"
|
||||
},
|
||||
"description": {
|
||||
"message": "Kullanıcı stil yöneticisi Stylus ile Web'in stilini yenileyin. Stylus Google, Facebook, YouTube, Orkut ve diğer pek çok site için temalar ve görünüm yüklemenize imkân tanır."
|
||||
},
|
||||
"disableAllStyles": {
|
||||
"message": "Tüm stilleri kapat"
|
||||
},
|
||||
"disableStyleLabel": {
|
||||
"message": "Devre dışı bırak"
|
||||
},
|
||||
"dragDropMessage": {
|
||||
"message": "İçe aktarmak için yedek dosyanızı bu sayfada herhangi bir yere bırakın."
|
||||
},
|
||||
"dragDropUsercssTabstrip": {
|
||||
"message": "Dosyayı yüklemek için sekme şeridine (sekme başlıklarının gösterildiği alan) bırakın."
|
||||
},
|
||||
"editDeleteText": {
|
||||
"message": "Sil"
|
||||
},
|
||||
"editGotoLine": {
|
||||
"message": "Satıra git (veya satır:sütun)"
|
||||
},
|
||||
"editStyleHeading": {
|
||||
"message": "Stili Düzenle"
|
||||
},
|
||||
"editStyleLabel": {
|
||||
"message": "Düzenle"
|
||||
},
|
||||
"editStyleTitle": {
|
||||
"message": "$stylename$ Stilini Düzenleyin",
|
||||
"placeholders": {
|
||||
"stylename": {
|
||||
"content": "$1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"enableStyleLabel": {
|
||||
"message": "Etkinleştir"
|
||||
},
|
||||
"excludeStyleByDomainLabel": {
|
||||
"message": "Mevcut alan adını hariç tut"
|
||||
},
|
||||
"excludeStyleByUrlLabel": {
|
||||
"message": "Mevcut URL'yi hariç tut"
|
||||
},
|
||||
"exportLabel": {
|
||||
"message": "Dışa aktar"
|
||||
},
|
||||
"exportSavedSuccess": {
|
||||
"message": "Dosya başarıyla kaydedildi"
|
||||
},
|
||||
"externalFeedback": {
|
||||
"message": "Geribildirim"
|
||||
},
|
||||
"externalHomepage": {
|
||||
"message": "Anasayfa"
|
||||
},
|
||||
"externalLink": {
|
||||
"message": "Harici bağlantı"
|
||||
},
|
||||
"externalSupport": {
|
||||
"message": "Destek"
|
||||
},
|
||||
"externalUsercssDocument": {
|
||||
"message": "Usercss belgeleri"
|
||||
},
|
||||
"filteredStyles": {
|
||||
"message": "Toplam $numTotal$ gösterilen $numShown$",
|
||||
"placeholders": {
|
||||
"numShown": {
|
||||
"content": "$1"
|
||||
},
|
||||
"numTotal": {
|
||||
"content": "$2"
|
||||
}
|
||||
}
|
||||
},
|
||||
"filteredStylesAllHidden": {
|
||||
"message": "Şu anda uygulanan filtreler hiçbir stille eşleşmiyor"
|
||||
},
|
||||
"findStyles": {
|
||||
"message": "Stil bul"
|
||||
},
|
||||
"genericAdd": {
|
||||
"message": "Ekle"
|
||||
},
|
||||
"genericClone": {
|
||||
"message": "Klon"
|
||||
},
|
||||
"genericDisabledLabel": {
|
||||
"message": "Devre dışı"
|
||||
},
|
||||
"genericEnabledLabel": {
|
||||
"message": "Etkin"
|
||||
},
|
||||
"genericError": {
|
||||
"message": "Hata"
|
||||
},
|
||||
"genericHistoryLabel": {
|
||||
"message": "Geçmiş"
|
||||
},
|
||||
"genericNext": {
|
||||
"message": "Sonraki"
|
||||
},
|
||||
"genericPrevious": {
|
||||
"message": "Önceki"
|
||||
},
|
||||
"genericResetLabel": {
|
||||
"message": "Yenile"
|
||||
},
|
||||
"genericSavedMessage": {
|
||||
"message": "Kaydedildi"
|
||||
},
|
||||
"genericTitle": {
|
||||
"message": "Başlık"
|
||||
},
|
||||
"genericUnknown": {
|
||||
"message": "Bilinmiyor"
|
||||
},
|
||||
"gettingStyles": {
|
||||
"message": "Tüm stiller alınıyor..."
|
||||
},
|
||||
"helpAlt": {
|
||||
"message": "Yardım"
|
||||
},
|
||||
"helpKeyMapCommand": {
|
||||
"message": "Bir komut adı yazın"
|
||||
},
|
||||
"helpKeyMapHotkey": {
|
||||
"message": "Bir kısayol tuşuna basın"
|
||||
},
|
||||
"hostDisabled": {
|
||||
"message": "Bu ana bilgisayar, kullanılan tarayıcının mevcut sürümündeki bir hata nedeniyle devre dışı bırakıldı"
|
||||
},
|
||||
"importAppendLabel": {
|
||||
"message": "Stile ekle"
|
||||
},
|
||||
"importAppendTooltip": {
|
||||
"message": "İçe aktarılan stili geçerli stile ekleme"
|
||||
},
|
||||
"importLabel": {
|
||||
"message": "İçe aktar"
|
||||
},
|
||||
"importReplaceLabel": {
|
||||
"message": "Stilin üzerine yaz"
|
||||
},
|
||||
"importReplaceTooltip": {
|
||||
"message": "Geçerli stilin içeriğini atın ve içe aktarılan stil ile üzerine yazın"
|
||||
},
|
||||
"importReportLegendAdded": {
|
||||
"message": "eklendi"
|
||||
},
|
||||
"importReportLegendIdentical": {
|
||||
"message": "Özdeş olan atlandı"
|
||||
},
|
||||
"importReportLegendInvalid": {
|
||||
"message": "geçersiz olan atlandı"
|
||||
},
|
||||
"importReportLegendUpdatedBoth": {
|
||||
"message": "hem meta bilgi hem de kod güncellendi"
|
||||
},
|
||||
"importReportLegendUpdatedCode": {
|
||||
"message": "güncellenmiş kod"
|
||||
},
|
||||
"importReportTitle": {
|
||||
"message": "Stillerin içeri aktarılması tamamlandı."
|
||||
},
|
||||
"importReportUnchanged": {
|
||||
"message": "Hiçbir şey değiştirilmedi."
|
||||
},
|
||||
"importReportUndone": {
|
||||
"message": "stiller geri çevrildi"
|
||||
},
|
||||
"importReportUndoneTitle": {
|
||||
"message": "İçe aktarma geri alındı"
|
||||
},
|
||||
"installButton": {
|
||||
"message": "Stil kur"
|
||||
},
|
||||
"installButtonInstalled": {
|
||||
"message": "Stil kuruldu"
|
||||
},
|
||||
"installButtonReinstall": {
|
||||
"message": "Stili yeniden kur"
|
||||
},
|
||||
"installButtonUpdate": {
|
||||
"message": "Stili güncelle"
|
||||
},
|
||||
"installUpdate": {
|
||||
"message": "Güncellemeyi yükle"
|
||||
},
|
||||
"installUpdateFromLabel": {
|
||||
"message": "Güncellemeleri denetle"
|
||||
},
|
||||
"license": {
|
||||
"message": "Lisans"
|
||||
},
|
||||
"linkGetHelp": {
|
||||
"message": "Destek al"
|
||||
},
|
||||
"linkStylusWiki": {
|
||||
"message": "Viki"
|
||||
},
|
||||
"linkTranslate": {
|
||||
"message": "Çevir"
|
||||
},
|
||||
"linterIssues": {
|
||||
"message": "Sorunlar"
|
||||
},
|
||||
"manageFaviconsGray": {
|
||||
"message": "Gri renkte"
|
||||
},
|
||||
"manageFaviconsHelp": {
|
||||
"message": "Stylus harici bir servis kullanır https://icons.duckduckgo.com"
|
||||
},
|
||||
"manageFilters": {
|
||||
"message": "Filtreler"
|
||||
},
|
||||
"manageHeading": {
|
||||
"message": "Yüklü Stiller"
|
||||
},
|
||||
"manageMaxTargets": {
|
||||
"message": "Uygulanan ögelerin sayısı"
|
||||
},
|
||||
"manageNewUI": {
|
||||
"message": "Yeni yönetim ara yüzü düzeni"
|
||||
},
|
||||
"manageOnlyEnabled": {
|
||||
"message": "Yalnızca etkin stiller"
|
||||
},
|
||||
"manageOnlyLocal": {
|
||||
"message": "Yalnızca yerelde oluşturulmuş stiller"
|
||||
},
|
||||
"manageOnlyLocalTooltip": {
|
||||
"message": "Stiller, bir userstyles.org sayfası üzerinden yülenmemiş."
|
||||
},
|
||||
"manageOnlyUpdates": {
|
||||
"message": "Sadece güncellemeler ya da sorunlar ile"
|
||||
},
|
||||
"menuShowBadge": {
|
||||
"message": "Etkin stil sayısını göster"
|
||||
},
|
||||
"noFileToImport": {
|
||||
"message": "Stillerinizi içe aktarmak için önce dışa aktarmanız gerekir."
|
||||
},
|
||||
"noStylesForSite": {
|
||||
"message": "Bu site için hiçbir stil yüklenmedi."
|
||||
},
|
||||
"openManage": {
|
||||
"message": "Yüklü stilleri yönet"
|
||||
},
|
||||
"openOptions": {
|
||||
"message": "Seçenekler"
|
||||
},
|
||||
"openStylesManager": {
|
||||
"message": "Stil yöneticisini aç"
|
||||
},
|
||||
"optionsActions": {
|
||||
"message": "İşlemler"
|
||||
},
|
||||
"optionsAdvanced": {
|
||||
"message": "Gelişmiş"
|
||||
},
|
||||
"optionsAdvancedContextDelete": {
|
||||
"message": "Editör bağlam menüsüne 'Sil' seçeneği ekle"
|
||||
},
|
||||
"optionsAdvancedExposeIframes": {
|
||||
"message": "HTML[stylus-iframe] vasıtasıyla iframe'leri gösterin"
|
||||
},
|
||||
"optionsBadgeDisabled": {
|
||||
"message": "Etkin değilken arkaplan rengi"
|
||||
},
|
||||
"optionsBadgeNormal": {
|
||||
"message": "Arkaplan rengi"
|
||||
},
|
||||
"optionsCheck": {
|
||||
"message": "Stilleri güncelle"
|
||||
},
|
||||
"optionsCheckUpdate": {
|
||||
"message": "Uygun tüm güncellemeleri kontrol et ve yükle."
|
||||
},
|
||||
"optionsCustomizePopup": {
|
||||
"message": "Açılır pencere"
|
||||
},
|
||||
"optionsCustomizeUpdate": {
|
||||
"message": "Güncellemeler"
|
||||
},
|
||||
"optionsHeading": {
|
||||
"message": "Seçenekler"
|
||||
},
|
||||
"optionsOpen": {
|
||||
"message": "Aç"
|
||||
},
|
||||
"optionsOpenManager": {
|
||||
"message": "Stilleri yönet"
|
||||
},
|
||||
"optionsPopupWidth": {
|
||||
"message": "Popup genişliği (piksel cinsinden)"
|
||||
},
|
||||
"optionsReset": {
|
||||
"message": "Ayarları varsayılanlara sıfırla."
|
||||
},
|
||||
"optionsResetButton": {
|
||||
"message": "Sıfırlama seçenekleri"
|
||||
},
|
||||
"optionsSubheading": {
|
||||
"message": "Daha Fazla Seçenek"
|
||||
},
|
||||
"optionsSyncConnect": {
|
||||
"message": "Bağlan"
|
||||
},
|
||||
"optionsSyncDisconnect": {
|
||||
"message": "Bağlantıyı kes"
|
||||
},
|
||||
"optionsSyncLogin": {
|
||||
"message": "Giriş yap"
|
||||
},
|
||||
"optionsSyncStatusConnected": {
|
||||
"message": "Bağlandı"
|
||||
},
|
||||
"optionsSyncStatusConnecting": {
|
||||
"message": "Bağlanılıyor..."
|
||||
},
|
||||
"optionsSyncStatusDisconnected": {
|
||||
"message": "Bağlantı kesildi"
|
||||
},
|
||||
"optionsSyncStatusDisconnecting": {
|
||||
"message": "Bağlantı kesiliyor..."
|
||||
},
|
||||
"optionsUpdateImportNote": {
|
||||
"message": "Eski versiyonlardan ya da Stylish'ten stil yedeklerini içeri aktarırken, hepsinin güncel olduğundan emin olmak için stil yöneticisinden bir defa elle güncelleme kontrolü yapın"
|
||||
},
|
||||
"optionsUpdateInterval": {
|
||||
"message": "Saat cinsinden kullanıcı stili otomatik güncelleme aralığı (devre dışı bırakmak için 0 yazın) "
|
||||
},
|
||||
"overwriteFileExport": {
|
||||
"message": "Mevcut bir dosyanın üzerine yazmak istiyor musunuz?"
|
||||
},
|
||||
"paginationCurrent": {
|
||||
"message": "Şimdiki sayfa"
|
||||
},
|
||||
"paginationEstimated": {
|
||||
"message": "Tahmini sayfa sayısı"
|
||||
},
|
||||
"paginationNext": {
|
||||
"message": "Sonraki sayfa"
|
||||
},
|
||||
"paginationPrevious": {
|
||||
"message": "Önceki sayfa"
|
||||
},
|
||||
"paginationTotal": {
|
||||
"message": "Toplam sayfa"
|
||||
},
|
||||
"prefShowBadge": {
|
||||
"message": "Şu an açık olan site için aktif olan stil sayısı"
|
||||
},
|
||||
"previewLabel": {
|
||||
"message": "Canlı önizleme"
|
||||
},
|
||||
"readingStyles": {
|
||||
"message": "Stiller okunuyor..."
|
||||
},
|
||||
"replace": {
|
||||
"message": "Değiştir"
|
||||
},
|
||||
"replaceAll": {
|
||||
"message": "Hepsini değiştir"
|
||||
},
|
||||
"replaceWith": {
|
||||
"message": "Şununla değiştir"
|
||||
},
|
||||
"retrieveBckp": {
|
||||
"message": "Stilleri içe aktar"
|
||||
},
|
||||
"retrieveDropboxSync": {
|
||||
"message": "Dropbox'a aktar"
|
||||
},
|
||||
"search": {
|
||||
"message": "Ara"
|
||||
},
|
||||
"searchRegexp": {
|
||||
"message": "Regexp araması için /re/ sözdizimini (syntax) kullanın."
|
||||
},
|
||||
"searchResultInstallCount": {
|
||||
"message": "Toplam kurulum sayısı"
|
||||
},
|
||||
"searchResultNoneFound": {
|
||||
"message": "Bu site için stil bulunamadı."
|
||||
},
|
||||
"searchResultWeeklyCount": {
|
||||
"message": "Haftalık kurulum sayısı"
|
||||
},
|
||||
"sectionAdd": {
|
||||
"message": "Başka bölüm ekle"
|
||||
},
|
||||
"sectionCode": {
|
||||
"message": "Kod"
|
||||
},
|
||||
"sectionRemove": {
|
||||
"message": "Bölümü kaldır"
|
||||
},
|
||||
"sections": {
|
||||
"message": "Bölümler"
|
||||
},
|
||||
"shortcuts": {
|
||||
"message": "Kısayollar"
|
||||
},
|
||||
"shortcutsNote": {
|
||||
"message": "Klavye kısayolları tanımla"
|
||||
},
|
||||
"sortDateNewestFirst": {
|
||||
"message": "önce en yeniler"
|
||||
},
|
||||
"sortDateOldestFirst": {
|
||||
"message": "önce en eskiler"
|
||||
},
|
||||
"sortStylesHelpTitle": {
|
||||
"message": "İçeriği sırala"
|
||||
},
|
||||
"styleBadRegexp": {
|
||||
"message": "Regexp geçerli değil."
|
||||
},
|
||||
"styleBeautify": {
|
||||
"message": "Güzelleştir"
|
||||
},
|
||||
"styleCancelEditLabel": {
|
||||
"message": "Yönetim sayfasına dön"
|
||||
},
|
||||
"styleChangesNotSaved": {
|
||||
"message": "Bu stilde yaptığınız, kaydedilmemiş değişiklikler var."
|
||||
},
|
||||
"styleEnabledLabel": {
|
||||
"message": "Etkin"
|
||||
},
|
||||
"styleFromMozillaFormatPrompt": {
|
||||
"message": "Mozilla biçemiyle yazılmış kodu yapıştır"
|
||||
},
|
||||
"styleInstall": {
|
||||
"message": "'$stylename$' Stylus'e yüklensin mi?",
|
||||
"placeholders": {
|
||||
"stylename": {
|
||||
"content": "$1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"styleMissingName": {
|
||||
"message": "Bir ad girin"
|
||||
},
|
||||
"styleMozillaFormatHeading": {
|
||||
"message": "Mozilla Biçemi"
|
||||
},
|
||||
"styleRegexpInvalidExplanation": {
|
||||
"message": "Hiç derlenemeyen bazı 'regexp ()' kuralları."
|
||||
},
|
||||
"styleRegexpProblemTooltip": {
|
||||
"message": "'Regexp ()' yanlış kullanımı nedeniyle uygulanmayan bölüm sayısı"
|
||||
},
|
||||
"styleRegexpTestFull": {
|
||||
"message": "Eşleşen sekmeler"
|
||||
},
|
||||
"styleRegexpTestInvalid": {
|
||||
"message": "Geçersiz regexp'ler atlandı"
|
||||
},
|
||||
"styleRegexpTestNone": {
|
||||
"message": "Eşleşen sekme yok"
|
||||
},
|
||||
"styleRegexpTestPartial": {
|
||||
"message": "Tam olarak eşleşmediğinden atlandı"
|
||||
},
|
||||
"styleRegexpTestTitle": {
|
||||
"message": "Eşleşen açık sekmelerin listesi (sekmesine gitmek için URL'ye tıklayın)"
|
||||
},
|
||||
"styleSaveLabel": {
|
||||
"message": "Kaydet"
|
||||
},
|
||||
"styleToMozillaFormatHelp": {
|
||||
"message": "Kodun Mozilla biçimi, Firefox için Stylish ile kullanılabilir ve userstyles.org sitesine gönderilebilir."
|
||||
},
|
||||
"styleToMozillaFormatTitle": {
|
||||
"message": "Mozilla biçeminde bir stil"
|
||||
},
|
||||
"styleUpdate": {
|
||||
"message": "\";$stylename$\" stilini güncelleştirmek istiyor musunuz?",
|
||||
"placeholders": {
|
||||
"stylename": {
|
||||
"content": "$1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"stylusUnavailableForURL": {
|
||||
"message": "Stylus bunun gibi sayfalarda çalışmaz."
|
||||
},
|
||||
"stylusUnavailableForURLdetails": {
|
||||
"message": "Bir güvenlik önlemi olarak tarayıcı eklentilerin, kendinin yerleşik sayfalarını (chrome://version, Chrome 61'den itibaren standart yeni sekme sayfası, about: addons vb.) ve diğer uzantı sayfalarını etkilemesini engeller. Ayrıca her tarayıcı kendi uzantı galerisine (Chrome Web Mağazası veya AMO gibi) erişimi de kısıtlar. "
|
||||
},
|
||||
"syncDropboxDeprecated": {
|
||||
"message": "Dropbox içe/dışa aktarma, seçenekler sayfasında daha gelişmiş bir stil senkronizasyonu ile değiştirilir."
|
||||
},
|
||||
"syncDropboxStyles": {
|
||||
"message": "Dropbox'tan aktar"
|
||||
},
|
||||
"toggleStyle": {
|
||||
"message": "Stili değiştir"
|
||||
},
|
||||
"undo": {
|
||||
"message": "Geri al"
|
||||
},
|
||||
"undoGlobal": {
|
||||
"message": "Tüm bölümlerde geri alma işlemi uygula."
|
||||
},
|
||||
"unreachableContentScript": {
|
||||
"message": "Sayfayla iletişim kurulamadı. Sekmeyi yeniden yüklemeyi deneyin."
|
||||
},
|
||||
"unreachableFileHint": {
|
||||
"message": "Stylus, eğer siz Stylus chrome://extensions sayfasından ilgili onay kutusunu işaretlerseniz file:// adreslerine erişebilir."
|
||||
},
|
||||
"unzipStyles": {
|
||||
"message": "Stiller açılıyor..."
|
||||
},
|
||||
"updateAllCheckSucceededNoUpdate": {
|
||||
"message": "Güncelleme bulunamadı."
|
||||
},
|
||||
"updateCheckFailBadResponseCode": {
|
||||
"message": "Güncellenemedi: sunucu yanıt olarak $code$ kodunu gönderdi.",
|
||||
"placeholders": {
|
||||
"code": {
|
||||
"content": "$1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"updateCheckFailServerUnreachable": {
|
||||
"message": "Güncellenemedi: sunucuya erişilemiyor."
|
||||
},
|
||||
"updateCheckHistory": {
|
||||
"message": "Güncelleme kontrolü geçmişi"
|
||||
},
|
||||
"updateCheckManualUpdateForce": {
|
||||
"message": "Güncellemeyi kur (yerel düzenlemelerin üzerine yazılacak)"
|
||||
},
|
||||
"updateCheckManualUpdateHint": {
|
||||
"message": "Bir güncellemeyi zorla yapmak yerel düzenlemelerin üstüne yazacaktır."
|
||||
},
|
||||
"updateCheckSkippedLocallyEdited": {
|
||||
"message": "Bu stil yerel olarak düzenlendi."
|
||||
},
|
||||
"updateCheckSkippedMaybeLocallyEdited": {
|
||||
"message": "Bu stil yerel olarak düzenlenmiş olabilir."
|
||||
},
|
||||
"updateCheckSucceededNoUpdate": {
|
||||
"message": "Stil güncel."
|
||||
},
|
||||
"updateCompleted": {
|
||||
"message": "Güncelleme tamamlandı."
|
||||
},
|
||||
"updatesCurrentlyInstalled": {
|
||||
"message": "Kurulan güncellemeler:"
|
||||
},
|
||||
"uploadingFile": {
|
||||
"message": "Dosya Yükleniyor..."
|
||||
},
|
||||
"usercssAvoidOverwriting": {
|
||||
"message": "Mevcut bir stilin üzerine yazmaktan kaçınmak için lütfen @name veya @ ad alanının değerini değiştirin."
|
||||
},
|
||||
"usercssConfigIncomplete": {
|
||||
"message": "Stil, yapılandırma iletişim kutusu gösterildikten sonra güncellendi veya silindi. Bu değişkenler, stilin meta verilerini bozmamak için kaydedilmedi:"
|
||||
},
|
||||
"usercssEditorNamePlaceholder": {
|
||||
"message": "Kodda @name belirtin"
|
||||
},
|
||||
"usercssReplaceTemplateConfirmation": {
|
||||
"message": "Yeni Usercss stilleri için varsayılan şablonu geçerli kodla değiştir?"
|
||||
},
|
||||
"usercssReplaceTemplateSectionBody": {
|
||||
"message": "Kodu buraya ekle..."
|
||||
},
|
||||
"versionInvalidOlder": {
|
||||
"message": "Sürüm, kurulu stillerden daha eski."
|
||||
},
|
||||
"writeStyleFor": {
|
||||
"message": "Şunun için stil yaz:"
|
||||
},
|
||||
"writeStyleForURL": {
|
||||
"message": "bu URL"
|
||||
},
|
||||
"zipStyles": {
|
||||
"message": "Stiller sıkıştırılıyor..."
|
||||
}
|
||||
}
|
||||
|
|
285
_locales/uk/messages.json
Normal file
285
_locales/uk/messages.json
Normal file
|
@ -0,0 +1,285 @@
|
|||
{
|
||||
"InaccessibleFileHint": {
|
||||
"message": "Stylus не може отримати доступ до деяких типів файлів (наприклад, файли PDF і JSON)."
|
||||
},
|
||||
"addStyleLabel": {
|
||||
"message": "Написати новий стиль"
|
||||
},
|
||||
"addStyleTitle": {
|
||||
"message": "Додати стиль"
|
||||
},
|
||||
"alphaChannel": {
|
||||
"message": "Прозорість"
|
||||
},
|
||||
"appliesAdd": {
|
||||
"message": "Додати"
|
||||
},
|
||||
"appliesDisplay": {
|
||||
"message": "Застосувати до $applies$",
|
||||
"placeholders": {
|
||||
"applies": {
|
||||
"content": "$1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"appliesDisplayTruncatedSuffix": {
|
||||
"message": "та інші"
|
||||
},
|
||||
"appliesDomainOption": {
|
||||
"message": "URL в домені"
|
||||
},
|
||||
"appliesHelp": {
|
||||
"message": "Щоб вказати, до яких URL відноситься код в цьому розділі, скористайтеся параметром \"Застосувати до\"."
|
||||
},
|
||||
"appliesLabel": {
|
||||
"message": "Застосувати до"
|
||||
},
|
||||
"appliesLineWidgetLabel": {
|
||||
"message": "Показати цільові сайти секцій"
|
||||
},
|
||||
"appliesRemove": {
|
||||
"message": "Видалити"
|
||||
},
|
||||
"appliesRemoveError": {
|
||||
"message": "Не можна видалити останній елемент"
|
||||
},
|
||||
"appliesSpecify": {
|
||||
"message": "Вказати"
|
||||
},
|
||||
"appliesToEverything": {
|
||||
"message": "Все"
|
||||
},
|
||||
"appliesUrlPrefixOption": {
|
||||
"message": "URL, що починаються з "
|
||||
},
|
||||
"applyAllUpdates": {
|
||||
"message": "Застосувати всі оновлення"
|
||||
},
|
||||
"author": {
|
||||
"message": "Автор"
|
||||
},
|
||||
"backupButtons": {
|
||||
"message": "Резервне копіювання"
|
||||
},
|
||||
"bckpInstStyles": {
|
||||
"message": "Експорт стилів"
|
||||
},
|
||||
"checkingForUpdate": {
|
||||
"message": "Перевірка ... "
|
||||
},
|
||||
"clickToUninstall": {
|
||||
"message": "Натисніть, щоб видалити "
|
||||
},
|
||||
"cm_selectByTokensTooltip": {
|
||||
"message": "Приклади токенов: .foo-бар-2 #aabbcc 0,32 !important\nЯкщо вимкнено: вибираються слова, розділені розділовими знаками."
|
||||
},
|
||||
"confirmCancel": {
|
||||
"message": "Скасувати "
|
||||
},
|
||||
"confirmDelete": {
|
||||
"message": "Видалити "
|
||||
},
|
||||
"confirmNo": {
|
||||
"message": "Ні"
|
||||
},
|
||||
"confirmSave": {
|
||||
"message": "Зберегти"
|
||||
},
|
||||
"confirmStop": {
|
||||
"message": "Зупинити"
|
||||
},
|
||||
"confirmYes": {
|
||||
"message": "Так"
|
||||
},
|
||||
"deleteStyleLabel": {
|
||||
"message": "Видалити"
|
||||
},
|
||||
"disableStyleLabel": {
|
||||
"message": "Вимкнути"
|
||||
},
|
||||
"editDeleteText": {
|
||||
"message": "Видалити"
|
||||
},
|
||||
"findStyles": {
|
||||
"message": "Знайти стилі"
|
||||
},
|
||||
"genericAdd": {
|
||||
"message": "Додати"
|
||||
},
|
||||
"genericDescription": {
|
||||
"message": "Опис"
|
||||
},
|
||||
"genericDisabledLabel": {
|
||||
"message": "Відключено"
|
||||
},
|
||||
"genericEnabledLabel": {
|
||||
"message": "Увімкнено"
|
||||
},
|
||||
"genericError": {
|
||||
"message": "Помилка"
|
||||
},
|
||||
"genericHistoryLabel": {
|
||||
"message": "Історія"
|
||||
},
|
||||
"genericNext": {
|
||||
"message": "Наступний "
|
||||
},
|
||||
"genericPrevious": {
|
||||
"message": "Попередній"
|
||||
},
|
||||
"genericResetLabel": {
|
||||
"message": "Скинути"
|
||||
},
|
||||
"genericSavedMessage": {
|
||||
"message": "Збережено"
|
||||
},
|
||||
"genericTitle": {
|
||||
"message": "Ім'я"
|
||||
},
|
||||
"genericUnknown": {
|
||||
"message": "Невідомо"
|
||||
},
|
||||
"gettingStyles": {
|
||||
"message": "Отримання всіх стилів ..."
|
||||
},
|
||||
"helpAlt": {
|
||||
"message": "Довідка"
|
||||
},
|
||||
"helpKeyMapCommand": {
|
||||
"message": "Введіть ім'я команди"
|
||||
},
|
||||
"helpKeyMapHotkey": {
|
||||
"message": "Натисніть клавішу"
|
||||
},
|
||||
"hostDisabled": {
|
||||
"message": "Цей хост вимкнено через помилку в поточній версії браузера, що використовується"
|
||||
},
|
||||
"importLabel": {
|
||||
"message": "Імпорт"
|
||||
},
|
||||
"importReplaceLabel": {
|
||||
"message": "Замінити стиль"
|
||||
},
|
||||
"importReportLegendIdentical": {
|
||||
"message": "ідентичні пропущені"
|
||||
},
|
||||
"importReportLegendInvalid": {
|
||||
"message": "недісних пропущено"
|
||||
},
|
||||
"importReportTitle": {
|
||||
"message": "Імпорт стилів закінчено"
|
||||
},
|
||||
"installUpdate": {
|
||||
"message": "Встановити оновлення"
|
||||
},
|
||||
"manageFavicons": {
|
||||
"message": "Піктограми для цільових сайтів"
|
||||
},
|
||||
"manageFilters": {
|
||||
"message": "Фільтри"
|
||||
},
|
||||
"manageHeading": {
|
||||
"message": "Встановити Styles"
|
||||
},
|
||||
"manageNewUI": {
|
||||
"message": "Новий макет інтерфейсу управління користувача"
|
||||
},
|
||||
"meta_unknownJSONLiteral": {
|
||||
"message": "Невірний JSON: $literal$не є дійсним літералом JSON",
|
||||
"placeholders": {
|
||||
"literal": {
|
||||
"content": "$1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"openManage": {
|
||||
"message": "Керування"
|
||||
},
|
||||
"openOptions": {
|
||||
"message": "Налаштування"
|
||||
},
|
||||
"optionsHeading": {
|
||||
"message": "Налаштування"
|
||||
},
|
||||
"optionsReset": {
|
||||
"message": "Скидання налаштувань до значень за замовчуванням"
|
||||
},
|
||||
"optionsResetButton": {
|
||||
"message": "Скинути параметри"
|
||||
},
|
||||
"optionsSubheading": {
|
||||
"message": "Додатково"
|
||||
},
|
||||
"optionsSyncLogin": {
|
||||
"message": "Логін"
|
||||
},
|
||||
"optionsSyncStatusRelogin": {
|
||||
"message": "Сеанс закінчився, будь ласка, увійдіть ще раз."
|
||||
},
|
||||
"paginationNext": {
|
||||
"message": "Наступна сторінка"
|
||||
},
|
||||
"paginationPrevious": {
|
||||
"message": "Попередня сторінка"
|
||||
},
|
||||
"replace": {
|
||||
"message": "Замінити"
|
||||
},
|
||||
"replaceAll": {
|
||||
"message": "Замінити все"
|
||||
},
|
||||
"retrieveBckp": {
|
||||
"message": "Імпорт стилів"
|
||||
},
|
||||
"search": {
|
||||
"message": "Пошук"
|
||||
},
|
||||
"searchStylesAll": {
|
||||
"message": "Усі"
|
||||
},
|
||||
"searchStylesCode": {
|
||||
"message": "CSS код"
|
||||
},
|
||||
"searchStylesHelp": {
|
||||
"message": "</> або <Ctrl-F>клавіша фокусує поле пошуку.\nРежим за замовчуванням — це пошук у звичайному тексті для всіх термінів, розділених пробілами, у будь-якому порядку.\nТочні слова: оберніть запит у подвійні лапки, напр. <.header ~ div\">\nРегулярні вирази: включають косі риски та прапорці, напр.</body.*?\\ba\\b/i>\n«By URL» в селекторі області: знаходить стилі, які застосовуються до повністю вказаної URL-адреси, напр. https://www.example.org/\n\"Metadata\" в селектрі області: шукає в іменах, \"applies to\" специфікаторів, URL-адреси встановлення, URL-адресі оновлення та всьому блоку метаданих для стилів CSS користувача."
|
||||
},
|
||||
"searchStylesName": {
|
||||
"message": "Назва"
|
||||
},
|
||||
"sectionCode": {
|
||||
"message": "Код"
|
||||
},
|
||||
"sections": {
|
||||
"message": "Розділи"
|
||||
},
|
||||
"styleBeautify": {
|
||||
"message": "Облагородити"
|
||||
},
|
||||
"styleCancelEditLabel": {
|
||||
"message": "Повернутися до керування"
|
||||
},
|
||||
"styleEnabledLabel": {
|
||||
"message": "Увімкнено"
|
||||
},
|
||||
"stylePreferSchemeLabel": {
|
||||
"message": "Темна/Світла тема"
|
||||
},
|
||||
"styleSaveLabel": {
|
||||
"message": "Зберегти"
|
||||
},
|
||||
"syncErrorRelogin": {
|
||||
"message": "Помилка синхронізації. Ви вийшли із системи. \nСпробуйте повторно увійти до системи в налаштуваннях Stylus."
|
||||
},
|
||||
"toggleStyle": {
|
||||
"message": "Включити/виключити стиль"
|
||||
},
|
||||
"writeStyleFor": {
|
||||
"message": "Створити стиль для:"
|
||||
},
|
||||
"writeStyleForURL": {
|
||||
"message": "цей URL"
|
||||
},
|
||||
"zipStyles": {
|
||||
"message": "Запаковування стилів ... "
|
||||
}
|
||||
}
|
379
_locales/vi/messages.json
Normal file
379
_locales/vi/messages.json
Normal file
|
@ -0,0 +1,379 @@
|
|||
{
|
||||
"InaccessibleFileHint": {
|
||||
"message": "Stylus không thể truy cập một số kiểu tập tin (chẳng hạn như PDF và JSON)."
|
||||
},
|
||||
"addStyleLabel": {
|
||||
"message": "Viết bảng định kiểu mới"
|
||||
},
|
||||
"addStyleTitle": {
|
||||
"message": "Thêm bảng định kiểu"
|
||||
},
|
||||
"alphaChannel": {
|
||||
"message": "Độ mờ"
|
||||
},
|
||||
"appliesAdd": {
|
||||
"message": "Thêm"
|
||||
},
|
||||
"appliesDisplay": {
|
||||
"message": "Áp dụng với: $applies$",
|
||||
"placeholders": {
|
||||
"applies": {
|
||||
"content": "$1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"appliesDisplayTruncatedSuffix": {
|
||||
"message": "và một số khác"
|
||||
},
|
||||
"appliesDomainOption": {
|
||||
"message": "Các địa chỉ thuộc tên miền này"
|
||||
},
|
||||
"appliesHelp": {
|
||||
"message": "Dùng tuỳ chọn \"Áp dụng với\" để giới hạn các địa chỉ cho đoạn mã này"
|
||||
},
|
||||
"appliesLabel": {
|
||||
"message": "Áp dụng với"
|
||||
},
|
||||
"appliesLineWidgetLabel": {
|
||||
"message": "Hiển thị thông tin \"Áp dụng với\""
|
||||
},
|
||||
"appliesLineWidgetWarning": {
|
||||
"message": "Không hoạt động với CSS tối giản"
|
||||
},
|
||||
"appliesRegexpOption": {
|
||||
"message": "URL khớp với biểu thức chính quy"
|
||||
},
|
||||
"appliesRemove": {
|
||||
"message": "Xoá"
|
||||
},
|
||||
"appliesRemoveError": {
|
||||
"message": "Không thể xoá mục \"Áp dụng với\" cuối cùng"
|
||||
},
|
||||
"appliesSpecify": {
|
||||
"message": "Chỉ định"
|
||||
},
|
||||
"appliesToEverything": {
|
||||
"message": "Tất cả"
|
||||
},
|
||||
"appliesUrlPrefixOption": {
|
||||
"message": "URL bắt đầu bằng"
|
||||
},
|
||||
"author": {
|
||||
"message": "Tác giả"
|
||||
},
|
||||
"backupButtons": {
|
||||
"message": "Sao lưu"
|
||||
},
|
||||
"backupMessage": {
|
||||
"message": "Để nhập tập tin sao lưu, kéo và thả nó vào trang này hoặc nhấp vào nút Nhập.\n\nĐể xuất một bản sao lưu tương thích với Stylus trước phiên bản 1.5.18, nhấp chuột phải hoặc nhấn giữ Shift khi nhấp chuột trái vào nút Xuất."
|
||||
},
|
||||
"bckpInstStyles": {
|
||||
"message": "Xuất bảng định kiểu"
|
||||
},
|
||||
"checkForUpdate": {
|
||||
"message": "Kiểm tra bản cập nhật mới"
|
||||
},
|
||||
"checkingForUpdate": {
|
||||
"message": "Đang kiểm tra..."
|
||||
},
|
||||
"clickToUninstall": {
|
||||
"message": "Nhấp để huỷ kích hoạt"
|
||||
},
|
||||
"cm_autoCloseBrackets": {
|
||||
"message": "Tự động đóng ngoặc và nháy"
|
||||
},
|
||||
"cm_autoCloseBracketsTooltip": {
|
||||
"message": "Tự động thêm dấu đóng tương ứng khi nhập một trong các dấu (, [, {, ' và \"."
|
||||
},
|
||||
"cm_autocompleteOnTyping": {
|
||||
"message": "Tự động hoàn thành"
|
||||
},
|
||||
"cm_colorpicker": {
|
||||
"message": "Bộ chọn màu cho màu CSS"
|
||||
},
|
||||
"cm_indentWithTabs": {
|
||||
"message": "Lùi đầu dòng thông minh bằng tab"
|
||||
},
|
||||
"cm_lineWrapping": {
|
||||
"message": "Gập dòng dài"
|
||||
},
|
||||
"cm_linter": {
|
||||
"message": "Trình phân tích cú pháp"
|
||||
},
|
||||
"cm_matchHighlight": {
|
||||
"message": "Làm nổi"
|
||||
},
|
||||
"cm_matchHighlightSelection": {
|
||||
"message": "Chỉ vùng được chọn"
|
||||
},
|
||||
"cm_matchHighlightToken": {
|
||||
"message": "Token nằm dưới con trỏ văn bản"
|
||||
},
|
||||
"cm_selectByTokens": {
|
||||
"message": "Nhấp đúp để chọn token"
|
||||
},
|
||||
"cm_selectByTokensTooltip": {
|
||||
"message": "Ví dụ về token: .foo-bar-2 #aabbcc 0.32 !important\nKhi tắt: Chọn từ (phân tách bằng dấu câu)."
|
||||
},
|
||||
"cm_smartIndent": {
|
||||
"message": "Lùi đầu dòng thông minh"
|
||||
},
|
||||
"cm_tabSize": {
|
||||
"message": "Chiều rộng tab"
|
||||
},
|
||||
"cm_theme": {
|
||||
"message": "Chủ đề"
|
||||
},
|
||||
"colorpickerSwitchFormatTooltip": {
|
||||
"message": "Đổi định dạng: HEX → RGB → HSL.\nNhấn giữ phím Shift khi nhấp để đảo thứ tự.\nPhím tắt: PgUp và PgDn."
|
||||
},
|
||||
"colorpickerTooltip": {
|
||||
"message": "Mở bộ chọn màu"
|
||||
},
|
||||
"configOnChange": {
|
||||
"message": "khi thay đổi"
|
||||
},
|
||||
"configOnChangeTooltip": {
|
||||
"message": "Tự động lưu và áp dụng"
|
||||
},
|
||||
"configureStyle": {
|
||||
"message": "Thiết lập"
|
||||
},
|
||||
"configureStyleOnHomepage": {
|
||||
"message": "Thiết lập trên trang chủ"
|
||||
},
|
||||
"confirmCancel": {
|
||||
"message": "Huỷ"
|
||||
},
|
||||
"confirmClose": {
|
||||
"message": "Đóng"
|
||||
},
|
||||
"confirmDefault": {
|
||||
"message": "Dùng mặc định"
|
||||
},
|
||||
"confirmDelete": {
|
||||
"message": "Xoá"
|
||||
},
|
||||
"confirmDiscardChanges": {
|
||||
"message": "Huỷ thay đổi?"
|
||||
},
|
||||
"confirmNo": {
|
||||
"message": "Không"
|
||||
},
|
||||
"confirmSave": {
|
||||
"message": "Lưu"
|
||||
},
|
||||
"confirmStop": {
|
||||
"message": "Dừng"
|
||||
},
|
||||
"confirmYes": {
|
||||
"message": "Có"
|
||||
},
|
||||
"connectingDropbox": {
|
||||
"message": "Đang kết nối với Dropbox..."
|
||||
},
|
||||
"connectingDropboxNotAllowed": {
|
||||
"message": "Tính năng kết nối với Dropbox chỉ khả dụng khi cài ứng dụng trực tiếp từ cửa hàng web"
|
||||
},
|
||||
"copied": {
|
||||
"message": "Đã chép vào khay nhớ tạm"
|
||||
},
|
||||
"copy": {
|
||||
"message": "Chép vào khay nhớ tạm"
|
||||
},
|
||||
"dateAbbrDay": {
|
||||
"message": "$value$ ngày",
|
||||
"placeholders": {
|
||||
"value": {
|
||||
"content": "$1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"dateAbbrHour": {
|
||||
"message": "$value$ giờ",
|
||||
"placeholders": {
|
||||
"value": {
|
||||
"content": "$1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"dateAbbrMonth": {
|
||||
"message": "$value$ tháng",
|
||||
"placeholders": {
|
||||
"value": {
|
||||
"content": "$1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"dateAbbrYear": {
|
||||
"message": "$value$ năm",
|
||||
"placeholders": {
|
||||
"value": {
|
||||
"content": "$1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"dateInstalled": {
|
||||
"message": "Ngày cài đặt"
|
||||
},
|
||||
"dateUpdated": {
|
||||
"message": "Ngày cập nhật"
|
||||
},
|
||||
"defaultTheme": {
|
||||
"message": "mặc định"
|
||||
},
|
||||
"deleteStyleConfirm": {
|
||||
"message": "Bạn có chắc chắn muốn xoá bảng định kiểu này không?"
|
||||
},
|
||||
"deleteStyleLabel": {
|
||||
"message": "Xoá"
|
||||
},
|
||||
"disableAllStyles": {
|
||||
"message": "Tắt tất cả bảng định kiểu"
|
||||
},
|
||||
"disableAllStylesOff": {
|
||||
"message": "Bật tất cả bảng định kiểu"
|
||||
},
|
||||
"disableStyleLabel": {
|
||||
"message": "Vô hiệu hoá"
|
||||
},
|
||||
"draftAction": {
|
||||
"message": "Chọn \"Có\" để tải bản nháp hoặc \"Không\" để xoá nó đi."
|
||||
},
|
||||
"editDeleteText": {
|
||||
"message": "Xoá"
|
||||
},
|
||||
"editGotoLine": {
|
||||
"message": "Đi đến dòng (hoặc dòng:cột)"
|
||||
},
|
||||
"editStyleHeading": {
|
||||
"message": "Sửa bảng định kiểu"
|
||||
},
|
||||
"editStyleLabel": {
|
||||
"message": "Sửa"
|
||||
},
|
||||
"editStyleTitle": {
|
||||
"message": "Sửa bảng định kiểu $stylename$",
|
||||
"placeholders": {
|
||||
"stylename": {
|
||||
"content": "$1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"editorSettings": {
|
||||
"message": "Cài đặt trình soạn thảo"
|
||||
},
|
||||
"enableStyleLabel": {
|
||||
"message": "Kích hoạt"
|
||||
},
|
||||
"exportCompatible": {
|
||||
"message": "Xuất (chế độ tương thích)"
|
||||
},
|
||||
"exportLabel": {
|
||||
"message": "Xuất"
|
||||
},
|
||||
"exportSavedSuccess": {
|
||||
"message": "Lưu thành công"
|
||||
},
|
||||
"externalFeedback": {
|
||||
"message": "Phản hồi"
|
||||
},
|
||||
"externalHomepage": {
|
||||
"message": "Trang chủ"
|
||||
},
|
||||
"externalLink": {
|
||||
"message": "Liên kết ngoài"
|
||||
},
|
||||
"externalSupport": {
|
||||
"message": "Ủng hộ"
|
||||
},
|
||||
"genericAdd": {
|
||||
"message": "Thêm"
|
||||
},
|
||||
"genericDescription": {
|
||||
"message": "Mô tả"
|
||||
},
|
||||
"genericDisabledLabel": {
|
||||
"message": "Vô hiệu hoá"
|
||||
},
|
||||
"genericEnabledLabel": {
|
||||
"message": "Kích hoạt"
|
||||
},
|
||||
"genericError": {
|
||||
"message": "Lỗi"
|
||||
},
|
||||
"genericHistoryLabel": {
|
||||
"message": "Lịch sử"
|
||||
},
|
||||
"genericNext": {
|
||||
"message": "Sau"
|
||||
},
|
||||
"genericPrevious": {
|
||||
"message": "Trước"
|
||||
},
|
||||
"genericResetLabel": {
|
||||
"message": "Đặt lại"
|
||||
},
|
||||
"genericSavedMessage": {
|
||||
"message": "Đã lưu"
|
||||
},
|
||||
"genericTest": {
|
||||
"message": "Thứ"
|
||||
},
|
||||
"genericTitle": {
|
||||
"message": "Tiêu đề"
|
||||
},
|
||||
"genericUnknown": {
|
||||
"message": "Không xác định"
|
||||
},
|
||||
"helpAlt": {
|
||||
"message": "Trợ giúp"
|
||||
},
|
||||
"importLabel": {
|
||||
"message": "Nhập"
|
||||
},
|
||||
"importReportLegendAdded": {
|
||||
"message": "đã thêm"
|
||||
},
|
||||
"importReportLegendIdentical": {
|
||||
"message": "Đã bỏ qua các tệp trùng lặp"
|
||||
},
|
||||
"importReportLegendInvalid": {
|
||||
"message": "Đã bỏ qua các tệp không hợp lệ"
|
||||
},
|
||||
"importReportLegendUpdatedBoth": {
|
||||
"message": "đã cập nhật siêu thông tin và mã"
|
||||
},
|
||||
"importReportLegendUpdatedCode": {
|
||||
"message": "đã cập nhật mã"
|
||||
},
|
||||
"importReportLegendUpdatedMeta": {
|
||||
"message": "đã cập nhật siêu thông tin"
|
||||
},
|
||||
"importReportTitle": {
|
||||
"message": "Đã nhập xong"
|
||||
},
|
||||
"installUpdateFromLabel": {
|
||||
"message": "Kiểm tra bản cập nhật mới"
|
||||
},
|
||||
"license": {
|
||||
"message": "Giấy phép"
|
||||
},
|
||||
"linterCSSLintIncompatible": {
|
||||
"message": "CSSLint không hỗ trợ bộ tiền xử lý $preprocessorname$",
|
||||
"placeholders": {
|
||||
"preprocessorname": {
|
||||
"content": "$1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"linterJSONError": {
|
||||
"message": "Định dạng JSON không hợp lệ"
|
||||
},
|
||||
"styleEnabledLabel": {
|
||||
"message": "Kích hoạt"
|
||||
},
|
||||
"styleSaveLabel": {
|
||||
"message": "Lưu"
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
26
background/background-worker.js
Normal file
26
background/background-worker.js
Normal file
|
@ -0,0 +1,26 @@
|
|||
/* global createWorkerApi */// worker-util.js
|
||||
'use strict';
|
||||
|
||||
/** @namespace BackgroundWorker */
|
||||
createWorkerApi({
|
||||
|
||||
async compileUsercss(...args) {
|
||||
require(['/js/usercss-compiler']); /* global compileUsercss */
|
||||
return compileUsercss(...args);
|
||||
},
|
||||
|
||||
nullifyInvalidVars(vars) {
|
||||
require(['/js/meta-parser']); /* global metaParser */
|
||||
return metaParser.nullifyInvalidVars(vars);
|
||||
},
|
||||
|
||||
parseMozFormat(...args) {
|
||||
require(['/js/moz-parser']); /* global extractSections */
|
||||
return extractSections(...args);
|
||||
},
|
||||
|
||||
parseUsercssMeta(text) {
|
||||
require(['/js/meta-parser']);
|
||||
return metaParser.parse(text);
|
||||
},
|
||||
});
|
|
@ -1,362 +1,213 @@
|
|||
/* global dbExec, getStyles, saveStyle */
|
||||
/* global handleCssTransitionBug */
|
||||
/* global usercssHelper openEditor */
|
||||
/* global styleViaAPI */
|
||||
/* global API msg */// msg.js
|
||||
/* global addAPI bgReady */// common.js
|
||||
/* global createWorker */// worker-util.js
|
||||
/* global prefs */
|
||||
/* global styleMan */
|
||||
/* global syncMan */
|
||||
/* global updateMan */
|
||||
/* global usercssMan */
|
||||
/* global usoApi */
|
||||
/* global uswApi */
|
||||
/* global FIREFOX UA activateTab openURL */ // toolbox.js
|
||||
/* global colorScheme */ // color-scheme.js
|
||||
'use strict';
|
||||
|
||||
// eslint-disable-next-line no-var
|
||||
var browserCommands, contextMenus;
|
||||
//#region API
|
||||
|
||||
// *************************************************************************
|
||||
// register all listeners
|
||||
chrome.runtime.onMessage.addListener(onRuntimeMessage);
|
||||
addAPI(/** @namespace API */ {
|
||||
|
||||
{
|
||||
const listener =
|
||||
URLS.chromeProtectsNTP
|
||||
? webNavigationListenerChrome
|
||||
: webNavigationListener;
|
||||
/** Temporary storage for data needed elsewhere e.g. in a content script */
|
||||
data: ((data = {}) => ({
|
||||
del: key => delete data[key],
|
||||
get: key => data[key],
|
||||
has: key => key in data,
|
||||
pop: key => {
|
||||
const val = data[key];
|
||||
delete data[key];
|
||||
return val;
|
||||
},
|
||||
set: (key, val) => {
|
||||
data[key] = val;
|
||||
},
|
||||
}))(),
|
||||
|
||||
chrome.webNavigation.onBeforeNavigate.addListener(data =>
|
||||
listener(null, data));
|
||||
styles: styleMan,
|
||||
sync: syncMan,
|
||||
updater: updateMan,
|
||||
usercss: usercssMan,
|
||||
uso: usoApi,
|
||||
usw: uswApi,
|
||||
colorScheme,
|
||||
/** @type {BackgroundWorker} */
|
||||
worker: createWorker({url: '/background/background-worker'}),
|
||||
|
||||
chrome.webNavigation.onCommitted.addListener(data =>
|
||||
listener('styleApply', data));
|
||||
|
||||
chrome.webNavigation.onHistoryStateUpdated.addListener(data =>
|
||||
listener('styleReplaceAll', data));
|
||||
|
||||
chrome.webNavigation.onReferenceFragmentUpdated.addListener(data =>
|
||||
listener('styleReplaceAll', data));
|
||||
}
|
||||
|
||||
chrome.contextMenus.onClicked.addListener((info, tab) =>
|
||||
contextMenus[info.menuItemId].click(info, tab));
|
||||
|
||||
if ('commands' in chrome) {
|
||||
// Not available in Firefox - https://bugzilla.mozilla.org/show_bug.cgi?id=1240350
|
||||
chrome.commands.onCommand.addListener(command => browserCommands[command]());
|
||||
}
|
||||
|
||||
// *************************************************************************
|
||||
// set the default icon displayed after a tab is created until webNavigation kicks in
|
||||
prefs.subscribe(['iconset'], () => updateIcon({id: undefined}, {}));
|
||||
|
||||
// *************************************************************************
|
||||
{
|
||||
const onInstall = ({reason}) => {
|
||||
chrome.runtime.onInstalled.removeListener(onInstall);
|
||||
const manifest = chrome.runtime.getManifest();
|
||||
// Open FAQs page once after installation to guide new users.
|
||||
// Do not display it in development mode.
|
||||
if (reason === 'install' && manifest.update_url) {
|
||||
setTimeout(openURL, 100, {
|
||||
url: 'http://add0n.com/stylus.html'
|
||||
});
|
||||
}
|
||||
// reset L10N cache on update
|
||||
if (reason === 'update') {
|
||||
localStorage.L10N = JSON.stringify({
|
||||
browserUIlanguage: chrome.i18n.getUILanguage(),
|
||||
});
|
||||
}
|
||||
};
|
||||
// bind for 60 seconds max and auto-unbind if it's a normal run
|
||||
chrome.runtime.onInstalled.addListener(onInstall);
|
||||
setTimeout(onInstall, 60e3, {reason: 'unbindme'});
|
||||
}
|
||||
|
||||
// *************************************************************************
|
||||
// browser commands
|
||||
browserCommands = {
|
||||
openManage() {
|
||||
openURL({url: 'manage.html'});
|
||||
/** @returns {string} */
|
||||
getTabUrlPrefix() {
|
||||
return this.sender.tab.url.match(/^([\w-]+:\/+[^/#]+)/)[1];
|
||||
},
|
||||
|
||||
/**
|
||||
* Opens the editor or activates an existing tab
|
||||
* @param {{
|
||||
id?: number
|
||||
domain?: string
|
||||
'url-prefix'?: string
|
||||
}} params
|
||||
* @returns {Promise<chrome.tabs.Tab>}
|
||||
*/
|
||||
async openEditor(params) {
|
||||
const u = new URL(chrome.runtime.getURL('edit.html'));
|
||||
u.search = new URLSearchParams(params);
|
||||
const wnd = chrome.windows && prefs.get('openEditInWindow');
|
||||
const wndPos = wnd && prefs.get('windowPosition');
|
||||
const wndBase = wnd && prefs.get('openEditInWindow.popup') ? {type: 'popup'} : {};
|
||||
const ffBug = wnd && FIREFOX; // https://bugzil.la/1271047
|
||||
if (wndPos) {
|
||||
const {left, top, width, height} = wndPos;
|
||||
const r = left + width;
|
||||
const b = top + height;
|
||||
const peek = 32;
|
||||
if (isNaN(r) || r < peek || left > screen.availWidth - peek || width < 100) {
|
||||
delete wndPos.left;
|
||||
delete wndPos.width;
|
||||
}
|
||||
if (isNaN(b) || b < peek || top > screen.availHeight - peek || height < 100) {
|
||||
delete wndPos.top;
|
||||
delete wndPos.height;
|
||||
}
|
||||
}
|
||||
const tab = await openURL({
|
||||
url: `${u}`,
|
||||
currentWindow: null,
|
||||
newWindow: wnd && Object.assign(wndBase, !ffBug && wndPos),
|
||||
});
|
||||
if (ffBug) await browser.windows.update(tab.windowId, wndPos);
|
||||
return tab;
|
||||
},
|
||||
|
||||
/** @returns {Promise<chrome.tabs.Tab>} */
|
||||
async openManage({options = false, search, searchMode} = {}) {
|
||||
const setUrlParams = url => {
|
||||
const u = new URL(url);
|
||||
if (search) u.searchParams.set('search', search);
|
||||
if (searchMode) u.searchParams.set('searchMode', searchMode);
|
||||
if (options) u.hash = '#stylus-options';
|
||||
return u.href;
|
||||
};
|
||||
const base = chrome.runtime.getURL('manage.html');
|
||||
const url = setUrlParams(base);
|
||||
const tabs = await browser.tabs.query({url: base + '*'});
|
||||
const same = tabs.find(t => t.url === url);
|
||||
let tab = same || tabs[0];
|
||||
if (!tab) {
|
||||
API.prefsDb.get('badFavs'); // prime the cache to avoid flicker/delay when opening the page
|
||||
tab = await openURL({url, newTab: true});
|
||||
} else if (!same) {
|
||||
msg.sendTab(tab.id, {method: 'pushState', url: setUrlParams(tab.url)});
|
||||
}
|
||||
return activateTab(tab); // activateTab unminimizes the window
|
||||
},
|
||||
|
||||
/**
|
||||
* Same as openURL, the only extra prop in `opts` is `message` - it'll be sent
|
||||
* when the tab is ready, which is needed in the popup, otherwise another
|
||||
* extension could force the tab to open in foreground thus auto-closing the
|
||||
* popup (in Chrome at least) and preventing the sendMessage code from running
|
||||
* @returns {Promise<chrome.tabs.Tab>}
|
||||
*/
|
||||
async openURL(opts) {
|
||||
const tab = await openURL(opts);
|
||||
if (opts.message) {
|
||||
await onTabReady(tab);
|
||||
await msg.sendTab(tab.id, opts.message);
|
||||
}
|
||||
return tab;
|
||||
function onTabReady(tab) {
|
||||
return new Promise((resolve, reject) =>
|
||||
setTimeout(function ping(numTries = 10, delay = 100) {
|
||||
msg.sendTab(tab.id, {method: 'ping'})
|
||||
.catch(() => false)
|
||||
.then(pong => pong
|
||||
? resolve(tab)
|
||||
: numTries && setTimeout(ping, delay, numTries - 1, delay * 1.5) ||
|
||||
reject('timeout'));
|
||||
}));
|
||||
}
|
||||
},
|
||||
|
||||
prefs: {
|
||||
getValues: () => prefs.__values, // will be deepCopy'd by apiHandler
|
||||
set: prefs.set,
|
||||
},
|
||||
});
|
||||
|
||||
//#endregion
|
||||
//#region Events
|
||||
|
||||
const browserCommands = {
|
||||
openManage: () => API.openManage(),
|
||||
openOptions: () => API.openManage({options: true}),
|
||||
reload: () => chrome.runtime.reload(),
|
||||
styleDisableAll(info) {
|
||||
prefs.set('disableAll', info ? info.checked : !prefs.get('disableAll'));
|
||||
},
|
||||
};
|
||||
|
||||
// *************************************************************************
|
||||
// context menus
|
||||
contextMenus = Object.assign({
|
||||
'show-badge': {
|
||||
title: 'menuShowBadge',
|
||||
click: info => prefs.set(info.menuItemId, info.checked),
|
||||
},
|
||||
'disableAll': {
|
||||
title: 'disableAllStyles',
|
||||
click: browserCommands.styleDisableAll,
|
||||
},
|
||||
'open-manager': {
|
||||
title: 'openStylesManager',
|
||||
click: browserCommands.openManage,
|
||||
},
|
||||
}, !FIREFOX && prefs.get('editor.contextDelete') && {
|
||||
'editor.contextDelete': {
|
||||
title: 'editDeleteText',
|
||||
type: 'normal',
|
||||
contexts: ['editable'],
|
||||
documentUrlPatterns: [URLS.ownOrigin + 'edit*'],
|
||||
click: (info, tab) => {
|
||||
chrome.tabs.sendMessage(tab.id, {method: 'editDeleteText'});
|
||||
},
|
||||
}
|
||||
});
|
||||
|
||||
{
|
||||
const createContextMenus = (ids = Object.keys(contextMenus)) => {
|
||||
for (const id of ids) {
|
||||
const item = Object.assign({id}, contextMenus[id]);
|
||||
const prefValue = prefs.readOnlyValues[id];
|
||||
item.title = chrome.i18n.getMessage(item.title);
|
||||
if (!item.type && typeof prefValue === 'boolean') {
|
||||
item.type = 'checkbox';
|
||||
item.checked = prefValue;
|
||||
}
|
||||
if (!item.contexts) {
|
||||
item.contexts = ['browser_action'];
|
||||
}
|
||||
delete item.click;
|
||||
chrome.contextMenus.create(item, ignoreChromeError);
|
||||
}
|
||||
};
|
||||
createContextMenus();
|
||||
const toggleableIds = Object.keys(contextMenus).filter(key =>
|
||||
typeof prefs.readOnlyValues[key] === 'boolean');
|
||||
prefs.subscribe(toggleableIds, (id, checked) => {
|
||||
if (id === 'editor.contextDelete') {
|
||||
if (checked) {
|
||||
createContextMenus([id]);
|
||||
} else {
|
||||
chrome.contextMenus.remove(id, ignoreChromeError);
|
||||
}
|
||||
} else {
|
||||
chrome.contextMenus.update(id, {checked}, ignoreChromeError);
|
||||
}
|
||||
});
|
||||
if (chrome.commands) {
|
||||
chrome.commands.onCommand.addListener(id => browserCommands[id]());
|
||||
}
|
||||
|
||||
// *************************************************************************
|
||||
// [re]inject content scripts
|
||||
window.addEventListener('storageReady', function _() {
|
||||
window.removeEventListener('storageReady', _);
|
||||
|
||||
updateIcon({id: undefined}, {});
|
||||
|
||||
const NTP = 'chrome://newtab/';
|
||||
const PING = {method: 'ping'};
|
||||
const ALL_URLS = '<all_urls>';
|
||||
const contentScripts = chrome.runtime.getManifest().content_scripts;
|
||||
// expand * as .*?
|
||||
const wildcardAsRegExp = (s, flags) => new RegExp(
|
||||
s.replace(/[{}()[\]/\\.+?^$:=!|]/g, '\\$&')
|
||||
.replace(/\*/g, '.*?'), flags);
|
||||
for (const cs of contentScripts) {
|
||||
cs.matches = cs.matches.map(m => (
|
||||
m === ALL_URLS ? m : wildcardAsRegExp(m)
|
||||
));
|
||||
chrome.runtime.onInstalled.addListener(({reason, previousVersion}) => {
|
||||
if (reason === 'install') {
|
||||
if (UA.mobile) prefs.set('manage.newUI', false);
|
||||
if (UA.windows) prefs.set('editor.keyMap', 'sublime');
|
||||
}
|
||||
|
||||
const injectCS = (cs, tabId) => {
|
||||
chrome.tabs.executeScript(tabId, {
|
||||
file: cs.js[0],
|
||||
runAt: cs.run_at,
|
||||
allFrames: cs.all_frames,
|
||||
matchAboutBlank: cs.match_about_blank,
|
||||
}, ignoreChromeError);
|
||||
};
|
||||
|
||||
const pingCS = (cs, {id, url}) => {
|
||||
cs.matches.some(match => {
|
||||
if ((match === ALL_URLS || url.match(match))
|
||||
&& (!url.startsWith('chrome') || url === NTP)) {
|
||||
chrome.tabs.sendMessage(id, PING, pong => {
|
||||
if (!pong) {
|
||||
injectCS(cs, id);
|
||||
// TODO: remove this before 1.5.23 as it's only for a few users who installed git 26b75e77
|
||||
if (reason === 'update' && previousVersion === '1.5.22') {
|
||||
for (const dbName of ['drafts', prefs.STORAGE_KEY]) {
|
||||
try {
|
||||
indexedDB.open(dbName).onsuccess = async e => {
|
||||
const idb = /** @type IDBDatabase */ e.target.result;
|
||||
const ta = idb.objectStoreNames[0] === 'data' && idb.transaction(['data']);
|
||||
if (ta && ta.objectStore('data').autoIncrement) {
|
||||
ta.abort();
|
||||
idb.close();
|
||||
await new Promise(setTimeout);
|
||||
indexedDB.deleteDatabase(dbName);
|
||||
}
|
||||
ignoreChromeError();
|
||||
});
|
||||
return true;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
queryTabs().then(tabs =>
|
||||
tabs.forEach(tab => {
|
||||
// skip lazy-loaded aka unloaded tabs that seem to start loading on message in FF
|
||||
if (!FIREFOX || tab.width) {
|
||||
contentScripts.forEach(cs =>
|
||||
setTimeout(pingCS, 0, cs, tab));
|
||||
}
|
||||
}));
|
||||
};
|
||||
} catch (e) {}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// *************************************************************************
|
||||
|
||||
function webNavigationListener(method, {url, tabId, frameId}) {
|
||||
getStyles({matchUrl: url, enabled: true, asHash: true}).then(styles => {
|
||||
if (method && URLS.supported(url) && tabId >= 0) {
|
||||
if (method === 'styleApply') {
|
||||
handleCssTransitionBug({tabId, frameId, url, styles});
|
||||
}
|
||||
chrome.tabs.sendMessage(tabId, {
|
||||
method,
|
||||
// ping own page so it retrieves the styles directly
|
||||
styles: url.startsWith(URLS.ownOrigin) ? 'DIY' : styles,
|
||||
}, {
|
||||
frameId
|
||||
}, ignoreChromeError);
|
||||
}
|
||||
// main page frame id is 0
|
||||
if (frameId === 0) {
|
||||
updateIcon({id: tabId, url}, styles);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function webNavigationListenerChrome(method, data) {
|
||||
// Chrome 61.0.3161+ doesn't run content scripts on NTP
|
||||
if (
|
||||
!data.url.startsWith('https://www.google.') ||
|
||||
!data.url.includes('/_/chrome/newtab?')
|
||||
) {
|
||||
webNavigationListener(method, data);
|
||||
return;
|
||||
msg.on((msg, sender) => {
|
||||
if (msg.method === 'invokeAPI') {
|
||||
let res = msg.path.reduce((res, name) => res && res[name], API);
|
||||
if (!res) throw new Error(`Unknown API.${msg.path.join('.')}`);
|
||||
res = res.apply({msg, sender}, msg.args);
|
||||
return res === undefined ? null : res;
|
||||
}
|
||||
getTab(data.tabId).then(tab => {
|
||||
if (tab.url === 'chrome://newtab/') {
|
||||
data.url = tab.url;
|
||||
}
|
||||
webNavigationListener(method, data);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
//#endregion
|
||||
|
||||
function updateIcon(tab, styles) {
|
||||
if (tab.id < 0) {
|
||||
return;
|
||||
}
|
||||
if (URLS.chromeProtectsNTP && tab.url === 'chrome://newtab/') {
|
||||
styles = {};
|
||||
}
|
||||
if (styles) {
|
||||
stylesReceived(styles);
|
||||
return;
|
||||
}
|
||||
getTabRealURL(tab)
|
||||
.then(url => getStyles({matchUrl: url, enabled: true, asHash: true}))
|
||||
.then(stylesReceived);
|
||||
|
||||
function stylesReceived(styles) {
|
||||
let numStyles = styles.length;
|
||||
if (numStyles === undefined) {
|
||||
// for 'styles' asHash:true fake the length by counting numeric ids manually
|
||||
numStyles = 0;
|
||||
for (const id of Object.keys(styles)) {
|
||||
numStyles += id.match(/^\d+$/) ? 1 : 0;
|
||||
}
|
||||
}
|
||||
const disableAll = 'disableAll' in styles ? styles.disableAll : prefs.get('disableAll');
|
||||
const postfix = disableAll ? 'x' : numStyles === 0 ? 'w' : '';
|
||||
const color = prefs.get(disableAll ? 'badgeDisabled' : 'badgeNormal');
|
||||
const text = prefs.get('show-badge') && numStyles ? String(numStyles) : '';
|
||||
const iconset = ['', 'light/'][prefs.get('iconset')] || '';
|
||||
const path = 'images/icon/' + iconset;
|
||||
chrome.browserAction.setIcon({
|
||||
tabId: tab.id,
|
||||
path: {
|
||||
// Material Design 2016 new size is 16px
|
||||
16: `${path}16${postfix}.png`,
|
||||
32: `${path}32${postfix}.png`,
|
||||
// Chromium forks or non-chromium browsers may still use the traditional 19px
|
||||
19: `${path}19${postfix}.png`,
|
||||
38: `${path}38${postfix}.png`,
|
||||
// TODO: add Edge preferred sizes: 20, 25, 30, 40
|
||||
},
|
||||
}, () => {
|
||||
if (chrome.runtime.lastError || tab.id === undefined) {
|
||||
return;
|
||||
}
|
||||
// Vivaldi bug workaround: setBadgeText must follow setBadgeBackgroundColor
|
||||
chrome.browserAction.setBadgeBackgroundColor({color});
|
||||
getTab(tab.id).then(realTab => {
|
||||
// skip pre-rendered tabs
|
||||
if (realTab.index >= 0) {
|
||||
chrome.browserAction.setBadgeText({text, tabId: tab.id});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function onRuntimeMessage(request, sender, sendResponse) {
|
||||
// prevent browser exception bug on sending a response to a closed tab
|
||||
sendResponse = (send => data => tryCatch(send, data))(sendResponse);
|
||||
switch (request.method) {
|
||||
case 'getStyles':
|
||||
getStyles(request).then(sendResponse);
|
||||
return KEEP_CHANNEL_OPEN;
|
||||
|
||||
case 'saveStyle':
|
||||
saveStyle(request).then(sendResponse);
|
||||
return KEEP_CHANNEL_OPEN;
|
||||
|
||||
case 'saveUsercss':
|
||||
usercssHelper.save(request, true).then(sendResponse);
|
||||
return KEEP_CHANNEL_OPEN;
|
||||
|
||||
case 'buildUsercss':
|
||||
usercssHelper.build(request, true).then(sendResponse);
|
||||
return KEEP_CHANNEL_OPEN;
|
||||
|
||||
case 'healthCheck':
|
||||
dbExec()
|
||||
.then(() => sendResponse(true))
|
||||
.catch(() => sendResponse(false));
|
||||
return KEEP_CHANNEL_OPEN;
|
||||
|
||||
case 'styleViaAPI':
|
||||
styleViaAPI(request, sender);
|
||||
return;
|
||||
|
||||
case 'download':
|
||||
download(request.url)
|
||||
.then(sendResponse)
|
||||
.catch(() => sendResponse(null));
|
||||
return KEEP_CHANNEL_OPEN;
|
||||
|
||||
case 'openUsercssInstallPage':
|
||||
usercssHelper.openInstallPage(sender.tab, request).then(sendResponse);
|
||||
return KEEP_CHANNEL_OPEN;
|
||||
|
||||
case 'closeTab':
|
||||
closeTab(sender.tab.id, request).then(sendResponse);
|
||||
return KEEP_CHANNEL_OPEN;
|
||||
|
||||
case 'openEditor':
|
||||
openEditor(request.id);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
function closeTab(tabId, request) {
|
||||
return new Promise(resolve => {
|
||||
if (request.tabId) {
|
||||
tabId = request.tabId;
|
||||
}
|
||||
chrome.tabs.remove(tabId, () => {
|
||||
const {lastError} = chrome.runtime;
|
||||
if (lastError) {
|
||||
resolve({
|
||||
success: false,
|
||||
error: lastError.message || String(lastError)
|
||||
});
|
||||
return;
|
||||
}
|
||||
resolve({success: true});
|
||||
});
|
||||
});
|
||||
}
|
||||
Promise.all([
|
||||
browser.extension.isAllowedFileSchemeAccess()
|
||||
.then(res => API.data.set('hasFileAccess', res)),
|
||||
bgReady.styles,
|
||||
/* These are loaded conditionally.
|
||||
Each item uses `require` individually so IDE can jump to the source and track usage. */
|
||||
FIREFOX &&
|
||||
require(['/background/style-via-api']),
|
||||
FIREFOX && ((browser.commands || {}).update) &&
|
||||
require(['/background/browser-cmd-hotkeys']),
|
||||
!FIREFOX &&
|
||||
require(['/background/content-scripts']),
|
||||
chrome.contextMenus &&
|
||||
require(['/background/context-menus']),
|
||||
]).then(() => {
|
||||
bgReady._resolveAll();
|
||||
msg.ready = true;
|
||||
msg.broadcast({method: 'backgroundReady'});
|
||||
});
|
||||
|
|
22
background/browser-cmd-hotkeys.js
Normal file
22
background/browser-cmd-hotkeys.js
Normal file
|
@ -0,0 +1,22 @@
|
|||
/* global prefs */
|
||||
'use strict';
|
||||
|
||||
/*
|
||||
Registers hotkeys in FF
|
||||
*/
|
||||
|
||||
(() => {
|
||||
const hotkeyPrefs = prefs.knownKeys.filter(k => k.startsWith('hotkey.'));
|
||||
prefs.subscribe(hotkeyPrefs, updateHotkey, {runNow: true});
|
||||
|
||||
async function updateHotkey(name, value) {
|
||||
try {
|
||||
name = name.split('.')[1];
|
||||
if (value.trim()) {
|
||||
await browser.commands.update({name, shortcut: value});
|
||||
} else {
|
||||
await browser.commands.reset(name);
|
||||
}
|
||||
} catch (e) {}
|
||||
}
|
||||
})();
|
91
background/color-scheme.js
Normal file
91
background/color-scheme.js
Normal file
|
@ -0,0 +1,91 @@
|
|||
/* global prefs */
|
||||
/* exported colorScheme */
|
||||
|
||||
'use strict';
|
||||
|
||||
const colorScheme = (() => {
|
||||
const changeListeners = new Set();
|
||||
const kSTATE = 'schemeSwitcher.enabled';
|
||||
const kSTART = 'schemeSwitcher.nightStart';
|
||||
const kEND = 'schemeSwitcher.nightEnd';
|
||||
const SCHEMES = ['dark', 'light'];
|
||||
const isDark = {
|
||||
never: null,
|
||||
dark: true,
|
||||
light: false,
|
||||
system: false,
|
||||
time: false,
|
||||
};
|
||||
let isDarkNow = false;
|
||||
|
||||
prefs.subscribe(kSTATE, () => update());
|
||||
prefs.subscribe([kSTART, kEND], (key, value) => {
|
||||
updateTimePreferDark();
|
||||
createAlarm(key, value);
|
||||
}, {runNow: true});
|
||||
chrome.alarms.onAlarm.addListener(({name}) => {
|
||||
if (name === kSTART || name === kEND) {
|
||||
updateTimePreferDark();
|
||||
}
|
||||
});
|
||||
|
||||
return {
|
||||
SCHEMES,
|
||||
onChange(listener) {
|
||||
changeListeners.add(listener);
|
||||
},
|
||||
isDark: () => isDarkNow,
|
||||
/** @param {StyleObj} _ */
|
||||
shouldIncludeStyle({preferScheme: ps}) {
|
||||
return prefs.get(kSTATE) === 'never' ||
|
||||
!SCHEMES.includes(ps) ||
|
||||
isDarkNow === (ps === 'dark');
|
||||
},
|
||||
updateSystemPreferDark(val) {
|
||||
update('system', val);
|
||||
return true;
|
||||
},
|
||||
};
|
||||
|
||||
function calcTime(key) {
|
||||
const [h, m] = prefs.get(key).split(':');
|
||||
return (h * 3600 + m * 60) * 1000;
|
||||
}
|
||||
|
||||
function createAlarm(key, value) {
|
||||
const date = new Date();
|
||||
const [h, m] = value.split(':');
|
||||
date.setHours(h, m, 0, 0);
|
||||
if (date.getTime() < Date.now()) {
|
||||
date.setDate(date.getDate() + 1);
|
||||
}
|
||||
chrome.alarms.create(key, {
|
||||
when: date.getTime(),
|
||||
periodInMinutes: 24 * 60,
|
||||
});
|
||||
}
|
||||
|
||||
function updateTimePreferDark() {
|
||||
const now = Date.now() - new Date().setHours(0, 0, 0, 0);
|
||||
const start = calcTime(kSTART);
|
||||
const end = calcTime(kEND);
|
||||
const val = start > end ?
|
||||
now >= start || now < end :
|
||||
now >= start && now < end;
|
||||
update('time', val);
|
||||
}
|
||||
|
||||
function update(type, val) {
|
||||
if (type) {
|
||||
if (isDark[type] === val) return;
|
||||
isDark[type] = val;
|
||||
}
|
||||
val = isDark[prefs.get(kSTATE)];
|
||||
if (isDarkNow !== val) {
|
||||
isDarkNow = val;
|
||||
for (const listener of changeListeners) {
|
||||
listener(isDarkNow);
|
||||
}
|
||||
}
|
||||
}
|
||||
})();
|
92
background/common.js
Normal file
92
background/common.js
Normal file
|
@ -0,0 +1,92 @@
|
|||
/* global API */// msg.js
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Common stuff that's loaded first so it's immediately available to all background scripts
|
||||
*/
|
||||
|
||||
window.bgReady = {}; /* global bgReady */
|
||||
bgReady.styles = new Promise(r => (bgReady._resolveStyles = r));
|
||||
bgReady.all = new Promise(r => (bgReady._resolveAll = r));
|
||||
|
||||
const uuidIndex = Object.assign(new Map(), {
|
||||
custom: {},
|
||||
/** `obj` must have a unique `id`, a UUIDv4 `_id`, and Date.now() for `_rev`. */
|
||||
addCustomId(obj, {get = () => obj, set}) {
|
||||
Object.defineProperty(uuidIndex.custom, obj.id, {get, set});
|
||||
},
|
||||
});
|
||||
|
||||
/* exported addAPI */
|
||||
function addAPI(methods) {
|
||||
for (const [key, val] of Object.entries(methods)) {
|
||||
const old = API[key];
|
||||
if (old && Object.prototype.toString.call(old) === '[object Object]') {
|
||||
Object.assign(old, val);
|
||||
} else {
|
||||
API[key] = val;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* exported createCache */
|
||||
/** Creates a FIFO limit-size map. */
|
||||
function createCache({size = 1000, onDeleted} = {}) {
|
||||
const map = new Map();
|
||||
const buffer = Array(size);
|
||||
let index = 0;
|
||||
let lastIndex = 0;
|
||||
return {
|
||||
get(id) {
|
||||
const item = map.get(id);
|
||||
return item && item.data;
|
||||
},
|
||||
set(id, data) {
|
||||
if (map.size === size) {
|
||||
// full
|
||||
map.delete(buffer[lastIndex].id);
|
||||
if (onDeleted) {
|
||||
onDeleted(buffer[lastIndex].id, buffer[lastIndex].data);
|
||||
}
|
||||
lastIndex = (lastIndex + 1) % size;
|
||||
}
|
||||
const item = {id, data, index};
|
||||
map.set(id, item);
|
||||
buffer[index] = item;
|
||||
index = (index + 1) % size;
|
||||
},
|
||||
delete(id) {
|
||||
const item = map.get(id);
|
||||
if (!item) {
|
||||
return false;
|
||||
}
|
||||
map.delete(item.id);
|
||||
const lastItem = buffer[lastIndex];
|
||||
lastItem.index = item.index;
|
||||
buffer[item.index] = lastItem;
|
||||
lastIndex = (lastIndex + 1) % size;
|
||||
if (onDeleted) {
|
||||
onDeleted(item.id, item.data);
|
||||
}
|
||||
return true;
|
||||
},
|
||||
clear() {
|
||||
map.clear();
|
||||
index = lastIndex = 0;
|
||||
},
|
||||
has: id => map.has(id),
|
||||
*entries() {
|
||||
for (const [id, item] of map) {
|
||||
yield [id, item.data];
|
||||
}
|
||||
},
|
||||
*values() {
|
||||
for (const item of map.values()) {
|
||||
yield item.data;
|
||||
}
|
||||
},
|
||||
get size() {
|
||||
return map.size;
|
||||
},
|
||||
};
|
||||
}
|
117
background/content-scripts.js
Normal file
117
background/content-scripts.js
Normal file
|
@ -0,0 +1,117 @@
|
|||
/* global bgReady */// common.js
|
||||
/* global msg */
|
||||
/* global URLS ignoreChromeError */// toolbox.js
|
||||
'use strict';
|
||||
|
||||
/*
|
||||
Reinject content scripts when the extension is reloaded/updated.
|
||||
Not used in Firefox as it reinjects automatically.
|
||||
*/
|
||||
|
||||
bgReady.all.then(() => {
|
||||
const NTP = 'chrome://newtab/';
|
||||
const ALL_URLS = '<all_urls>';
|
||||
const SCRIPTS = chrome.runtime.getManifest().content_scripts;
|
||||
// expand * as .*?
|
||||
const wildcardAsRegExp = (s, flags) => new RegExp(
|
||||
s.replace(/[{}()[\]/\\.+?^$:=!|]/g, '\\$&')
|
||||
.replace(/\*/g, '.*?'), flags);
|
||||
for (const cs of SCRIPTS) {
|
||||
cs.matches = cs.matches.map(m => (
|
||||
m === ALL_URLS ? m : wildcardAsRegExp(m)
|
||||
));
|
||||
}
|
||||
const busyTabs = new Set();
|
||||
let busyTabsTimer;
|
||||
|
||||
setTimeout(injectToAllTabs);
|
||||
|
||||
function injectToTab({url, tabId, frameId = null}) {
|
||||
for (const script of SCRIPTS) {
|
||||
if (
|
||||
script.matches.some(match =>
|
||||
(match === ALL_URLS || url.match(match)) &&
|
||||
(!url.startsWith('chrome') || url === NTP))
|
||||
) {
|
||||
doInject(tabId, frameId, script);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function doInject(tabId, frameId, script) {
|
||||
const options = frameId === null ? {} : {frameId};
|
||||
msg.sendTab(tabId, {method: 'ping'}, options)
|
||||
.catch(() => false)
|
||||
.then(pong => {
|
||||
if (pong) {
|
||||
return;
|
||||
}
|
||||
const options = {
|
||||
runAt: script.run_at,
|
||||
allFrames: script.all_frames,
|
||||
matchAboutBlank: script.match_about_blank,
|
||||
};
|
||||
if (frameId !== null) {
|
||||
options.allFrames = false;
|
||||
options.frameId = frameId;
|
||||
}
|
||||
for (const file of script.js) {
|
||||
chrome.tabs.executeScript(tabId, Object.assign({file}, options), ignoreChromeError);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function injectToAllTabs() {
|
||||
return browser.tabs.query({}).then(tabs => {
|
||||
for (const tab of tabs) {
|
||||
// skip unloaded/discarded/chrome tabs
|
||||
if (!tab.width || tab.discarded || !URLS.supported(tab.pendingUrl || tab.url)) continue;
|
||||
// our content scripts may still be pending injection at browser start so it's too early to ping them
|
||||
if (tab.status === 'loading') {
|
||||
trackBusyTab(tab.id, true);
|
||||
} else {
|
||||
injectToTab({
|
||||
url: tab.pendingUrl || tab.url,
|
||||
tabId: tab.id,
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function toggleBusyTabListeners(state) {
|
||||
const toggle = state ? 'addListener' : 'removeListener';
|
||||
chrome.webNavigation.onCompleted[toggle](onBusyTabUpdated);
|
||||
chrome.webNavigation.onErrorOccurred[toggle](onBusyTabUpdated);
|
||||
chrome.webNavigation.onTabReplaced[toggle](onBusyTabReplaced);
|
||||
chrome.tabs.onRemoved[toggle](onBusyTabRemoved);
|
||||
if (state) {
|
||||
busyTabsTimer = setTimeout(toggleBusyTabListeners, 15e3, false);
|
||||
} else {
|
||||
clearTimeout(busyTabsTimer);
|
||||
}
|
||||
}
|
||||
|
||||
function trackBusyTab(tabId, state) {
|
||||
busyTabs[state ? 'add' : 'delete'](tabId);
|
||||
if (state && busyTabs.size === 1) toggleBusyTabListeners(true);
|
||||
if (!state && !busyTabs.size) toggleBusyTabListeners(false);
|
||||
}
|
||||
|
||||
function onBusyTabUpdated({error, frameId, tabId, url}) {
|
||||
if (!frameId && busyTabs.has(tabId)) {
|
||||
trackBusyTab(tabId, false);
|
||||
if (url && !error) {
|
||||
injectToTab({tabId, url});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function onBusyTabReplaced({replacedTabId}) {
|
||||
trackBusyTab(replacedTabId, false);
|
||||
}
|
||||
|
||||
function onBusyTabRemoved(tabId) {
|
||||
trackBusyTab(tabId, false);
|
||||
}
|
||||
});
|
87
background/context-menus.js
Normal file
87
background/context-menus.js
Normal file
|
@ -0,0 +1,87 @@
|
|||
/* global browserCommands */// background.js
|
||||
/* global msg */
|
||||
/* global prefs */
|
||||
/* global CHROME URLS ignoreChromeError */// toolbox.js
|
||||
'use strict';
|
||||
|
||||
chrome.management.getSelf(ext => {
|
||||
const contextMenus = Object.assign({
|
||||
'show-badge': {
|
||||
title: 'menuShowBadge',
|
||||
click: togglePref,
|
||||
},
|
||||
'disableAll': {
|
||||
title: 'disableAllStyles',
|
||||
click: browserCommands.styleDisableAll,
|
||||
},
|
||||
'open-manager': {
|
||||
title: 'optionsOpenManager',
|
||||
click: browserCommands.openManage,
|
||||
},
|
||||
'open-options': {
|
||||
title: 'openOptions',
|
||||
click: browserCommands.openOptions,
|
||||
},
|
||||
}, ext.installType === 'development' && {
|
||||
'reload': {
|
||||
title: 'reload',
|
||||
click: browserCommands.reload,
|
||||
},
|
||||
}, CHROME && {
|
||||
'editor.contextDelete': {
|
||||
title: 'editDeleteText',
|
||||
type: 'normal',
|
||||
contexts: ['editable'],
|
||||
documentUrlPatterns: [URLS.ownOrigin + '*'],
|
||||
click: (info, tab) => {
|
||||
msg.sendTab(tab.id, {method: 'editDeleteText'}, undefined, 'extension')
|
||||
.catch(msg.ignoreError);
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
createContextMenus(Object.keys(contextMenus));
|
||||
chrome.contextMenus.onClicked.addListener((info, tab) =>
|
||||
contextMenus[info.menuItemId].click(info, tab));
|
||||
|
||||
function createContextMenus(ids) {
|
||||
for (const id of ids) {
|
||||
const item = Object.assign({id, contexts: ['browser_action']}, contextMenus[id]);
|
||||
item.title = chrome.i18n.getMessage(item.title);
|
||||
if (typeof prefs.defaults[id] === 'boolean') {
|
||||
if (item.type) {
|
||||
prefs.subscribe(id, togglePresence);
|
||||
} else {
|
||||
item.type = 'checkbox';
|
||||
item.checked = prefs.get(id);
|
||||
prefs.subscribe(id, CHROME >= 62 && CHROME <= 64 ? toggleCheckmarkBugged : toggleCheckmark);
|
||||
}
|
||||
}
|
||||
delete item.click;
|
||||
chrome.contextMenus.create(item, ignoreChromeError);
|
||||
}
|
||||
}
|
||||
|
||||
function toggleCheckmark(id, checked) {
|
||||
chrome.contextMenus.update(id, {checked}, ignoreChromeError);
|
||||
}
|
||||
|
||||
/** Circumvents the bug with disabling check marks in Chrome 62-64 */
|
||||
async function toggleCheckmarkBugged(id) {
|
||||
await browser.contextMenus.remove(id).catch(ignoreChromeError);
|
||||
createContextMenus([id]);
|
||||
}
|
||||
|
||||
/** @param {chrome.contextMenus.OnClickData} info */
|
||||
function togglePref(info) {
|
||||
prefs.set(info.menuItemId, info.checked);
|
||||
}
|
||||
|
||||
function togglePresence(id, checked) {
|
||||
if (checked) {
|
||||
createContextMenus([id]);
|
||||
} else {
|
||||
chrome.contextMenus.remove(id, ignoreChromeError);
|
||||
}
|
||||
}
|
||||
});
|
64
background/db-chrome-storage.js
Normal file
64
background/db-chrome-storage.js
Normal file
|
@ -0,0 +1,64 @@
|
|||
/* global chromeLocal */// storage-util.js
|
||||
'use strict';
|
||||
|
||||
/* exported createChromeStorageDB */
|
||||
function createChromeStorageDB(PREFIX) {
|
||||
let INC;
|
||||
const isMain = !PREFIX;
|
||||
if (!PREFIX) PREFIX = 'style-';
|
||||
|
||||
return {
|
||||
|
||||
delete(id) {
|
||||
return chromeLocal.remove(PREFIX + id);
|
||||
},
|
||||
|
||||
get(id) {
|
||||
return chromeLocal.getValue(PREFIX + id);
|
||||
},
|
||||
|
||||
async getAll() {
|
||||
const all = await chromeLocal.get();
|
||||
if (!INC) prepareInc(all);
|
||||
return Object.entries(all)
|
||||
.map(([key, val]) => key.startsWith(PREFIX) &&
|
||||
(!isMain || Number(key.slice(PREFIX.length))) &&
|
||||
val)
|
||||
.filter(Boolean);
|
||||
},
|
||||
|
||||
async put(item) {
|
||||
if (!item.id) {
|
||||
if (!INC) await prepareInc();
|
||||
item.id = INC++;
|
||||
}
|
||||
await chromeLocal.setValue(PREFIX + item.id, item);
|
||||
return item.id;
|
||||
},
|
||||
|
||||
async putMany(items) {
|
||||
const data = {};
|
||||
for (const item of items) {
|
||||
if (!item.id) {
|
||||
if (!INC) await prepareInc();
|
||||
item.id = INC++;
|
||||
}
|
||||
data[PREFIX + item.id] = item;
|
||||
}
|
||||
await chromeLocal.set(data);
|
||||
return items.map(_ => _.id);
|
||||
},
|
||||
};
|
||||
|
||||
async function prepareInc(data) {
|
||||
INC = 1;
|
||||
for (const key in data || await chromeLocal.get()) {
|
||||
if (key.startsWith(PREFIX)) {
|
||||
const id = Number(key.slice(PREFIX.length));
|
||||
if (id >= INC) {
|
||||
INC = id + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
150
background/db.js
Normal file
150
background/db.js
Normal file
|
@ -0,0 +1,150 @@
|
|||
/* global addAPI */// common.js
|
||||
/* global chromeLocal */// storage-util.js
|
||||
/* global cloneError */// worker-util.js
|
||||
/* global deepCopy */// toolbox.js
|
||||
/* global prefs */
|
||||
'use strict';
|
||||
|
||||
/*
|
||||
Initialize a database. There are some problems using IndexedDB in Firefox:
|
||||
https://www.reddit.com/r/firefox/comments/74wttb/note_to_firefox_webextension_developers_who_use/
|
||||
Some of them are fixed in FF59:
|
||||
https://www.reddit.com/r/firefox/comments/7ijuaq/firefox_59_webextensions_can_use_indexeddb_when/
|
||||
*/
|
||||
|
||||
/* exported db */
|
||||
const db = (() => {
|
||||
let exec = async (...args) => (
|
||||
exec = await tryUsingIndexedDB().catch(useChromeStorage)
|
||||
)(...args);
|
||||
const DB = 'stylish';
|
||||
const FALLBACK = 'dbInChromeStorage';
|
||||
const ID_AS_KEY = {[DB]: true};
|
||||
const getStoreName = dbName => dbName === DB ? 'styles' : 'data';
|
||||
const cache = {};
|
||||
const proxies = {};
|
||||
const proxyHandler = {
|
||||
get: ({dbName}, cmd) =>
|
||||
(...args) =>
|
||||
(dbName === DB ? exec : cachedExec)(dbName, cmd, ...args),
|
||||
};
|
||||
/**
|
||||
* @param {string} dbName
|
||||
* @return {IDBObjectStore | {putMany: function(items:?[]):Promise<?[]>}}
|
||||
*/
|
||||
const getProxy = dbName => proxies[dbName] || (
|
||||
(proxies[dbName] = new Proxy({dbName}, proxyHandler))
|
||||
);
|
||||
addAPI(/** @namespace API */ {
|
||||
drafts: getProxy('drafts'),
|
||||
/** Storage for big items that may exceed 8kB limit of chrome.storage.sync.
|
||||
* To make an item syncable register it with uuidIndex.addCustomId. */
|
||||
prefsDb: getProxy(prefs.STORAGE_KEY),
|
||||
});
|
||||
return {
|
||||
styles: getProxy(DB),
|
||||
};
|
||||
|
||||
async function cachedExec(dbName, cmd, a, b) {
|
||||
const hub = cache[dbName] || (cache[dbName] = {});
|
||||
const res = cmd === 'get' && a in hub ? hub[a] : await exec(...arguments);
|
||||
if (cmd === 'get') {
|
||||
hub[a] = deepCopy(res);
|
||||
} else if (cmd === 'put') {
|
||||
hub[ID_AS_KEY[dbName] ? a.id : b] = deepCopy(a);
|
||||
} else if (cmd === 'delete') {
|
||||
delete hub[a];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
async function tryUsingIndexedDB() {
|
||||
// we use chrome.storage.local fallback if IndexedDB doesn't save data,
|
||||
// which, once detected on the first run, is remembered in chrome.storage.local
|
||||
// note that accessing indexedDB may throw, https://github.com/openstyles/stylus/issues/615
|
||||
if (typeof indexedDB === 'undefined') {
|
||||
throw new Error('indexedDB is undefined');
|
||||
}
|
||||
switch (await chromeLocal.getValue(FALLBACK)) {
|
||||
case true: throw null;
|
||||
case false: break;
|
||||
default: await testDB();
|
||||
}
|
||||
chromeLocal.setValue(FALLBACK, false);
|
||||
return dbExecIndexedDB;
|
||||
}
|
||||
|
||||
async function testDB() {
|
||||
const id = `${performance.now()}.${Math.random()}.${Date.now()}`;
|
||||
await dbExecIndexedDB(DB, 'put', {id});
|
||||
const e = await dbExecIndexedDB(DB, 'get', id);
|
||||
await dbExecIndexedDB(DB, 'delete', e.id); // throws if `e` or id is null
|
||||
}
|
||||
|
||||
async function useChromeStorage(err) {
|
||||
chromeLocal.setValue(FALLBACK, true);
|
||||
if (err) {
|
||||
chromeLocal.setValue(FALLBACK + 'Reason', cloneError(err));
|
||||
console.warn('Failed to access indexedDB. Switched to storage API.', err);
|
||||
}
|
||||
await require(['/background/db-chrome-storage']); /* global createChromeStorageDB */
|
||||
const BASES = {};
|
||||
return (dbName, method, ...args) => (
|
||||
BASES[dbName] || (
|
||||
BASES[dbName] = createChromeStorageDB(dbName !== DB && `${dbName}-`)
|
||||
)
|
||||
)[method](...args);
|
||||
}
|
||||
|
||||
async function dbExecIndexedDB(dbName, method, ...args) {
|
||||
const mode = method.startsWith('get') ? 'readonly' : 'readwrite';
|
||||
const storeName = getStoreName(dbName);
|
||||
const store = (await open(dbName)).transaction([storeName], mode).objectStore(storeName);
|
||||
const fn = method === 'putMany' ? putMany : storeRequest;
|
||||
return fn(store, method, ...args);
|
||||
}
|
||||
|
||||
function storeRequest(store, method, ...args) {
|
||||
return new Promise((resolve, reject) => {
|
||||
/** @type {IDBRequest} */
|
||||
const request = store[method](...args);
|
||||
request.onsuccess = () => resolve(request.result);
|
||||
request.onerror = reject;
|
||||
});
|
||||
}
|
||||
|
||||
function putMany(store, _method, items) {
|
||||
return Promise.all(items.map(item => storeRequest(store, 'put', item)));
|
||||
}
|
||||
|
||||
function open(name) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const request = indexedDB.open(name, 2);
|
||||
request.onsuccess = e => resolve(create(e));
|
||||
request.onerror = reject;
|
||||
request.onupgradeneeded = create;
|
||||
});
|
||||
}
|
||||
|
||||
function create(event) {
|
||||
/** @type IDBDatabase */
|
||||
const idb = event.target.result;
|
||||
const dbName = idb.name;
|
||||
const sn = getStoreName(dbName);
|
||||
if (!idb.objectStoreNames.contains(sn)) {
|
||||
if (event.type === 'success') {
|
||||
idb.close();
|
||||
return new Promise(resolve => {
|
||||
indexedDB.deleteDatabase(dbName).onsuccess = () => {
|
||||
resolve(open(dbName));
|
||||
};
|
||||
});
|
||||
}
|
||||
idb.createObjectStore(sn, ID_AS_KEY[dbName] ? {
|
||||
keyPath: 'id',
|
||||
autoIncrement: true,
|
||||
} : undefined);
|
||||
}
|
||||
return idb;
|
||||
}
|
||||
})();
|
232
background/icon-manager.js
Normal file
232
background/icon-manager.js
Normal file
|
@ -0,0 +1,232 @@
|
|||
/* global API */// msg.js
|
||||
/* global addAPI bgReady */// common.js
|
||||
/* global colorScheme */
|
||||
/* global prefs */
|
||||
/* global tabMan */
|
||||
/* global CHROME FIREFOX UA debounce ignoreChromeError */// toolbox.js
|
||||
'use strict';
|
||||
|
||||
/* exported iconMan */
|
||||
const iconMan = (() => {
|
||||
const ICON_SIZES = FIREFOX || CHROME && !UA.vivaldi ? [16, 32] : [19, 38];
|
||||
const staleBadges = new Set();
|
||||
const imageDataCache = new Map();
|
||||
const badgeOvr = {color: '', text: ''};
|
||||
// https://github.com/openstyles/stylus/issues/1287 Fenix can't use custom ImageData
|
||||
const FIREFOX_ANDROID = FIREFOX && UA.mobile;
|
||||
let isDark;
|
||||
// https://github.com/openstyles/stylus/issues/335
|
||||
let hasCanvas = FIREFOX_ANDROID ? false : loadImage(`/images/icon/${ICON_SIZES[0]}.png`)
|
||||
.then(({data}) => (hasCanvas = data.some(b => b !== 255)));
|
||||
|
||||
addAPI(/** @namespace API */ {
|
||||
/**
|
||||
* @param {(number|string)[]} styleIds
|
||||
* @param {boolean} [lazyBadge=false] preventing flicker during page load
|
||||
*/
|
||||
updateIconBadge(styleIds, {lazyBadge} = {}) {
|
||||
// FIXME: in some cases, we only have to redraw the badge. is it worth a optimization?
|
||||
const {frameId, tab: {id: tabId}} = this.sender;
|
||||
const value = styleIds.length ? styleIds.map(Number) : undefined;
|
||||
tabMan.set(tabId, 'styleIds', frameId, value);
|
||||
debounce(refreshStaleBadges, frameId && lazyBadge ? 250 : 0);
|
||||
staleBadges.add(tabId);
|
||||
if (!frameId) refreshIcon(tabId, true);
|
||||
},
|
||||
});
|
||||
|
||||
chrome.webNavigation.onCommitted.addListener(({tabId, frameId}) => {
|
||||
if (!frameId) tabMan.set(tabId, 'styleIds', undefined);
|
||||
});
|
||||
chrome.runtime.onConnect.addListener(port => {
|
||||
if (port.name === 'iframe') {
|
||||
port.onDisconnect.addListener(onPortDisconnected);
|
||||
}
|
||||
});
|
||||
colorScheme.onChange(val => {
|
||||
isDark = val;
|
||||
if (prefs.get('iconset') === -1) {
|
||||
debounce(refreshAllIcons);
|
||||
}
|
||||
});
|
||||
bgReady.all.then(() => {
|
||||
prefs.subscribe([
|
||||
'disableAll',
|
||||
'badgeDisabled',
|
||||
'badgeNormal',
|
||||
], () => debounce(refreshIconBadgeColor), {runNow: true});
|
||||
prefs.subscribe([
|
||||
'show-badge',
|
||||
], () => debounce(refreshAllIconsBadgeText), {runNow: true});
|
||||
prefs.subscribe([
|
||||
'disableAll',
|
||||
'iconset',
|
||||
], () => debounce(refreshAllIcons), {runNow: true});
|
||||
});
|
||||
|
||||
return {
|
||||
/** Calling with no params clears the override */
|
||||
overrideBadge({text = '', color = '', title = ''} = {}) {
|
||||
if (badgeOvr.text === text) {
|
||||
return;
|
||||
}
|
||||
badgeOvr.text = text;
|
||||
badgeOvr.color = color;
|
||||
refreshIconBadgeColor();
|
||||
setBadgeText({text});
|
||||
for (const tabId of tabMan.list()) {
|
||||
if (text) {
|
||||
setBadgeText({tabId, text});
|
||||
} else {
|
||||
refreshIconBadgeText(tabId);
|
||||
}
|
||||
}
|
||||
chrome.browserAction.setTitle({
|
||||
title: title && chrome.i18n.getMessage(title) || title || '',
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
function onPortDisconnected({sender}) {
|
||||
if (tabMan.get(sender.tab.id, 'styleIds')) {
|
||||
API.updateIconBadge.call({sender}, [], {lazyBadge: true});
|
||||
}
|
||||
}
|
||||
|
||||
function refreshIconBadgeText(tabId) {
|
||||
if (badgeOvr.text) return;
|
||||
const text = prefs.get('show-badge') ? `${getStyleCount(tabId)}` : '';
|
||||
setBadgeText({tabId, text});
|
||||
}
|
||||
|
||||
function getIconName(hasStyles = false) {
|
||||
const i = prefs.get('iconset');
|
||||
const prefix = i === 0 || i === -1 && isDark ? '' : 'light/';
|
||||
const postfix = prefs.get('disableAll') ? 'x' : !hasStyles ? 'w' : '';
|
||||
return `${prefix}$SIZE$${postfix}`;
|
||||
}
|
||||
|
||||
function refreshIcon(tabId, force = false) {
|
||||
const oldIcon = tabMan.get(tabId, 'icon');
|
||||
const newIcon = getIconName(tabMan.get(tabId, 'styleIds', 0));
|
||||
// (changing the icon only for the main page, frameId = 0)
|
||||
|
||||
if (!force && oldIcon === newIcon) {
|
||||
return;
|
||||
}
|
||||
tabMan.set(tabId, 'icon', newIcon);
|
||||
setIcon({
|
||||
path: getIconPath(newIcon),
|
||||
tabId,
|
||||
});
|
||||
}
|
||||
|
||||
function getIconPath(icon) {
|
||||
return ICON_SIZES.reduce(
|
||||
(obj, size) => {
|
||||
obj[size] = `/images/icon/${icon.replace('$SIZE$', size)}.png`;
|
||||
return obj;
|
||||
},
|
||||
{}
|
||||
);
|
||||
}
|
||||
|
||||
/** @return {number | ''} */
|
||||
function getStyleCount(tabId) {
|
||||
const allIds = new Set();
|
||||
const data = tabMan.get(tabId, 'styleIds') || {};
|
||||
Object.values(data).forEach(frameIds => frameIds.forEach(id => allIds.add(id)));
|
||||
return allIds.size || '';
|
||||
}
|
||||
|
||||
// Caches imageData for icon paths
|
||||
async function loadImage(url) {
|
||||
const {OffscreenCanvas} = !FIREFOX && self.createImageBitmap && self || {};
|
||||
const img = OffscreenCanvas
|
||||
? await createImageBitmap(await (await fetch(url)).blob())
|
||||
: await new Promise((resolve, reject) =>
|
||||
Object.assign(new Image(), {
|
||||
src: url,
|
||||
onload: e => resolve(e.target),
|
||||
onerror: reject,
|
||||
}));
|
||||
const {width: w, height: h} = img;
|
||||
const canvas = OffscreenCanvas
|
||||
? new OffscreenCanvas(w, h)
|
||||
: Object.assign(document.createElement('canvas'), {width: w, height: h});
|
||||
const ctx = canvas.getContext('2d');
|
||||
ctx.drawImage(img, 0, 0, w, h);
|
||||
const result = ctx.getImageData(0, 0, w, h);
|
||||
imageDataCache.set(url, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
function refreshGlobalIcon() {
|
||||
setIcon({
|
||||
path: getIconPath(getIconName()),
|
||||
});
|
||||
}
|
||||
|
||||
function refreshIconBadgeColor() {
|
||||
setBadgeBackgroundColor({
|
||||
color: badgeOvr.color ||
|
||||
prefs.get(prefs.get('disableAll') ? 'badgeDisabled' : 'badgeNormal'),
|
||||
});
|
||||
}
|
||||
|
||||
function refreshAllIcons() {
|
||||
for (const tabId of tabMan.list()) {
|
||||
refreshIcon(tabId);
|
||||
}
|
||||
refreshGlobalIcon();
|
||||
}
|
||||
|
||||
function refreshAllIconsBadgeText() {
|
||||
for (const tabId of tabMan.list()) {
|
||||
refreshIconBadgeText(tabId);
|
||||
}
|
||||
}
|
||||
|
||||
function refreshStaleBadges() {
|
||||
for (const tabId of staleBadges) {
|
||||
refreshIconBadgeText(tabId);
|
||||
}
|
||||
staleBadges.clear();
|
||||
}
|
||||
|
||||
function safeCall(method, data) {
|
||||
const {browserAction = {}} = chrome;
|
||||
const fn = browserAction[method];
|
||||
if (fn) {
|
||||
try {
|
||||
// Chrome supports the callback since 67.0.3381.0, see https://crbug.com/451320
|
||||
fn.call(browserAction, data, ignoreChromeError);
|
||||
} catch (e) {
|
||||
// FIXME: skip pre-rendered tabs?
|
||||
fn.call(browserAction, data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** @param {chrome.browserAction.TabIconDetails} data */
|
||||
async function setIcon(data) {
|
||||
if (hasCanvas === true || await hasCanvas) {
|
||||
data.imageData = {};
|
||||
for (const [key, url] of Object.entries(data.path)) {
|
||||
data.imageData[key] = imageDataCache.get(url) || await loadImage(url);
|
||||
}
|
||||
delete data.path;
|
||||
}
|
||||
safeCall('setIcon', data);
|
||||
}
|
||||
|
||||
/** @param {chrome.browserAction.BadgeTextDetails} data */
|
||||
function setBadgeText(data) {
|
||||
safeCall('setBadgeText', data);
|
||||
}
|
||||
|
||||
/** @param {chrome.browserAction.BadgeBackgroundColorDetails} data */
|
||||
function setBadgeBackgroundColor(data) {
|
||||
safeCall('setBadgeBackgroundColor', data);
|
||||
}
|
||||
})();
|
103
background/navigation-manager.js
Normal file
103
background/navigation-manager.js
Normal file
|
@ -0,0 +1,103 @@
|
|||
/* global CHROME FIREFOX URLS deepEqual ignoreChromeError */// toolbox.js
|
||||
/* global bgReady */// common.js
|
||||
/* global msg */
|
||||
'use strict';
|
||||
|
||||
/* exported navMan */
|
||||
const navMan = (() => {
|
||||
const listeners = new Set();
|
||||
let prevData = {};
|
||||
|
||||
chrome.webNavigation.onCommitted.addListener(onNavigation.bind('committed'));
|
||||
chrome.webNavigation.onHistoryStateUpdated.addListener(onFakeNavigation.bind('history'));
|
||||
chrome.webNavigation.onReferenceFragmentUpdated.addListener(onFakeNavigation.bind('hash'));
|
||||
|
||||
return {
|
||||
/** @param {function(data: Object, type: ('committed'|'history'|'hash'))} fn */
|
||||
onUrlChange(fn) {
|
||||
listeners.add(fn);
|
||||
},
|
||||
};
|
||||
|
||||
/** @this {string} type */
|
||||
async function onNavigation(data) {
|
||||
if (CHROME && data.timeStamp === prevData.timeStamp && deepEqual(data, prevData)) {
|
||||
return; // Chrome bug: listener is called twice with identical data
|
||||
}
|
||||
prevData = data;
|
||||
if (CHROME &&
|
||||
URLS.chromeProtectsNTP &&
|
||||
data.url.startsWith('https://www.google.') &&
|
||||
data.url.includes('/_/chrome/newtab?')) {
|
||||
// Modern Chrome switched to WebUI NTP so this is obsolete, but there may be exceptions
|
||||
// TODO: investigate, and maybe use a separate listener for CHROME <= ver
|
||||
const tab = await browser.tabs.get(data.tabId);
|
||||
const url = tab.pendingUrl || tab.url;
|
||||
if (url === 'chrome://newtab/') {
|
||||
data.url = url;
|
||||
}
|
||||
}
|
||||
listeners.forEach(fn => fn(data, this));
|
||||
}
|
||||
|
||||
/** @this {string} type */
|
||||
function onFakeNavigation(data) {
|
||||
const {url, frameId} = data;
|
||||
onNavigation.call(this, data);
|
||||
msg.sendTab(data.tabId, {method: 'urlChanged', url}, {frameId})
|
||||
.catch(msg.ignoreError);
|
||||
}
|
||||
})();
|
||||
|
||||
bgReady.all.then(() => {
|
||||
/*
|
||||
* Expose style version on greasyfork/sleazyfork 1) info page and 2) code page
|
||||
* Not using manifest.json as adding a content script disables the extension on update.
|
||||
*/
|
||||
const urlMatches = '/scripts/\\d+[^/]*(/code)?([?#].*)?$';
|
||||
chrome.webNavigation.onCommitted.addListener(({tabId}) => {
|
||||
chrome.tabs.executeScript(tabId, {
|
||||
file: '/content/install-hook-greasyfork.js',
|
||||
runAt: 'document_start',
|
||||
});
|
||||
}, {
|
||||
url: [
|
||||
{hostEquals: 'greasyfork.org', urlMatches},
|
||||
{hostEquals: 'sleazyfork.org', urlMatches},
|
||||
],
|
||||
});
|
||||
|
||||
/*
|
||||
* Removes the Get Stylus button on style pages.
|
||||
* Not using manifest.json as adding a content script disables the extension on update.
|
||||
*/
|
||||
chrome.webNavigation.onCommitted.addListener(({tabId}) => {
|
||||
chrome.tabs.executeScript(tabId, {
|
||||
file: '/content/install-hook-userstylesworld.js',
|
||||
runAt: 'document_start',
|
||||
});
|
||||
}, {
|
||||
url: [
|
||||
{hostEquals: 'userstyles.world'},
|
||||
],
|
||||
});
|
||||
/*
|
||||
* FF misses some about:blank iframes so we inject our content script explicitly
|
||||
*/
|
||||
if (FIREFOX) {
|
||||
chrome.webNavigation.onDOMContentLoaded.addListener(async ({tabId, frameId}) => {
|
||||
if (frameId &&
|
||||
!await msg.sendTab(tabId, {method: 'ping'}, {frameId}).catch(ignoreChromeError)) {
|
||||
for (const file of chrome.runtime.getManifest().content_scripts[0].js) {
|
||||
chrome.tabs.executeScript(tabId, {
|
||||
frameId,
|
||||
file,
|
||||
matchAboutBlank: true,
|
||||
}, ignoreChromeError);
|
||||
}
|
||||
}
|
||||
}, {
|
||||
url: [{urlEquals: 'about:blank'}],
|
||||
});
|
||||
}
|
||||
});
|
|
@ -1,803 +0,0 @@
|
|||
/* global LZString */
|
||||
'use strict';
|
||||
|
||||
const RX_NAMESPACE = new RegExp([/[\s\r\n]*/,
|
||||
/(@namespace[\s\r\n]+(?:[^\s\r\n]+[\s\r\n]+)?url\(http:\/\/.*?\);)/,
|
||||
/[\s\r\n]*/].map(rx => rx.source).join(''), 'g');
|
||||
const RX_CSS_COMMENTS = /\/\*[\s\S]*?\*\//g;
|
||||
// eslint-disable-next-line no-var
|
||||
var SLOPPY_REGEXP_PREFIX = '\0';
|
||||
|
||||
// CSS transition bug workaround: since we insert styles asynchronously,
|
||||
// the browsers, especially Firefox, may apply all transitions on page load
|
||||
const CSS_TRANSITION_SUPPRESSOR = '* { transition: none !important; }';
|
||||
const RX_CSS_TRANSITION_DETECTOR = /([\s\n;/{]|-webkit-|-moz-)transition[\s\n]*:[\s\n]*(?!none)/;
|
||||
|
||||
// Note, only 'var'-declared variables are visible from another extension page
|
||||
// eslint-disable-next-line no-var
|
||||
var cachedStyles = {
|
||||
list: null, // array of all styles
|
||||
byId: new Map(), // all styles indexed by id
|
||||
filters: new Map(), // filterStyles() parameters mapped to the returned results, 10k max
|
||||
regexps: new Map(), // compiled style regexps
|
||||
urlDomains: new Map(), // getDomain() results for 100 last checked urls
|
||||
needTransitionPatch: new Map(), // FF bug workaround
|
||||
mutex: {
|
||||
inProgress: true, // while getStyles() is reading IndexedDB all subsequent calls
|
||||
// (initially 'true' to prevent rogue getStyles before dbExec.initialized)
|
||||
onDone: [], // to getStyles() are queued and resolved when the first one finishes
|
||||
},
|
||||
};
|
||||
|
||||
// eslint-disable-next-line no-var
|
||||
var chromeLocal = {
|
||||
get(options) {
|
||||
return new Promise(resolve => {
|
||||
chrome.storage.local.get(options, data => resolve(data));
|
||||
});
|
||||
},
|
||||
set(data) {
|
||||
return new Promise(resolve => {
|
||||
chrome.storage.local.set(data, () => resolve(data));
|
||||
});
|
||||
},
|
||||
remove(keyOrKeys) {
|
||||
return new Promise(resolve => {
|
||||
chrome.storage.local.remove(keyOrKeys, resolve);
|
||||
});
|
||||
},
|
||||
getValue(key) {
|
||||
return chromeLocal.get(key).then(data => data[key]);
|
||||
},
|
||||
setValue(key, value) {
|
||||
return chromeLocal.set({[key]: value});
|
||||
},
|
||||
};
|
||||
|
||||
// eslint-disable-next-line no-var
|
||||
var chromeSync = {
|
||||
get(options) {
|
||||
return new Promise(resolve => {
|
||||
chrome.storage.sync.get(options, resolve);
|
||||
});
|
||||
},
|
||||
set(data) {
|
||||
return new Promise(resolve => {
|
||||
chrome.storage.sync.set(data, () => resolve(data));
|
||||
});
|
||||
},
|
||||
getLZValue(key) {
|
||||
return chromeSync.getLZValues([key]).then(data => data[key]);
|
||||
},
|
||||
getLZValues(keys) {
|
||||
return chromeSync.get(keys).then((data = {}) => {
|
||||
for (const key of keys) {
|
||||
const value = data[key];
|
||||
data[key] = value && tryJSONparse(LZString.decompressFromUTF16(value));
|
||||
}
|
||||
return data;
|
||||
});
|
||||
},
|
||||
setLZValue(key, value) {
|
||||
return chromeSync.set({[key]: LZString.compressToUTF16(JSON.stringify(value))});
|
||||
}
|
||||
};
|
||||
|
||||
// eslint-disable-next-line no-var
|
||||
var dbExec = dbExecIndexedDB;
|
||||
dbExec.initialized = false;
|
||||
|
||||
// we use chrome.storage.local fallback if IndexedDB doesn't save data,
|
||||
// which, once detected on the first run, is remembered in chrome.storage.local
|
||||
// for reliablility and in localStorage for fast synchronous access
|
||||
// (FF may block localStorage depending on its privacy options)
|
||||
do {
|
||||
const done = () => {
|
||||
cachedStyles.mutex.inProgress = false;
|
||||
getStyles().then(() => {
|
||||
dbExec.initialized = true;
|
||||
window.dispatchEvent(new Event('storageReady'));
|
||||
});
|
||||
};
|
||||
const fallback = () => {
|
||||
dbExec = dbExecChromeStorage;
|
||||
chromeLocal.set({dbInChromeStorage: true});
|
||||
localStorage.dbInChromeStorage = 'true';
|
||||
ignoreChromeError();
|
||||
done();
|
||||
};
|
||||
const fallbackSet = localStorage.dbInChromeStorage;
|
||||
if (fallbackSet === 'true' || !tryCatch(() => indexedDB)) {
|
||||
fallback();
|
||||
break;
|
||||
} else if (fallbackSet === 'false') {
|
||||
done();
|
||||
break;
|
||||
}
|
||||
chromeLocal.get('dbInChromeStorage')
|
||||
.then(data =>
|
||||
data && data.dbInChromeStorage && Promise.reject())
|
||||
.then(() =>
|
||||
tryCatch(dbExecIndexedDB, 'getAllKeys', IDBKeyRange.lowerBound(1), 1) ||
|
||||
Promise.reject())
|
||||
.then(({target}) => (
|
||||
(target.result || [])[0] ?
|
||||
Promise.reject('ok') :
|
||||
dbExecIndexedDB('put', {id: -1})))
|
||||
.then(() =>
|
||||
dbExecIndexedDB('get', -1))
|
||||
.then(({target}) => (
|
||||
(target.result || {}).id === -1 ?
|
||||
dbExecIndexedDB('delete', -1) :
|
||||
Promise.reject()))
|
||||
.then(() =>
|
||||
Promise.reject('ok'))
|
||||
.catch(result => {
|
||||
if (result === 'ok') {
|
||||
chromeLocal.set({dbInChromeStorage: false});
|
||||
localStorage.dbInChromeStorage = 'false';
|
||||
done();
|
||||
} else {
|
||||
fallback();
|
||||
}
|
||||
});
|
||||
} while (0);
|
||||
|
||||
|
||||
function dbExecIndexedDB(method, ...args) {
|
||||
return new Promise((resolve, reject) => {
|
||||
Object.assign(indexedDB.open('stylish', 2), {
|
||||
onsuccess(event) {
|
||||
const database = event.target.result;
|
||||
if (!method) {
|
||||
resolve(database);
|
||||
} else {
|
||||
const transaction = database.transaction(['styles'], 'readwrite');
|
||||
const store = transaction.objectStore('styles');
|
||||
Object.assign(store[method](...args), {
|
||||
onsuccess: event => resolve(event, store, transaction, database),
|
||||
onerror: reject,
|
||||
});
|
||||
}
|
||||
},
|
||||
onerror(event) {
|
||||
console.warn(event.target.error || event.target.errorCode);
|
||||
reject(event);
|
||||
},
|
||||
onupgradeneeded(event) {
|
||||
if (event.oldVersion === 0) {
|
||||
event.target.result.createObjectStore('styles', {
|
||||
keyPath: 'id',
|
||||
autoIncrement: true,
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function dbExecChromeStorage(method, data) {
|
||||
const STYLE_KEY_PREFIX = 'style-';
|
||||
switch (method) {
|
||||
case 'get':
|
||||
return chromeLocal.getValue(STYLE_KEY_PREFIX + data)
|
||||
.then(result => ({target: {result}}));
|
||||
|
||||
case 'put':
|
||||
if (!data.id) {
|
||||
return getStyles().then(() => {
|
||||
data.id = 1;
|
||||
for (const style of cachedStyles.list) {
|
||||
data.id = Math.max(data.id, style.id + 1);
|
||||
}
|
||||
return dbExecChromeStorage('put', data);
|
||||
});
|
||||
}
|
||||
return chromeLocal.setValue(STYLE_KEY_PREFIX + data.id, data)
|
||||
.then(() => (chrome.runtime.lastError ? Promise.reject() : data.id));
|
||||
|
||||
case 'delete':
|
||||
return chromeLocal.remove(STYLE_KEY_PREFIX + data);
|
||||
|
||||
case 'getAll':
|
||||
return chromeLocal.get(null).then(storage => {
|
||||
const styles = [];
|
||||
for (const key in storage) {
|
||||
if (key.startsWith(STYLE_KEY_PREFIX) &&
|
||||
Number(key.substr(STYLE_KEY_PREFIX.length))) {
|
||||
styles.push(storage[key]);
|
||||
}
|
||||
}
|
||||
return {target: {result: styles}};
|
||||
});
|
||||
}
|
||||
return Promise.reject();
|
||||
}
|
||||
|
||||
|
||||
function getStyles(options) {
|
||||
if (cachedStyles.list) {
|
||||
return Promise.resolve(filterStyles(options));
|
||||
}
|
||||
if (cachedStyles.mutex.inProgress) {
|
||||
return new Promise(resolve => {
|
||||
cachedStyles.mutex.onDone.push({options, resolve});
|
||||
});
|
||||
}
|
||||
cachedStyles.mutex.inProgress = true;
|
||||
|
||||
return dbExec('getAll').then(event => {
|
||||
cachedStyles.list = event.target.result || [];
|
||||
cachedStyles.byId.clear();
|
||||
for (const style of cachedStyles.list) {
|
||||
cachedStyles.byId.set(style.id, style);
|
||||
}
|
||||
|
||||
cachedStyles.mutex.inProgress = false;
|
||||
for (const {options, resolve} of cachedStyles.mutex.onDone) {
|
||||
resolve(filterStyles(options));
|
||||
}
|
||||
cachedStyles.mutex.onDone = [];
|
||||
return filterStyles(options);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function filterStyles({
|
||||
enabled = null,
|
||||
url = null,
|
||||
id = null,
|
||||
matchUrl = null,
|
||||
asHash = null,
|
||||
strictRegexp = true, // used by the popup to detect bad regexps
|
||||
} = {}) {
|
||||
enabled = enabled === null || typeof enabled === 'boolean' ? enabled :
|
||||
typeof enabled === 'string' ? enabled === 'true' : null;
|
||||
id = id === null ? null : Number(id);
|
||||
|
||||
if (
|
||||
enabled === null &&
|
||||
url === null &&
|
||||
id === null &&
|
||||
matchUrl === null &&
|
||||
asHash !== true
|
||||
) {
|
||||
return cachedStyles.list;
|
||||
}
|
||||
|
||||
if (matchUrl && !URLS.supported(matchUrl)) {
|
||||
return asHash ? {} : [];
|
||||
}
|
||||
|
||||
const blankHash = asHash && {
|
||||
disableAll: prefs.get('disableAll'),
|
||||
exposeIframes: prefs.get('exposeIframes'),
|
||||
};
|
||||
|
||||
// add \t after url to prevent collisions (not sure it can actually happen though)
|
||||
const cacheKey = ' ' + enabled + url + '\t' + id + matchUrl + '\t' + asHash + strictRegexp;
|
||||
const cached = cachedStyles.filters.get(cacheKey);
|
||||
if (cached) {
|
||||
cached.hits++;
|
||||
cached.lastHit = Date.now();
|
||||
return asHash
|
||||
? Object.assign(blankHash, cached.styles)
|
||||
: cached.styles;
|
||||
}
|
||||
|
||||
return filterStylesInternal({
|
||||
enabled,
|
||||
url,
|
||||
id,
|
||||
matchUrl,
|
||||
asHash,
|
||||
strictRegexp,
|
||||
blankHash,
|
||||
cacheKey,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function filterStylesInternal({
|
||||
// js engines don't like big functions (V8 often deoptimized the original filterStyles)
|
||||
// it also makes sense to extract the less frequently executed code
|
||||
enabled,
|
||||
url,
|
||||
id,
|
||||
matchUrl,
|
||||
asHash,
|
||||
strictRegexp,
|
||||
blankHash,
|
||||
cacheKey,
|
||||
}) {
|
||||
if (matchUrl && !cachedStyles.urlDomains.has(matchUrl)) {
|
||||
cachedStyles.urlDomains.set(matchUrl, getDomains(matchUrl));
|
||||
for (let i = cachedStyles.urlDomains.size - 100; i > 0; i--) {
|
||||
const firstKey = cachedStyles.urlDomains.keys().next().value;
|
||||
cachedStyles.urlDomains.delete(firstKey);
|
||||
}
|
||||
}
|
||||
|
||||
const styles = id === null
|
||||
? cachedStyles.list
|
||||
: [cachedStyles.byId.get(id)];
|
||||
if (!styles[0]) {
|
||||
// may happen when users [accidentally] reopen an old URL
|
||||
// of edit.html with a non-existent style id parameter
|
||||
return asHash ? blankHash : [];
|
||||
}
|
||||
const filtered = asHash ? {} : [];
|
||||
const needSections = asHash || matchUrl !== null;
|
||||
const matchUrlBase = matchUrl && matchUrl.includes('#') && matchUrl.split('#', 1)[0];
|
||||
|
||||
let style;
|
||||
for (let i = 0; (style = styles[i]); i++) {
|
||||
if ((enabled === null || style.enabled === enabled)
|
||||
&& (url === null || style.url === url)
|
||||
&& (id === null || style.id === id)) {
|
||||
const sections = needSections &&
|
||||
getApplicableSections({
|
||||
style,
|
||||
matchUrl,
|
||||
strictRegexp,
|
||||
stopOnFirst: !asHash,
|
||||
skipUrlCheck: true,
|
||||
matchUrlBase,
|
||||
});
|
||||
if (asHash) {
|
||||
if (sections.length) {
|
||||
filtered[style.id] = sections;
|
||||
}
|
||||
} else if (matchUrl === null || sections.length) {
|
||||
filtered.push(style);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cachedStyles.filters.set(cacheKey, {
|
||||
styles: filtered,
|
||||
lastHit: Date.now(),
|
||||
hits: 1,
|
||||
});
|
||||
if (cachedStyles.filters.size > 10000) {
|
||||
cleanupCachedFilters();
|
||||
}
|
||||
|
||||
// a shallow copy is needed because the cache doesn't store options like disableAll
|
||||
return asHash
|
||||
? Object.assign(blankHash, filtered)
|
||||
: filtered;
|
||||
}
|
||||
|
||||
|
||||
function saveStyle(style) {
|
||||
const id = Number(style.id) || null;
|
||||
const reason = style.reason;
|
||||
const notify = style.notify !== false;
|
||||
delete style.method;
|
||||
delete style.reason;
|
||||
delete style.notify;
|
||||
if (!style.name) {
|
||||
delete style.name;
|
||||
}
|
||||
let existed;
|
||||
let codeIsUpdated;
|
||||
|
||||
return maybeCalcDigest()
|
||||
.then(maybeImportFix)
|
||||
.then(decide);
|
||||
|
||||
function maybeCalcDigest() {
|
||||
if (reason === 'update' || reason === 'update-digest') {
|
||||
return calcStyleDigest(style).then(digest => {
|
||||
style.originalDigest = digest;
|
||||
});
|
||||
}
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
function maybeImportFix() {
|
||||
if (reason === 'import') {
|
||||
style.originalDigest = style.originalDigest || style.styleDigest; // TODO: remove in the future
|
||||
delete style.styleDigest; // TODO: remove in the future
|
||||
if (typeof style.originalDigest !== 'string' || style.originalDigest.length !== 40) {
|
||||
delete style.originalDigest;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function decide() {
|
||||
if (id !== null) {
|
||||
// Update or create
|
||||
style.id = id;
|
||||
return dbExec('get', id).then((event, store) => {
|
||||
const oldStyle = event.target.result;
|
||||
existed = Boolean(oldStyle);
|
||||
if (reason === 'update-digest' && oldStyle.originalDigest === style.originalDigest) {
|
||||
return style;
|
||||
}
|
||||
codeIsUpdated = !existed || 'sections' in style && !styleSectionsEqual(style, oldStyle);
|
||||
style = Object.assign({}, oldStyle, style);
|
||||
return write(style, store);
|
||||
});
|
||||
} else {
|
||||
// Create
|
||||
delete style.id;
|
||||
style = Object.assign({
|
||||
// Set optional things if they're undefined
|
||||
enabled: true,
|
||||
updateUrl: null,
|
||||
md5Url: null,
|
||||
url: null,
|
||||
originalMd5: null,
|
||||
}, style);
|
||||
return write(style);
|
||||
}
|
||||
}
|
||||
|
||||
function write(style, store) {
|
||||
style.sections = normalizeStyleSections(style);
|
||||
if (store) {
|
||||
return new Promise(resolve => {
|
||||
store.put(style).onsuccess = event => resolve(done(event));
|
||||
});
|
||||
} else {
|
||||
return dbExec('put', style).then(done);
|
||||
}
|
||||
}
|
||||
|
||||
function done(event) {
|
||||
if (reason === 'update-digest') {
|
||||
return style;
|
||||
}
|
||||
style.id = style.id || event.target.result;
|
||||
invalidateCache(existed ? {updated: style} : {added: style});
|
||||
if (notify) {
|
||||
notifyAllTabs({
|
||||
method: existed ? 'styleUpdated' : 'styleAdded',
|
||||
style, codeIsUpdated, reason,
|
||||
});
|
||||
}
|
||||
return style;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function deleteStyle({id, notify = true}) {
|
||||
id = Number(id);
|
||||
return dbExec('delete', id).then(() => {
|
||||
invalidateCache({deletedId: id});
|
||||
if (notify) {
|
||||
notifyAllTabs({method: 'styleDeleted', id});
|
||||
}
|
||||
return id;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function getApplicableSections({
|
||||
style,
|
||||
matchUrl,
|
||||
strictRegexp = true,
|
||||
// filterStylesInternal() sets the following to avoid recalc on each style:
|
||||
stopOnFirst,
|
||||
skipUrlCheck,
|
||||
matchUrlBase = matchUrl.includes('#') && matchUrl.split('#', 1)[0],
|
||||
// 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 the spec is outdated and doesn't account for SPA sites
|
||||
// so we only respect it in case of url("http://exact.url/without/hash")
|
||||
}) {
|
||||
if (!skipUrlCheck && !URLS.supported(matchUrl)) {
|
||||
return [];
|
||||
}
|
||||
const sections = [];
|
||||
for (const section of style.sections) {
|
||||
const {urls, domains, urlPrefixes, regexps, code} = section;
|
||||
const isGlobal = !urls.length && !urlPrefixes.length && !domains.length && !regexps.length;
|
||||
const isMatching = !isGlobal && (
|
||||
urls.length
|
||||
&& (urls.includes(matchUrl) || matchUrlBase && urls.includes(matchUrlBase))
|
||||
|| urlPrefixes.length
|
||||
&& arraySomeIsPrefix(urlPrefixes, matchUrl)
|
||||
|| domains.length
|
||||
&& arraySomeIn(cachedStyles.urlDomains.get(matchUrl) || getDomains(matchUrl), domains)
|
||||
|| regexps.length
|
||||
&& arraySomeMatches(regexps, matchUrl, strictRegexp));
|
||||
if (isGlobal && !styleCodeEmpty(code) || isMatching) {
|
||||
sections.push(section);
|
||||
if (stopOnFirst) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return sections;
|
||||
|
||||
function arraySomeIsPrefix(array, string) {
|
||||
for (const prefix of array) {
|
||||
if (string.startsWith(prefix)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function arraySomeIn(array, haystack) {
|
||||
for (const el of array) {
|
||||
if (haystack.indexOf(el) >= 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function arraySomeMatches(array, matchUrl, strictRegexp) {
|
||||
for (const regexp of array) {
|
||||
for (let pass = 1; pass <= (strictRegexp ? 1 : 2); pass++) {
|
||||
const cacheKey = pass === 1 ? regexp : SLOPPY_REGEXP_PREFIX + regexp;
|
||||
let rx = cachedStyles.regexps.get(cacheKey);
|
||||
if (rx === false) {
|
||||
// invalid regexp
|
||||
break;
|
||||
}
|
||||
if (!rx) {
|
||||
const anchored = pass === 1 ? '^(?:' + regexp + ')$' : '^' + regexp + '$';
|
||||
rx = tryRegExp(anchored);
|
||||
cachedStyles.regexps.set(cacheKey, rx || false);
|
||||
if (!rx) {
|
||||
// invalid regexp
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (rx.test(matchUrl)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function styleCodeEmpty(code) {
|
||||
// Collect the global section if it's not empty, not comment-only, not namespace-only.
|
||||
const cmtOpen = code && code.indexOf('/*');
|
||||
if (cmtOpen >= 0) {
|
||||
const cmtCloseLast = code.lastIndexOf('*/');
|
||||
if (cmtCloseLast < 0) {
|
||||
code = code.substr(0, cmtOpen);
|
||||
} else {
|
||||
code = code.substr(0, cmtOpen) +
|
||||
code.substring(cmtOpen, cmtCloseLast + 2).replace(RX_CSS_COMMENTS, '') +
|
||||
code.substr(cmtCloseLast + 2);
|
||||
}
|
||||
}
|
||||
return !code
|
||||
|| !code.trim()
|
||||
|| code.includes('@namespace') && !code.replace(RX_NAMESPACE, '').trim();
|
||||
}
|
||||
|
||||
|
||||
function styleSectionsEqual({sections: a}, {sections: b}) {
|
||||
if (!a || !b) {
|
||||
return undefined;
|
||||
}
|
||||
if (a.length !== b.length) {
|
||||
return false;
|
||||
}
|
||||
// order of sections should be identical to account for the case of multiple
|
||||
// sections matching the same URL because the order of rules is part of cascading
|
||||
return a.every((sectionA, index) => propertiesEqual(sectionA, b[index]));
|
||||
|
||||
function propertiesEqual(secA, secB) {
|
||||
for (const name of ['urlPrefixes', 'urls', 'domains', 'regexps']) {
|
||||
if (!equalOrEmpty(secA[name], secB[name], 'every', arrayMirrors)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return equalOrEmpty(secA.code, secB.code, 'substr', (a, b) => a === b);
|
||||
}
|
||||
|
||||
function equalOrEmpty(a, b, telltale, comparator) {
|
||||
const typeA = a && typeof a[telltale] === 'function';
|
||||
const typeB = b && typeof b[telltale] === 'function';
|
||||
return (
|
||||
(a === null || a === undefined || (typeA && !a.length)) &&
|
||||
(b === null || b === undefined || (typeB && !b.length))
|
||||
) || typeA && typeB && a.length === b.length && comparator(a, b);
|
||||
}
|
||||
|
||||
function arrayMirrors(array1, array2) {
|
||||
return (
|
||||
array1.every(el => array2.includes(el)) &&
|
||||
array2.every(el => array1.includes(el))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function invalidateCache({added, updated, deletedId} = {}) {
|
||||
if (!cachedStyles.list) {
|
||||
return;
|
||||
}
|
||||
const id = added ? added.id : updated ? updated.id : deletedId;
|
||||
const cached = cachedStyles.byId.get(id);
|
||||
if (updated) {
|
||||
if (cached) {
|
||||
Object.assign(cached, updated);
|
||||
cachedStyles.filters.clear();
|
||||
cachedStyles.needTransitionPatch.delete(id);
|
||||
return;
|
||||
} else {
|
||||
added = updated;
|
||||
}
|
||||
}
|
||||
if (added) {
|
||||
if (!cached) {
|
||||
cachedStyles.list.push(added);
|
||||
cachedStyles.byId.set(added.id, added);
|
||||
cachedStyles.filters.clear();
|
||||
cachedStyles.needTransitionPatch.delete(id);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (deletedId !== undefined) {
|
||||
if (cached) {
|
||||
const cachedIndex = cachedStyles.list.indexOf(cached);
|
||||
cachedStyles.list.splice(cachedIndex, 1);
|
||||
cachedStyles.byId.delete(deletedId);
|
||||
cachedStyles.filters.clear();
|
||||
cachedStyles.needTransitionPatch.delete(id);
|
||||
return;
|
||||
}
|
||||
}
|
||||
cachedStyles.list = null;
|
||||
cachedStyles.filters.clear();
|
||||
cachedStyles.needTransitionPatch.clear(id);
|
||||
}
|
||||
|
||||
|
||||
function cleanupCachedFilters({force = false} = {}) {
|
||||
if (!force) {
|
||||
debounce(cleanupCachedFilters, 1000, {force: true});
|
||||
return;
|
||||
}
|
||||
const size = cachedStyles.filters.size;
|
||||
const oldestHit = cachedStyles.filters.values().next().value.lastHit;
|
||||
const now = Date.now();
|
||||
const timeSpan = now - oldestHit;
|
||||
const recencyWeight = 5 / size;
|
||||
const hitWeight = 1 / 4; // we make ~4 hits per URL
|
||||
const lastHitWeight = 10;
|
||||
// delete the oldest 10%
|
||||
[...cachedStyles.filters.entries()]
|
||||
.map(([id, v], index) => ({
|
||||
id,
|
||||
weight:
|
||||
index * recencyWeight +
|
||||
v.hits * hitWeight +
|
||||
(v.lastHit - oldestHit) / timeSpan * lastHitWeight,
|
||||
}))
|
||||
.sort((a, b) => a.weight - b.weight)
|
||||
.slice(0, size / 10 + 1)
|
||||
.forEach(({id}) => cachedStyles.filters.delete(id));
|
||||
}
|
||||
|
||||
|
||||
function getDomains(url) {
|
||||
let d = /.*?:\/*([^/:]+)|$/.exec(url)[1];
|
||||
if (!d || url.startsWith('file:')) {
|
||||
return [];
|
||||
}
|
||||
const domains = [d];
|
||||
while (d.indexOf('.') !== -1) {
|
||||
d = d.substring(d.indexOf('.') + 1);
|
||||
domains.push(d);
|
||||
}
|
||||
return domains;
|
||||
}
|
||||
|
||||
|
||||
function normalizeStyleSections({sections}) {
|
||||
// retain known properties in an arbitrarily predefined order
|
||||
return (sections || []).map(section => ({
|
||||
code: section.code || '',
|
||||
urls: section.urls || [],
|
||||
urlPrefixes: section.urlPrefixes || [],
|
||||
domains: section.domains || [],
|
||||
regexps: section.regexps || [],
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
function calcStyleDigest(style) {
|
||||
const jsonString = style.usercssData ?
|
||||
style.sourceCode : JSON.stringify(normalizeStyleSections(style));
|
||||
const text = new TextEncoder('utf-8').encode(jsonString);
|
||||
return crypto.subtle.digest('SHA-1', text).then(hex);
|
||||
|
||||
function hex(buffer) {
|
||||
const parts = [];
|
||||
const PAD8 = '00000000';
|
||||
const view = new DataView(buffer);
|
||||
for (let i = 0; i < view.byteLength; i += 4) {
|
||||
parts.push((PAD8 + view.getUint32(i).toString(16)).slice(-8));
|
||||
}
|
||||
return parts.join('');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function handleCssTransitionBug({tabId, frameId, url, styles}) {
|
||||
for (let id in styles) {
|
||||
id |= 0;
|
||||
if (!id) {
|
||||
continue;
|
||||
}
|
||||
let need = cachedStyles.needTransitionPatch.get(id);
|
||||
if (need === false) {
|
||||
continue;
|
||||
}
|
||||
if (need !== true) {
|
||||
need = styles[id].some(sectionContainsTransitions);
|
||||
cachedStyles.needTransitionPatch.set(id, need);
|
||||
if (!need) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (FIREFOX && !url.startsWith(URLS.ownOrigin)) {
|
||||
patchFirefox();
|
||||
} else {
|
||||
styles.needTransitionPatch = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
function patchFirefox() {
|
||||
const options = {
|
||||
frameId,
|
||||
code: CSS_TRANSITION_SUPPRESSOR,
|
||||
matchAboutBlank: true,
|
||||
};
|
||||
if (FIREFOX >= 53) {
|
||||
options.cssOrigin = 'user';
|
||||
}
|
||||
browser.tabs.insertCSS(tabId, Object.assign(options, {
|
||||
runAt: 'document_start',
|
||||
})).then(() => setTimeout(() => {
|
||||
browser.tabs.removeCSS(tabId, options).catch(ignoreChromeError);
|
||||
})).catch(ignoreChromeError);
|
||||
}
|
||||
|
||||
function sectionContainsTransitions(section) {
|
||||
let code = section.code;
|
||||
const firstTransition = code.indexOf('transition');
|
||||
if (firstTransition < 0) {
|
||||
return false;
|
||||
}
|
||||
const firstCmt = code.indexOf('/*');
|
||||
// check the part before the first comment
|
||||
if (firstCmt < 0 || firstTransition < firstCmt) {
|
||||
if (quickCheckAround(code, firstTransition)) {
|
||||
return true;
|
||||
} else if (firstCmt < 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// check the rest
|
||||
const lastCmt = code.lastIndexOf('*/');
|
||||
if (lastCmt < firstCmt) {
|
||||
// the comment is unclosed and we already checked the preceding part
|
||||
return false;
|
||||
}
|
||||
let mid = code.slice(firstCmt, lastCmt + 2);
|
||||
mid = mid.indexOf('*/') === mid.length - 2 ? '' : mid.replace(RX_CSS_COMMENTS, '');
|
||||
code = mid + code.slice(lastCmt + 2);
|
||||
return quickCheckAround(code) || RX_CSS_TRANSITION_DETECTOR.test(code);
|
||||
}
|
||||
|
||||
function quickCheckAround(code, pos = code.indexOf('transition')) {
|
||||
return RX_CSS_TRANSITION_DETECTOR.test(code.substr(Math.max(0, pos - 10), 50));
|
||||
}
|
||||
}
|
791
background/style-manager.js
Normal file
791
background/style-manager.js
Normal file
|
@ -0,0 +1,791 @@
|
|||
/* global API msg */// msg.js
|
||||
/* global CHROME URLS deepEqual isEmptyObj mapObj stringAsRegExp tryRegExp tryURL */// toolbox.js
|
||||
/* global bgReady createCache uuidIndex */// common.js
|
||||
/* global calcStyleDigest styleCodeEmpty */// sections-util.js
|
||||
/* global db */
|
||||
/* global prefs */
|
||||
/* global tabMan */
|
||||
/* global usercssMan */
|
||||
/* global colorScheme */
|
||||
'use strict';
|
||||
|
||||
/*
|
||||
This style manager is a layer between content script and the DB. When a style
|
||||
is added/updated, it broadcast a message to content script and the content
|
||||
script would try to fetch the new code.
|
||||
|
||||
The live preview feature relies on `runtime.connect` and `port.onDisconnect`
|
||||
to cleanup the temporary code. See livePreview in /edit.
|
||||
*/
|
||||
|
||||
const styleUtil = {};
|
||||
|
||||
/* exported styleMan */
|
||||
const styleMan = (() => {
|
||||
|
||||
Object.assign(styleUtil, {
|
||||
id2style,
|
||||
handleSave,
|
||||
uuid2style,
|
||||
});
|
||||
|
||||
//#region Declarations
|
||||
|
||||
/** @typedef {{
|
||||
style: StyleObj,
|
||||
preview?: StyleObj,
|
||||
appliesTo: Set<string>,
|
||||
}} StyleMapData */
|
||||
/** @type {Map<number,StyleMapData>} */
|
||||
const dataMap = new Map();
|
||||
/** @typedef {Object<styleId,{id: number, code: string[]}>} StyleSectionsToApply */
|
||||
/** @type {Map<string,{maybeMatch: Set<styleId>, sections: StyleSectionsToApply}>} */
|
||||
const cachedStyleForUrl = createCache({
|
||||
onDeleted(url, cache) {
|
||||
for (const section of Object.values(cache.sections)) {
|
||||
const data = id2data(section.id);
|
||||
if (data) data.appliesTo.delete(url);
|
||||
}
|
||||
},
|
||||
});
|
||||
const BAD_MATCHER = {test: () => false};
|
||||
const compileRe = createCompiler(text => `^(${text})$`);
|
||||
const compileSloppyRe = createCompiler(text => `^${text}$`);
|
||||
const compileExclusion = createCompiler(buildExclusion);
|
||||
const uuidv4 = crypto.randomUUID ? crypto.randomUUID.bind(crypto) : (() => {
|
||||
const seeds = crypto.getRandomValues(new Uint16Array(8));
|
||||
// 00001111-2222-M333-N444-555566667777
|
||||
seeds[3] = seeds[3] & 0x0FFF | 0x4000; // UUID version 4, M = 4
|
||||
seeds[4] = seeds[4] & 0x3FFF | 0x8000; // UUID variant 1, N = 8..0xB
|
||||
return Array.from(seeds, hex4dashed).join('');
|
||||
});
|
||||
const MISSING_PROPS = {
|
||||
name: style => `ID: ${style.id}`,
|
||||
_id: () => uuidv4(),
|
||||
_rev: () => Date.now(),
|
||||
};
|
||||
const DELETE_IF_NULL = ['id', 'customName', 'md5Url', 'originalMd5'];
|
||||
const INJ_ORDER = 'injectionOrder';
|
||||
const order = {main: {}, prio: {}};
|
||||
const orderWrap = {
|
||||
id: INJ_ORDER,
|
||||
value: mapObj(order, () => []),
|
||||
_id: `${chrome.runtime.id}-${INJ_ORDER}`,
|
||||
_rev: 0,
|
||||
};
|
||||
uuidIndex.addCustomId(orderWrap, {set: setOrder});
|
||||
|
||||
class MatchQuery {
|
||||
constructor(url) {
|
||||
this.url = url;
|
||||
}
|
||||
get urlWithoutHash() {
|
||||
return this._set('urlWithoutHash', this.url.split('#', 1)[0]);
|
||||
}
|
||||
get urlWithoutParams() {
|
||||
return this._set('urlWithoutParams', this.url.split(/[?#]/, 1)[0]);
|
||||
}
|
||||
get domain() {
|
||||
return this._set('domain', tryURL(this.url).hostname);
|
||||
}
|
||||
get isOwnPage() {
|
||||
return this._set('isOwnPage', this.url.startsWith(URLS.ownOrigin));
|
||||
}
|
||||
_set(name, value) {
|
||||
Object.defineProperty(this, name, {value});
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
/** @type {Promise|boolean} will be `true` to avoid wasting a microtask tick on each `await` */
|
||||
let ready = Promise.all([init(), prefs.ready]);
|
||||
|
||||
chrome.runtime.onConnect.addListener(port => {
|
||||
if (port.name === 'livePreview') {
|
||||
handleLivePreview(port);
|
||||
} else if (port.name.startsWith('draft:')) {
|
||||
handleDraft(port);
|
||||
}
|
||||
});
|
||||
colorScheme.onChange(value => {
|
||||
msg.broadcastExtension({method: 'colorScheme', value});
|
||||
for (const {style} of dataMap.values()) {
|
||||
if (colorScheme.SCHEMES.includes(style.preferScheme)) {
|
||||
broadcastStyleUpdated(style, 'colorScheme');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
//#endregion
|
||||
//#region Exports
|
||||
|
||||
return {
|
||||
|
||||
/** @returns {Promise<number>} style id */
|
||||
async delete(id, reason) {
|
||||
if (ready.then) await ready;
|
||||
const {style, appliesTo} = dataMap.get(id);
|
||||
const sync = reason !== 'sync';
|
||||
const uuid = style._id;
|
||||
db.styles.delete(id);
|
||||
if (sync) API.sync.delete(uuid, Date.now());
|
||||
for (const url of appliesTo) {
|
||||
const cache = cachedStyleForUrl.get(url);
|
||||
if (cache) delete cache.sections[id];
|
||||
}
|
||||
dataMap.delete(id);
|
||||
uuidIndex.delete(uuid);
|
||||
mapObj(orderWrap.value, (group, type) => {
|
||||
delete order[type][id];
|
||||
const i = group.indexOf(uuid);
|
||||
if (i >= 0) group.splice(i, 1);
|
||||
});
|
||||
setOrder(orderWrap, {calc: false});
|
||||
if (style._usw && style._usw.token) {
|
||||
// Must be called after the style is deleted from dataMap
|
||||
API.usw.revoke(id);
|
||||
}
|
||||
API.drafts.delete(id);
|
||||
await msg.broadcast({
|
||||
method: 'styleDeleted',
|
||||
style: {id},
|
||||
});
|
||||
return id;
|
||||
},
|
||||
|
||||
/** @returns {Promise<StyleObj>} */
|
||||
async editSave(style) {
|
||||
if (ready.then) await ready;
|
||||
style = mergeWithMapped(style);
|
||||
style.updateDate = Date.now();
|
||||
return saveStyle(style, {reason: 'editSave'});
|
||||
},
|
||||
|
||||
/** @returns {Promise<?StyleObj>} */
|
||||
async find(...filters) {
|
||||
if (ready.then) await ready;
|
||||
for (const filter of filters) {
|
||||
const filterEntries = Object.entries(filter);
|
||||
for (const {style} of dataMap.values()) {
|
||||
if (filterEntries.every(([key, val]) => style[key] === val)) {
|
||||
return style;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
},
|
||||
|
||||
/** @returns {Promise<StyleObj[]>} */
|
||||
async getAll() {
|
||||
if (ready.then) await ready;
|
||||
return getAllAsArray();
|
||||
},
|
||||
|
||||
/** @returns {Promise<Object<string,StyleObj[]>>}>} */
|
||||
async getAllOrdered(keys) {
|
||||
if (ready.then) await ready;
|
||||
const res = mapObj(orderWrap.value, group => group.map(uuid2style).filter(Boolean));
|
||||
if (res.main.length + res.prio.length < dataMap.size) {
|
||||
for (const {style} of dataMap.values()) {
|
||||
if (!(style.id in order.main) && !(style.id in order.prio)) {
|
||||
res.main.push(style);
|
||||
}
|
||||
}
|
||||
}
|
||||
return keys
|
||||
? mapObj(res, group => group.map(style => mapObj(style, null, keys)))
|
||||
: res;
|
||||
},
|
||||
|
||||
getOrder: () => orderWrap.value,
|
||||
|
||||
/** @returns {Promise<string | {[remoteId:string]: styleId}>}>} */
|
||||
async getRemoteInfo(id) {
|
||||
if (ready.then) await ready;
|
||||
if (id) return calcRemoteId(id2style(id));
|
||||
const res = {};
|
||||
for (const {style} of dataMap.values()) {
|
||||
const [rid, vars] = calcRemoteId(style);
|
||||
if (rid) res[rid] = [style.id, vars];
|
||||
}
|
||||
return res;
|
||||
},
|
||||
|
||||
/** @returns {Promise<StyleSectionsToApply>} */
|
||||
async getSectionsByUrl(url, id, isInitialApply) {
|
||||
if (ready.then) await ready;
|
||||
if (isInitialApply && prefs.get('disableAll')) {
|
||||
return {
|
||||
cfg: {
|
||||
disableAll: true,
|
||||
},
|
||||
};
|
||||
}
|
||||
// TODO: enable in FF when it supports sourceURL comment in style elements (also options.html)
|
||||
const {exposeStyleName} = CHROME && prefs.__values;
|
||||
const sender = CHROME && this && this.sender || {};
|
||||
if (sender.frameId === 0) {
|
||||
/* Chrome hides text frament from location.href of the page e.g. #:~:text=foo
|
||||
so we'll use the real URL reported by webNavigation API.
|
||||
TODO: if FF will do the same, this won't work as is: FF reports onCommitted too late */
|
||||
url = tabMan.get(sender.tab.id, 'url', 0) || url;
|
||||
}
|
||||
let cache = cachedStyleForUrl.get(url);
|
||||
if (!cache) {
|
||||
cache = {
|
||||
sections: {},
|
||||
maybeMatch: new Set(),
|
||||
};
|
||||
buildCache(cache, url, dataMap.values());
|
||||
cachedStyleForUrl.set(url, cache);
|
||||
} else if (cache.maybeMatch.size) {
|
||||
buildCache(cache, url, Array.from(cache.maybeMatch, id2data).filter(Boolean));
|
||||
}
|
||||
return Object.assign({cfg: {exposeStyleName, order}},
|
||||
id ? mapObj(cache.sections, null, [id])
|
||||
: cache.sections);
|
||||
},
|
||||
|
||||
/** @returns {Promise<StyleObj>} */
|
||||
async get(id) {
|
||||
if (ready.then) await ready;
|
||||
return id2style(id);
|
||||
},
|
||||
|
||||
/** @returns {Promise<StylesByUrlResult[]>} */
|
||||
async getByUrl(url, id = null) {
|
||||
if (ready.then) await ready;
|
||||
// FIXME: do we want to cache this? Who would like to open popup rapidly
|
||||
// or search the DB with the same URL?
|
||||
const result = [];
|
||||
const styles = id
|
||||
? [id2style(id)].filter(Boolean)
|
||||
: getAllAsArray();
|
||||
const query = new MatchQuery(url);
|
||||
for (const style of styles) {
|
||||
let excluded = false;
|
||||
let excludedScheme = false;
|
||||
let included = false;
|
||||
let sloppy = false;
|
||||
let sectionMatched = false;
|
||||
const match = urlMatchStyle(query, style);
|
||||
// TODO: enable this when the function starts returning false
|
||||
// if (match === false) {
|
||||
// continue;
|
||||
// }
|
||||
if (match === 'included') {
|
||||
included = true;
|
||||
}
|
||||
if (match === 'excluded') {
|
||||
excluded = true;
|
||||
}
|
||||
if (match === 'excludedScheme') {
|
||||
excludedScheme = true;
|
||||
}
|
||||
for (const section of style.sections) {
|
||||
const match = urlMatchSection(query, section, true);
|
||||
if (match) {
|
||||
if (match === 'sloppy') {
|
||||
sloppy = true;
|
||||
}
|
||||
sectionMatched = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (sectionMatched || included) {
|
||||
result.push(/** @namespace StylesByUrlResult */ {
|
||||
style, excluded, sloppy, excludedScheme, sectionMatched, included});
|
||||
}
|
||||
}
|
||||
return result;
|
||||
},
|
||||
|
||||
/** @returns {Promise<StyleObj[]>} */
|
||||
async importMany(items) {
|
||||
if (ready.then) await ready;
|
||||
for (const style of items) {
|
||||
beforeSave(style);
|
||||
if (style.sourceCode && style.usercssData) {
|
||||
await usercssMan.buildCode(style);
|
||||
}
|
||||
}
|
||||
const events = await db.styles.putMany(items);
|
||||
return Promise.all(items.map((item, i) =>
|
||||
handleSave(item, {reason: 'import'}, events[i])
|
||||
));
|
||||
},
|
||||
|
||||
/** @returns {Promise<StyleObj>} */
|
||||
async install(style, reason = null) {
|
||||
if (ready.then) await ready;
|
||||
reason = reason || dataMap.has(style.id) ? 'update' : 'install';
|
||||
style = mergeWithMapped(style);
|
||||
style.originalDigest = await calcStyleDigest(style);
|
||||
// FIXME: update updateDate? what about usercss config?
|
||||
return saveStyle(style, {reason});
|
||||
},
|
||||
|
||||
save: saveStyle,
|
||||
|
||||
async setOrder(value) {
|
||||
if (ready.then) await ready;
|
||||
return setOrder({value}, {broadcast: true, sync: true});
|
||||
},
|
||||
|
||||
/** @returns {Promise<number>} style id */
|
||||
async toggle(id, enabled) {
|
||||
if (ready.then) await ready;
|
||||
const style = Object.assign({}, id2style(id), {enabled});
|
||||
await saveStyle(style, {reason: 'toggle'});
|
||||
return id;
|
||||
},
|
||||
|
||||
// using bind() to skip step-into when debugging
|
||||
|
||||
/** @returns {Promise<StyleObj>} */
|
||||
addExclusion: addIncludeExclude.bind(null, 'exclusions'),
|
||||
/** @returns {Promise<StyleObj>} */
|
||||
addInclusion: addIncludeExclude.bind(null, 'inclusions'),
|
||||
/** @returns {Promise<?StyleObj>} */
|
||||
removeExclusion: removeIncludeExclude.bind(null, 'exclusions'),
|
||||
/** @returns {Promise<?StyleObj>} */
|
||||
removeInclusion: removeIncludeExclude.bind(null, 'inclusions'),
|
||||
|
||||
async config(id, prop, value) {
|
||||
if (ready.then) await ready;
|
||||
const style = Object.assign({}, id2style(id));
|
||||
const {preview = {}} = dataMap.get(id);
|
||||
style[prop] = preview[prop] = value;
|
||||
return saveStyle(style, {reason: 'config'});
|
||||
},
|
||||
};
|
||||
|
||||
//#endregion
|
||||
//#region Implementation
|
||||
|
||||
/** @returns {StyleMapData} */
|
||||
function id2data(id) {
|
||||
return dataMap.get(id);
|
||||
}
|
||||
|
||||
/** @returns {?StyleObj} */
|
||||
function id2style(id) {
|
||||
return (dataMap.get(Number(id)) || {}).style;
|
||||
}
|
||||
|
||||
/** @returns {?StyleObj} */
|
||||
function uuid2style(uuid) {
|
||||
return id2style(uuidIndex.get(uuid));
|
||||
}
|
||||
|
||||
function calcRemoteId({md5Url, updateUrl, usercssData: ucd} = {}) {
|
||||
let id;
|
||||
id = (id = /\d+/.test(md5Url) || URLS.extractUsoArchiveId(updateUrl)) && `uso-${id}`
|
||||
|| (id = URLS.extractUSwId(updateUrl)) && `usw-${id}`
|
||||
|| '';
|
||||
return id && [
|
||||
id,
|
||||
ucd && !isEmptyObj(ucd.vars),
|
||||
];
|
||||
}
|
||||
|
||||
/** @returns {StyleObj} */
|
||||
function createNewStyle() {
|
||||
return /** @namespace StyleObj */ {
|
||||
enabled: true,
|
||||
updateUrl: null,
|
||||
md5Url: null,
|
||||
url: null,
|
||||
originalMd5: null,
|
||||
installDate: Date.now(),
|
||||
};
|
||||
}
|
||||
|
||||
/** @returns {void} */
|
||||
function storeInMap(style) {
|
||||
dataMap.set(style.id, {
|
||||
style,
|
||||
appliesTo: new Set(),
|
||||
});
|
||||
uuidIndex.set(style._id, style.id);
|
||||
}
|
||||
|
||||
/** @returns {StyleObj} */
|
||||
function mergeWithMapped(style) {
|
||||
return Object.assign({},
|
||||
id2style(style.id) || createNewStyle(),
|
||||
style);
|
||||
}
|
||||
|
||||
function handleDraft(port) {
|
||||
const id = port.name.split(':').pop();
|
||||
port.onDisconnect.addListener(() => API.drafts.delete(Number(id) || id));
|
||||
}
|
||||
|
||||
function handleLivePreview(port) {
|
||||
let id;
|
||||
port.onMessage.addListener(style => {
|
||||
if (!id) id = style.id;
|
||||
const data = id2data(id);
|
||||
data.preview = style;
|
||||
broadcastStyleUpdated(style, 'editPreview');
|
||||
});
|
||||
port.onDisconnect.addListener(() => {
|
||||
port = null;
|
||||
if (id) {
|
||||
const data = id2data(id);
|
||||
if (data) {
|
||||
data.preview = null;
|
||||
broadcastStyleUpdated(data.style, 'editPreviewEnd');
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async function addIncludeExclude(type, id, rule) {
|
||||
if (ready.then) await ready;
|
||||
const style = Object.assign({}, id2style(id));
|
||||
const list = style[type] || (style[type] = []);
|
||||
if (list.includes(rule)) {
|
||||
throw new Error('The rule already exists');
|
||||
}
|
||||
style[type] = list.concat([rule]);
|
||||
return saveStyle(style, {reason: 'config'});
|
||||
}
|
||||
|
||||
async function removeIncludeExclude(type, id, rule) {
|
||||
if (ready.then) await ready;
|
||||
const style = Object.assign({}, id2style(id));
|
||||
const list = style[type];
|
||||
if (!list || !list.includes(rule)) {
|
||||
return;
|
||||
}
|
||||
style[type] = list.filter(r => r !== rule);
|
||||
return saveStyle(style, {reason: 'config'});
|
||||
}
|
||||
|
||||
function broadcastStyleUpdated(style, reason, method = 'styleUpdated') {
|
||||
const {id} = style;
|
||||
const data = id2data(id);
|
||||
const excluded = new Set();
|
||||
const updated = new Set();
|
||||
for (const [url, cache] of cachedStyleForUrl.entries()) {
|
||||
if (!data.appliesTo.has(url)) {
|
||||
cache.maybeMatch.add(id);
|
||||
continue;
|
||||
}
|
||||
const code = getAppliedCode(new MatchQuery(url), style);
|
||||
if (code) {
|
||||
updated.add(url);
|
||||
buildCacheEntry(cache, style, code);
|
||||
} else {
|
||||
excluded.add(url);
|
||||
delete cache.sections[id];
|
||||
}
|
||||
}
|
||||
data.appliesTo = updated;
|
||||
return msg.broadcast({
|
||||
method,
|
||||
reason,
|
||||
style: {
|
||||
id,
|
||||
md5Url: style.md5Url,
|
||||
enabled: style.enabled,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
function beforeSave(style) {
|
||||
if (!style.name) {
|
||||
throw new Error('Style name is empty');
|
||||
}
|
||||
for (const key of DELETE_IF_NULL) {
|
||||
if (style[key] == null) {
|
||||
delete style[key];
|
||||
}
|
||||
}
|
||||
if (!style._id) {
|
||||
style._id = uuidv4();
|
||||
}
|
||||
style._rev = Date.now();
|
||||
fixKnownProblems(style);
|
||||
}
|
||||
|
||||
async function saveStyle(style, handlingOptions) {
|
||||
beforeSave(style);
|
||||
const newId = await db.styles.put(style);
|
||||
return handleSave(style, handlingOptions, newId);
|
||||
}
|
||||
|
||||
function handleSave(style, {reason, broadcast = true}, id = style.id) {
|
||||
if (style.id == null) style.id = id;
|
||||
const data = id2data(id);
|
||||
const method = data ? 'styleUpdated' : 'styleAdded';
|
||||
if (!data) {
|
||||
storeInMap(style);
|
||||
} else {
|
||||
data.style = style;
|
||||
}
|
||||
if (reason !== 'sync') {
|
||||
API.sync.putDoc(style);
|
||||
}
|
||||
if (broadcast) broadcastStyleUpdated(style, reason, method);
|
||||
return style;
|
||||
}
|
||||
|
||||
// get styles matching a URL, including sloppy regexps and excluded items.
|
||||
function getAppliedCode(query, data) {
|
||||
const result = urlMatchStyle(query, data);
|
||||
if (result === 'included') {
|
||||
// return all sections
|
||||
return data.sections.map(s => s.code);
|
||||
}
|
||||
if (result !== true) {
|
||||
return;
|
||||
}
|
||||
const code = [];
|
||||
for (const section of data.sections) {
|
||||
if (urlMatchSection(query, section) === true && !styleCodeEmpty(section.code)) {
|
||||
code.push(section.code);
|
||||
}
|
||||
}
|
||||
return code.length && code;
|
||||
}
|
||||
|
||||
async function init() {
|
||||
const orderPromise = API.prefsDb.get(orderWrap.id);
|
||||
const styles = await db.styles.getAll() || [];
|
||||
const updated = await Promise.all(styles.map(fixKnownProblems).filter(Boolean));
|
||||
if (updated.length) {
|
||||
await db.styles.putMany(updated);
|
||||
}
|
||||
setOrder(await orderPromise, {store: false});
|
||||
styles.forEach(storeInMap);
|
||||
ready = true;
|
||||
bgReady._resolveStyles();
|
||||
}
|
||||
|
||||
function fixKnownProblems(style, initIndex, initArray) {
|
||||
let res = 0;
|
||||
for (const key in MISSING_PROPS) {
|
||||
if (!style[key]) {
|
||||
style[key] = MISSING_PROPS[key](style);
|
||||
res = 1;
|
||||
}
|
||||
}
|
||||
/* Upgrade the old way of customizing local names */
|
||||
const {originalName} = style;
|
||||
if (originalName) {
|
||||
if (originalName !== style.name) {
|
||||
style.customName = style.name;
|
||||
style.name = originalName;
|
||||
}
|
||||
delete style.originalName;
|
||||
res = 1;
|
||||
}
|
||||
/* wrong homepage url in 1.5.20-1.5.21 due to commit 1e5f118d */
|
||||
for (const key of ['url', 'installationUrl']) {
|
||||
const url = style[key];
|
||||
const fixedUrl = url && url.replace(/([^:]\/)\//, '$1');
|
||||
if (fixedUrl !== url) {
|
||||
res = 1;
|
||||
style[key] = fixedUrl;
|
||||
}
|
||||
}
|
||||
let url;
|
||||
/* USO bug, duplicate "update" subdomain, see #523 */
|
||||
if ((url = style.md5Url) && url.includes('update.update.userstyles')) {
|
||||
res = style.md5Url = url.replace('update.update.userstyles', 'update.userstyles');
|
||||
}
|
||||
/* Default homepage URL for external styles installed from a known distro */
|
||||
if (
|
||||
(!style.url || !style.installationUrl) &&
|
||||
(url = style.updateUrl) &&
|
||||
(url = URLS.extractGreasyForkInstallUrl(url) ||
|
||||
URLS.extractUsoArchiveInstallUrl(url) ||
|
||||
URLS.extractUSwInstallUrl(url)
|
||||
)
|
||||
) {
|
||||
if (!style.url) res = style.url = url;
|
||||
if (!style.installationUrl) res = style.installationUrl = url;
|
||||
}
|
||||
/* @import must precede `vars` that we add at beginning */
|
||||
if (
|
||||
initArray &&
|
||||
!isEmptyObj((style.usercssData || {}).vars) &&
|
||||
style.sections.some(({code}) =>
|
||||
code.startsWith(':root {\n --') &&
|
||||
/@import\s/i.test(code))
|
||||
) {
|
||||
return usercssMan.buildCode(style);
|
||||
}
|
||||
return res && style;
|
||||
}
|
||||
|
||||
function urlMatchStyle(query, style) {
|
||||
if (
|
||||
style.exclusions &&
|
||||
style.exclusions.some(e => compileExclusion(e).test(query.urlWithoutParams))
|
||||
) {
|
||||
return 'excluded';
|
||||
}
|
||||
if (!style.enabled) {
|
||||
return 'disabled';
|
||||
}
|
||||
if (!colorScheme.shouldIncludeStyle(style)) {
|
||||
return 'excludedScheme';
|
||||
}
|
||||
if (
|
||||
style.inclusions &&
|
||||
style.inclusions.some(r => compileExclusion(r).test(query.urlWithoutParams))
|
||||
) {
|
||||
return 'included';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function urlMatchSection(query, section, skipEmptyGlobal) {
|
||||
let dd, ddL, pp, ppL, rr, rrL, uu, uuL;
|
||||
if (
|
||||
(dd = section.domains) && (ddL = dd.length) && dd.some(urlMatchDomain, query) ||
|
||||
(pp = section.urlPrefixes) && (ppL = pp.length) && pp.some(urlMatchPrefix, query) ||
|
||||
/* Per the specification the fragment portion is ignored in @-moz-document:
|
||||
https://www.w3.org/TR/2012/WD-css3-conditional-20120911/#url-of-doc
|
||||
but the spec is outdated and doesn't account for SPA sites,
|
||||
so we only respect it for `url()` function */
|
||||
(uu = section.urls) && (uuL = uu.length) && (
|
||||
uu.includes(query.url) ||
|
||||
uu.includes(query.urlWithoutHash)
|
||||
) ||
|
||||
(rr = section.regexps) && (rrL = rr.length) && rr.some(urlMatchRegexp, query)
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
/*
|
||||
According to CSS4 @document specification the entire URL must match.
|
||||
Stylish-for-Chrome implemented it incorrectly since the very beginning.
|
||||
We'll detect styles that abuse the bug by finding the sections that
|
||||
would have been applied by Stylish but not by us as we follow the spec.
|
||||
*/
|
||||
if (rrL && rr.some(urlMatchRegexpSloppy, query)) {
|
||||
return 'sloppy';
|
||||
}
|
||||
// TODO: check for invalid regexps?
|
||||
return !rrL && !ppL && !uuL && !ddL &&
|
||||
!query.isOwnPage && // We allow only intentionally targeted sections for own pages
|
||||
(!skipEmptyGlobal || !styleCodeEmpty(section.code));
|
||||
}
|
||||
/** @this {MatchQuery} */
|
||||
function urlMatchDomain(d) {
|
||||
const _d = this.domain;
|
||||
return d === _d ||
|
||||
_d[_d.length - d.length - 1] === '.' && _d.endsWith(d);
|
||||
}
|
||||
/** @this {MatchQuery} */
|
||||
function urlMatchPrefix(p) {
|
||||
return p && this.url.startsWith(p);
|
||||
}
|
||||
/** @this {MatchQuery} */
|
||||
function urlMatchRegexp(r) {
|
||||
return (!this.isOwnPage || /\bextension\b/.test(r)) &&
|
||||
compileRe(r).test(this.url);
|
||||
}
|
||||
/** @this {MatchQuery} */
|
||||
function urlMatchRegexpSloppy(r) {
|
||||
return (!this.isOwnPage || /\bextension\b/.test(r)) &&
|
||||
compileSloppyRe(r).test(this.url);
|
||||
}
|
||||
|
||||
function createCompiler(compile) {
|
||||
// FIXME: FIFO cache doesn't work well here, if we want to match many
|
||||
// regexps more than the cache size, we will never hit the cache because
|
||||
// the first cache is deleted. So we use a simple map but it leaks memory.
|
||||
const cache = new Map();
|
||||
return text => {
|
||||
let re = cache.get(text);
|
||||
if (!re) {
|
||||
re = tryRegExp(compile(text));
|
||||
if (!re) {
|
||||
re = BAD_MATCHER;
|
||||
}
|
||||
cache.set(text, re);
|
||||
}
|
||||
return re;
|
||||
};
|
||||
}
|
||||
|
||||
function compileGlob(text) {
|
||||
return stringAsRegExp(text, '', true)
|
||||
.replace(/\\\\\\\*|\\\*/g, m => m.length > 2 ? m : '.*');
|
||||
}
|
||||
|
||||
function buildExclusion(text) {
|
||||
// match pattern
|
||||
const match = text.match(/^(\*|[\w-]+):\/\/(\*\.)?([\w.]+\/.*)/);
|
||||
if (!match) {
|
||||
return '^' + compileGlob(text) + '$';
|
||||
}
|
||||
return '^' +
|
||||
(match[1] === '*' ? '[\\w-]+' : match[1]) +
|
||||
'://' +
|
||||
(match[2] ? '(?:[\\w.]+\\.)?' : '') +
|
||||
compileGlob(match[3]) +
|
||||
'$';
|
||||
}
|
||||
|
||||
function buildCache(cache, url, styleList) {
|
||||
const query = new MatchQuery(url);
|
||||
for (const {style, appliesTo, preview} of styleList) {
|
||||
const code = getAppliedCode(query, preview || style);
|
||||
if (code) {
|
||||
buildCacheEntry(cache, style, code);
|
||||
appliesTo.add(url);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function buildCacheEntry(cache, style, code = style.code) {
|
||||
cache.sections[style.id] = {
|
||||
code,
|
||||
id: style.id,
|
||||
name: style.customName || style.name,
|
||||
};
|
||||
}
|
||||
|
||||
/** @returns {StyleObj[]} */
|
||||
function getAllAsArray() {
|
||||
return Array.from(dataMap.values(), v => v.style);
|
||||
}
|
||||
|
||||
/** uuidv4 helper: converts to a 4-digit hex string and adds "-" at required positions */
|
||||
function hex4dashed(num, i) {
|
||||
return (num + 0x10000).toString(16).slice(-4) + (i >= 1 && i <= 4 ? '-' : '');
|
||||
}
|
||||
|
||||
async function setOrder(data, {broadcast, calc = true, store = true, sync} = {}) {
|
||||
if (!data || !data.value || deepEqual(data.value, orderWrap.value)) {
|
||||
return;
|
||||
}
|
||||
Object.assign(orderWrap, data, sync && {_rev: Date.now()});
|
||||
if (calc) {
|
||||
for (const [type, group] of Object.entries(data.value)) {
|
||||
const dst = order[type] = {};
|
||||
group.forEach((uuid, i) => {
|
||||
const id = uuidIndex.get(uuid);
|
||||
if (id) dst[id] = i;
|
||||
});
|
||||
}
|
||||
}
|
||||
if (broadcast) {
|
||||
msg.broadcast({method: 'styleSort', order});
|
||||
}
|
||||
if (store) {
|
||||
await API.prefsDb.put(orderWrap, orderWrap.id);
|
||||
}
|
||||
if (sync) {
|
||||
API.sync.putDoc(orderWrap);
|
||||
}
|
||||
}
|
||||
|
||||
//#endregion
|
||||
})();
|
108
background/style-search-db.js
Normal file
108
background/style-search-db.js
Normal file
|
@ -0,0 +1,108 @@
|
|||
/* global API */// msg.js
|
||||
/* global RX_META debounce stringAsRegExp tryRegExp */// toolbox.js
|
||||
/* global addAPI */// common.js
|
||||
'use strict';
|
||||
|
||||
(() => {
|
||||
// toLocaleLowerCase cache, autocleared after 1 minute
|
||||
const cache = new Map();
|
||||
const METAKEYS = ['customName', 'name', 'url', 'installationUrl', 'updateUrl'];
|
||||
|
||||
const extractMeta = style =>
|
||||
style.usercssData
|
||||
? (style.sourceCode.match(RX_META) || [''])[0]
|
||||
: null;
|
||||
|
||||
const stripMeta = style =>
|
||||
style.usercssData
|
||||
? style.sourceCode.replace(RX_META, '')
|
||||
: null;
|
||||
|
||||
const MODES = Object.assign(Object.create(null), {
|
||||
code: (style, test) =>
|
||||
style.usercssData
|
||||
? test(stripMeta(style))
|
||||
: searchSections(style, test, 'code'),
|
||||
|
||||
meta: (style, test, part) =>
|
||||
METAKEYS.some(key => test(style[key])) ||
|
||||
test(part === 'all' ? style.sourceCode : extractMeta(style)) ||
|
||||
searchSections(style, test, 'funcs'),
|
||||
|
||||
name: (style, test) =>
|
||||
test(style.customName) ||
|
||||
test(style.name),
|
||||
|
||||
all: (style, test) =>
|
||||
MODES.meta(style, test, 'all') ||
|
||||
!style.usercssData && MODES.code(style, test),
|
||||
});
|
||||
|
||||
addAPI(/** @namespace API */ {
|
||||
styles: {
|
||||
/**
|
||||
* @param params
|
||||
* @param {string} params.query - 1. url:someurl 2. text (may contain quoted parts like "qUot Ed")
|
||||
* @param {'name'|'meta'|'code'|'all'|'url'} [params.mode=all]
|
||||
* @param {number[]} [params.ids] - if not specified, all styles are searched
|
||||
* @returns {number[]} - array of matched styles ids
|
||||
*/
|
||||
async searchDB({query, mode = 'all', ids}) {
|
||||
let res = [];
|
||||
if (mode === 'url' && query) {
|
||||
res = (await API.styles.getByUrl(query)).map(r => r.style.id);
|
||||
} else if (mode in MODES) {
|
||||
const modeHandler = MODES[mode];
|
||||
const m = /^\/(.+?)\/([gimsuy]*)$/.exec(query);
|
||||
const rx = m && tryRegExp(m[1], m[2]);
|
||||
const test = rx ? rx.test.bind(rx) : createTester(query);
|
||||
res = (await API.styles.getAll())
|
||||
.filter(style =>
|
||||
(!ids || ids.includes(style.id)) &&
|
||||
(!query || modeHandler(style, test)))
|
||||
.map(style => style.id);
|
||||
if (cache.size) debounce(clearCache, 60e3);
|
||||
}
|
||||
return res;
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
function createTester(query) {
|
||||
const flags = `u${lower(query) === query ? 'i' : ''}`;
|
||||
const words = query
|
||||
.split(/(".*?")|\s+/)
|
||||
.filter(Boolean)
|
||||
.map(w => w.startsWith('"') && w.endsWith('"')
|
||||
? w.slice(1, -1)
|
||||
: w)
|
||||
.filter(w => w.length > 1);
|
||||
const rxs = (words.length ? words : [query])
|
||||
.map(w => stringAsRegExp(w, flags));
|
||||
return text => rxs.every(rx => rx.test(text));
|
||||
}
|
||||
|
||||
function searchSections({sections}, test, part) {
|
||||
const inCode = part === 'code' || part === 'all';
|
||||
const inFuncs = part === 'funcs' || part === 'all';
|
||||
for (const section of sections) {
|
||||
for (const prop in section) {
|
||||
const value = section[prop];
|
||||
if (inCode && prop === 'code' && test(value) ||
|
||||
inFuncs && Array.isArray(value) && value.some(str => test(str))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function lower(text) {
|
||||
let result = cache.get(text);
|
||||
if (!result) cache.set(text, result = text.toLocaleLowerCase());
|
||||
return result;
|
||||
}
|
||||
|
||||
function clearCache() {
|
||||
cache.clear();
|
||||
}
|
||||
})();
|
|
@ -1,7 +1,14 @@
|
|||
/* global getStyles */
|
||||
/* global API */// msg.js
|
||||
/* global addAPI */// common.js
|
||||
/* global isEmptyObj */// toolbox.js
|
||||
/* global prefs */
|
||||
'use strict';
|
||||
|
||||
const styleViaAPI = !CHROME && (() => {
|
||||
/**
|
||||
* Uses chrome.tabs.insertCSS
|
||||
*/
|
||||
|
||||
(() => {
|
||||
const ACTIONS = {
|
||||
styleApply,
|
||||
styleDeleted,
|
||||
|
@ -9,28 +16,38 @@ const styleViaAPI = !CHROME && (() => {
|
|||
styleAdded,
|
||||
styleReplaceAll,
|
||||
prefChanged,
|
||||
updateCount,
|
||||
};
|
||||
const NOP = Promise.resolve(new Error('NOP'));
|
||||
const NOP = new Error('NOP');
|
||||
const onError = () => {};
|
||||
|
||||
/* <tabId>: Object
|
||||
<frameId>: Object
|
||||
url: String, non-enumerable
|
||||
<styleId>: Array of strings
|
||||
section code */
|
||||
const cache = new Map();
|
||||
|
||||
let observingTabs = false;
|
||||
|
||||
return (request, sender) => {
|
||||
const action = ACTIONS[request.action];
|
||||
return !action ? NOP :
|
||||
action(request, sender)
|
||||
.catch(onError)
|
||||
.then(maybeToggleObserver);
|
||||
};
|
||||
addAPI(/** @namespace API */ {
|
||||
async styleViaAPI(request) {
|
||||
try {
|
||||
const fn = ACTIONS[request.method];
|
||||
return fn ? fn(request, this.sender) : NOP;
|
||||
} catch (e) {}
|
||||
maybeToggleObserver();
|
||||
},
|
||||
});
|
||||
|
||||
function styleApply({id = null, ignoreUrlCheck}, {tab, frameId, url}) {
|
||||
function updateCount(request, sender) {
|
||||
const {tab, frameId} = sender;
|
||||
if (frameId) {
|
||||
throw new Error('we do not count styles for frames');
|
||||
}
|
||||
const {frameStyles} = getCachedData(tab.id, frameId);
|
||||
API.updateIconBadge.call({sender}, Object.keys(frameStyles));
|
||||
}
|
||||
|
||||
function styleApply({id = null, ignoreUrlCheck = false}, {tab, frameId, url}) {
|
||||
if (prefs.get('disableAll')) {
|
||||
return NOP;
|
||||
}
|
||||
|
@ -38,24 +55,16 @@ const styleViaAPI = !CHROME && (() => {
|
|||
if (id === null && !ignoreUrlCheck && frameStyles.url === url) {
|
||||
return NOP;
|
||||
}
|
||||
return getStyles({id, matchUrl: url, enabled: true, asHash: true}).then(styles => {
|
||||
return API.styles.getSectionsByUrl(url, id).then(sections => {
|
||||
delete sections.cfg;
|
||||
const tasks = [];
|
||||
for (const styleId in styles) {
|
||||
if (isNaN(parseInt(styleId))) {
|
||||
continue;
|
||||
}
|
||||
// shallow-extract code from the sections array in order to reuse references
|
||||
// in other places whereas the combined string gets garbage-collected
|
||||
const styleSections = styles[styleId].map(section => section.code);
|
||||
const code = styleSections.join('\n');
|
||||
if (!code) {
|
||||
delete frameStyles[styleId];
|
||||
continue;
|
||||
}
|
||||
for (const section of Object.values(sections)) {
|
||||
const styleId = section.id;
|
||||
const code = section.code.join('\n');
|
||||
if (code === (frameStyles[styleId] || []).join('\n')) {
|
||||
continue;
|
||||
}
|
||||
frameStyles[styleId] = styleSections;
|
||||
frameStyles[styleId] = section.code;
|
||||
tasks.push(
|
||||
browser.tabs.insertCSS(tab.id, {
|
||||
code,
|
||||
|
@ -70,16 +79,18 @@ const styleViaAPI = !CHROME && (() => {
|
|||
cache.set(tab.id, tabFrames);
|
||||
}
|
||||
return Promise.all(tasks);
|
||||
});
|
||||
})
|
||||
.then(() => updateCount(null, {tab, frameId}));
|
||||
}
|
||||
|
||||
function styleDeleted({id}, {tab, frameId}) {
|
||||
function styleDeleted({style: {id}}, {tab, frameId}) {
|
||||
const {tabFrames, frameStyles, styleSections} = getCachedData(tab.id, frameId, id);
|
||||
const code = styleSections.join('\n');
|
||||
if (code && !duplicateCodeExists({frameStyles, id, code})) {
|
||||
delete frameStyles[id];
|
||||
removeFrameIfEmpty(tab.id, frameId, tabFrames, frameStyles);
|
||||
return removeCSS(tab.id, frameId, code);
|
||||
return removeCSS(tab.id, frameId, code)
|
||||
.then(() => updateCount(null, {tab, frameId}));
|
||||
} else {
|
||||
return NOP;
|
||||
}
|
||||
|
@ -87,7 +98,7 @@ const styleViaAPI = !CHROME && (() => {
|
|||
|
||||
function styleUpdated({style}, sender) {
|
||||
if (!style.enabled) {
|
||||
return styleDeleted(style, sender);
|
||||
return styleDeleted({style}, sender);
|
||||
}
|
||||
const {tab, frameId} = sender;
|
||||
const {frameStyles, styleSections} = getCachedData(tab.id, frameId, style.id);
|
||||
|
@ -122,13 +133,15 @@ const styleViaAPI = !CHROME && (() => {
|
|||
}
|
||||
const {tab, frameId} = sender;
|
||||
const {tabFrames, frameStyles} = getCachedData(tab.id, frameId);
|
||||
if (isEmpty(frameStyles)) {
|
||||
if (isEmptyObj(frameStyles)) {
|
||||
return NOP;
|
||||
}
|
||||
removeFrameIfEmpty(tab.id, frameId, tabFrames, {});
|
||||
const tasks = Object.keys(frameStyles)
|
||||
.map(id => removeCSS(tab.id, frameId, frameStyles[id].join('\n')));
|
||||
return Promise.all(tasks);
|
||||
} else {
|
||||
return NOP;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -155,9 +168,9 @@ const styleViaAPI = !CHROME && (() => {
|
|||
return;
|
||||
}
|
||||
const tabFrames = cache.get(tabId);
|
||||
if (frameId in tabFrames) {
|
||||
if (tabFrames && frameId in tabFrames) {
|
||||
delete tabFrames[frameId];
|
||||
if (isEmpty(tabFrames)) {
|
||||
if (isEmptyObj(tabFrames)) {
|
||||
onTabRemoved(tabId);
|
||||
}
|
||||
}
|
||||
|
@ -173,9 +186,9 @@ const styleViaAPI = !CHROME && (() => {
|
|||
}
|
||||
|
||||
function removeFrameIfEmpty(tabId, frameId, tabFrames, frameStyles) {
|
||||
if (isEmpty(frameStyles)) {
|
||||
if (isEmptyObj(frameStyles)) {
|
||||
delete tabFrames[frameId];
|
||||
if (isEmpty(tabFrames)) {
|
||||
if (isEmptyObj(tabFrames)) {
|
||||
cache.delete(tabId);
|
||||
}
|
||||
return true;
|
||||
|
@ -218,11 +231,4 @@ const styleViaAPI = !CHROME && (() => {
|
|||
return browser.tabs.removeCSS(tabId, {frameId, code, matchAboutBlank: true})
|
||||
.catch(onError);
|
||||
}
|
||||
|
||||
function isEmpty(obj) {
|
||||
for (const k in obj) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
})();
|
||||
|
|
166
background/style-via-webrequest.js
Normal file
166
background/style-via-webrequest.js
Normal file
|
@ -0,0 +1,166 @@
|
|||
/* global API */// msg.js
|
||||
/* global CHROME URLS ignoreChromeError */// toolbox.js
|
||||
/* global prefs */
|
||||
'use strict';
|
||||
|
||||
(() => {
|
||||
const idCSP = 'patchCsp';
|
||||
const idOFF = 'disableAll';
|
||||
const idXHR = 'styleViaXhr';
|
||||
const rxHOST = /^('none'|(https?:\/\/)?[^']+?[^:'])$/; // strips CSP sources covered by *
|
||||
const blobUrlPrefix = 'blob:' + chrome.runtime.getURL('/');
|
||||
/** @type {Object<string,StylesToPass>} */
|
||||
const stylesToPass = {};
|
||||
const state = {};
|
||||
const injectedCode = CHROME && `${data => {
|
||||
if (self.INJECTED !== 1) { // storing data only if apply.js hasn't run yet
|
||||
window[Symbol.for('styles')] = data;
|
||||
}
|
||||
}}`;
|
||||
|
||||
toggle();
|
||||
prefs.subscribe([idXHR, idOFF, idCSP], toggle);
|
||||
|
||||
function toggle() {
|
||||
const off = prefs.get(idOFF);
|
||||
const csp = prefs.get(idCSP) && !off;
|
||||
const xhr = prefs.get(idXHR) && !off;
|
||||
if (xhr === state.xhr && csp === state.csp && off === state.off) {
|
||||
return;
|
||||
}
|
||||
const reqFilter = {
|
||||
urls: ['*://*/*'],
|
||||
types: ['main_frame', 'sub_frame'],
|
||||
};
|
||||
chrome.webNavigation.onCommitted.removeListener(injectData);
|
||||
chrome.webRequest.onBeforeRequest.removeListener(prepareStyles);
|
||||
chrome.webRequest.onHeadersReceived.removeListener(modifyHeaders);
|
||||
if (xhr || csp) {
|
||||
// We unregistered it above so that the optional EXTRA_HEADERS is properly re-registered
|
||||
chrome.webRequest.onHeadersReceived.addListener(modifyHeaders, reqFilter, [
|
||||
'blocking',
|
||||
'responseHeaders',
|
||||
xhr && chrome.webRequest.OnHeadersReceivedOptions.EXTRA_HEADERS,
|
||||
].filter(Boolean));
|
||||
}
|
||||
if (CHROME ? !off : xhr || csp) {
|
||||
chrome.webRequest.onBeforeRequest.addListener(prepareStyles, reqFilter);
|
||||
}
|
||||
if (CHROME && !off) {
|
||||
chrome.webNavigation.onCommitted.addListener(injectData, {url: [{urlPrefix: 'http'}]});
|
||||
}
|
||||
if (CHROME) {
|
||||
chrome.webRequest.onBeforeRequest.addListener(openNamedStyle, {
|
||||
urls: [URLS.ownOrigin + '*.user.css'],
|
||||
types: ['main_frame'],
|
||||
}, ['blocking']);
|
||||
}
|
||||
state.csp = csp;
|
||||
state.off = off;
|
||||
state.xhr = xhr;
|
||||
}
|
||||
|
||||
/** @param {chrome.webRequest.WebRequestBodyDetails} req */
|
||||
async function prepareStyles(req) {
|
||||
const sections = await API.styles.getSectionsByUrl(req.url);
|
||||
stylesToPass[req2key(req)] = /** @namespace StylesToPass */ {
|
||||
blobId: '',
|
||||
str: JSON.stringify(sections),
|
||||
timer: setTimeout(cleanUp, 600e3, req),
|
||||
};
|
||||
}
|
||||
|
||||
function injectData(req) {
|
||||
const data = stylesToPass[req2key(req)];
|
||||
if (data && !data.injected) {
|
||||
data.injected = true;
|
||||
chrome.tabs.executeScript(req.tabId, {
|
||||
frameId: req.frameId,
|
||||
runAt: 'document_start',
|
||||
code: `(${injectedCode})(${data.str})`,
|
||||
}, ignoreChromeError);
|
||||
if (!state.xhr) cleanUp(req);
|
||||
}
|
||||
}
|
||||
|
||||
/** @param {chrome.webRequest.WebResponseHeadersDetails} req */
|
||||
function modifyHeaders(req) {
|
||||
const {responseHeaders} = req;
|
||||
const data = stylesToPass[req2key(req)];
|
||||
if (!data || data.str === '{}') {
|
||||
cleanUp(req);
|
||||
return;
|
||||
}
|
||||
if (state.xhr) {
|
||||
data.blobId = URL.createObjectURL(new Blob([data.str])).slice(blobUrlPrefix.length);
|
||||
responseHeaders.push({
|
||||
name: 'Set-Cookie',
|
||||
value: `${chrome.runtime.id}=${data.blobId}`,
|
||||
});
|
||||
}
|
||||
const csp = state.csp &&
|
||||
responseHeaders.find(h => h.name.toLowerCase() === 'content-security-policy');
|
||||
if (csp) {
|
||||
patchCsp(csp);
|
||||
}
|
||||
if (state.xhr || csp) {
|
||||
return {responseHeaders};
|
||||
}
|
||||
}
|
||||
|
||||
/** @param {chrome.webRequest.HttpHeader} csp */
|
||||
function patchCsp(csp) {
|
||||
const src = {};
|
||||
for (let p of csp.value.split(';')) {
|
||||
p = p.trim().split(/\s+/);
|
||||
src[p[0]] = p.slice(1);
|
||||
}
|
||||
// Allow style assets
|
||||
patchCspSrc(src, 'img-src', 'data:', '*');
|
||||
patchCspSrc(src, 'font-src', 'data:', '*');
|
||||
// Allow our DOM styles, allow @import from any URL
|
||||
patchCspSrc(src, 'style-src', "'unsafe-inline'", '*');
|
||||
// Allow our XHR cookies in CSP sandbox (known case: raw github urls)
|
||||
if (src.sandbox && !src.sandbox.includes('allow-same-origin')) {
|
||||
src.sandbox.push('allow-same-origin');
|
||||
}
|
||||
csp.value = Object.entries(src).map(([k, v]) =>
|
||||
`${k}${v.length ? ' ' : ''}${v.join(' ')}`).join('; ');
|
||||
}
|
||||
|
||||
function patchCspSrc(src, name, ...values) {
|
||||
let def = src['default-src'];
|
||||
let list = src[name];
|
||||
if (def || list) {
|
||||
if (!def) def = [];
|
||||
if (!list) list = [...def];
|
||||
if (values.includes('*')) list = src[name] = list.filter(v => !rxHOST.test(v));
|
||||
list.push(...values.filter(v => !list.includes(v) && !def.includes(v)));
|
||||
if (!list.length) delete src[name];
|
||||
}
|
||||
}
|
||||
|
||||
function cleanUp(req) {
|
||||
const key = req2key(req);
|
||||
const data = stylesToPass[key];
|
||||
if (data) {
|
||||
delete stylesToPass[key];
|
||||
clearTimeout(data.timer);
|
||||
if (data.blobId) {
|
||||
URL.revokeObjectURL(blobUrlPrefix + data.blobId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** @param {chrome.webRequest.WebRequestBodyDetails} req */
|
||||
function openNamedStyle(req) {
|
||||
if (!req.url.includes('?')) { // skipping our usercss installer
|
||||
chrome.tabs.update(req.tabId, {url: 'edit.html?id=' + req.url.split('#')[1]});
|
||||
return {cancel: true};
|
||||
}
|
||||
}
|
||||
|
||||
function req2key(req) {
|
||||
return req.tabId + ':' + req.frameId;
|
||||
}
|
||||
})();
|
307
background/sync-manager.js
Normal file
307
background/sync-manager.js
Normal file
|
@ -0,0 +1,307 @@
|
|||
/* global API msg */// msg.js
|
||||
/* global bgReady uuidIndex */// common.js
|
||||
/* global chromeLocal chromeSync */// storage-util.js
|
||||
/* global db */
|
||||
/* global iconMan */
|
||||
/* global prefs */
|
||||
/* global styleUtil */
|
||||
/* global tokenMan */
|
||||
'use strict';
|
||||
|
||||
const syncMan = (() => {
|
||||
//#region Init
|
||||
|
||||
const SYNC_DELAY = 1; // minutes
|
||||
const SYNC_INTERVAL = 30; // minutes
|
||||
const STATES = Object.freeze({
|
||||
connected: 'connected',
|
||||
connecting: 'connecting',
|
||||
disconnected: 'disconnected',
|
||||
disconnecting: 'disconnecting',
|
||||
});
|
||||
const STORAGE_KEY = 'sync/state/';
|
||||
const NO_LOGIN = ['webdav'];
|
||||
const status = /** @namespace SyncManager.Status */ {
|
||||
STATES,
|
||||
state: STATES.disconnected,
|
||||
syncing: false,
|
||||
progress: null,
|
||||
currentDriveName: null,
|
||||
errorMessage: null,
|
||||
login: false,
|
||||
};
|
||||
const compareRevision = (rev1, rev2) => rev1 - rev2;
|
||||
let lastError = null;
|
||||
let ctrl;
|
||||
let currentDrive;
|
||||
/** @type {Promise|boolean} will be `true` to avoid wasting a microtask tick on each `await` */
|
||||
let ready = bgReady.styles.then(() => {
|
||||
ready = true;
|
||||
prefs.subscribe('sync.enabled',
|
||||
(_, val) => val === 'none'
|
||||
? syncMan.stop()
|
||||
: syncMan.start(val, true),
|
||||
{runNow: true});
|
||||
});
|
||||
|
||||
chrome.alarms.onAlarm.addListener(async ({name}) => {
|
||||
if (name === 'syncNow') {
|
||||
await syncMan.syncNow();
|
||||
}
|
||||
});
|
||||
|
||||
//#endregion
|
||||
//#region Exports
|
||||
|
||||
return {
|
||||
|
||||
async delete(...args) {
|
||||
if (ready.then) await ready;
|
||||
if (!currentDrive) return;
|
||||
schedule();
|
||||
return ctrl.delete(...args);
|
||||
},
|
||||
|
||||
/** @returns {Promise<SyncManager.Status>} */
|
||||
async getStatus() {
|
||||
return status;
|
||||
},
|
||||
|
||||
async login(name) {
|
||||
if (ready.then) await ready;
|
||||
if (!name) name = prefs.get('sync.enabled');
|
||||
await tokenMan.revokeToken(name);
|
||||
try {
|
||||
await tokenMan.getToken(name, true);
|
||||
status.login = true;
|
||||
} catch (err) {
|
||||
status.login = false;
|
||||
throw err;
|
||||
} finally {
|
||||
emitStatusChange();
|
||||
}
|
||||
},
|
||||
|
||||
async putDoc({_id, _rev}) {
|
||||
if (ready.then) await ready;
|
||||
if (!currentDrive) return;
|
||||
schedule();
|
||||
return ctrl.put(_id, _rev);
|
||||
},
|
||||
|
||||
async setDriveOptions(driveName, options) {
|
||||
const key = `secure/sync/driveOptions/${driveName}`;
|
||||
await chromeSync.setValue(key, options);
|
||||
},
|
||||
|
||||
async getDriveOptions(driveName) {
|
||||
const key = `secure/sync/driveOptions/${driveName}`;
|
||||
return await chromeSync.getValue(key) || {};
|
||||
},
|
||||
|
||||
async start(name, fromPref = false) {
|
||||
if (ready.then) await ready;
|
||||
if (!ctrl) await initController();
|
||||
|
||||
if (currentDrive) return;
|
||||
currentDrive = await getDrive(name);
|
||||
ctrl.use(currentDrive);
|
||||
|
||||
status.state = STATES.connecting;
|
||||
status.currentDriveName = currentDrive.name;
|
||||
emitStatusChange();
|
||||
|
||||
if (fromPref || NO_LOGIN.includes(currentDrive.name)) {
|
||||
status.login = true;
|
||||
} else {
|
||||
try {
|
||||
await syncMan.login(name);
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
status.errorMessage = err.message;
|
||||
lastError = err;
|
||||
emitStatusChange();
|
||||
return syncMan.stop();
|
||||
}
|
||||
}
|
||||
|
||||
await ctrl.init();
|
||||
|
||||
await syncMan.syncNow(name);
|
||||
prefs.set('sync.enabled', name);
|
||||
status.state = STATES.connected;
|
||||
schedule(SYNC_INTERVAL);
|
||||
emitStatusChange();
|
||||
},
|
||||
|
||||
async stop() {
|
||||
if (ready.then) await ready;
|
||||
if (!currentDrive) return;
|
||||
chrome.alarms.clear('syncNow');
|
||||
status.state = STATES.disconnecting;
|
||||
emitStatusChange();
|
||||
try {
|
||||
await ctrl.uninit();
|
||||
await tokenMan.revokeToken(currentDrive.name);
|
||||
await chromeLocal.remove(STORAGE_KEY + currentDrive.name);
|
||||
} catch (e) {}
|
||||
currentDrive = null;
|
||||
prefs.set('sync.enabled', 'none');
|
||||
status.state = STATES.disconnected;
|
||||
status.currentDriveName = null;
|
||||
status.login = false;
|
||||
emitStatusChange();
|
||||
},
|
||||
|
||||
async syncNow() {
|
||||
if (ready.then) await ready;
|
||||
if (!currentDrive || !status.login) {
|
||||
console.warn('cannot sync when disconnected');
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await ctrl.syncNow();
|
||||
status.errorMessage = null;
|
||||
lastError = null;
|
||||
} catch (err) {
|
||||
err.message = translateErrorMessage(err);
|
||||
status.errorMessage = err.message;
|
||||
lastError = err;
|
||||
if (isGrantError(err)) {
|
||||
status.login = false;
|
||||
}
|
||||
}
|
||||
emitStatusChange();
|
||||
},
|
||||
};
|
||||
|
||||
//#endregion
|
||||
//#region Utils
|
||||
|
||||
async function initController() {
|
||||
await require(['/vendor/db-to-cloud/db-to-cloud']); /* global dbToCloud */
|
||||
ctrl = dbToCloud.dbToCloud({
|
||||
onGet: styleUtil.uuid2style,
|
||||
async onPut(doc) {
|
||||
const id = uuidIndex.get(doc._id);
|
||||
const oldCust = uuidIndex.custom[id];
|
||||
const oldDoc = oldCust || styleUtil.id2style(id);
|
||||
const diff = oldDoc ? compareRevision(oldDoc._rev, doc._rev) : -1;
|
||||
if (!diff) return;
|
||||
if (diff > 0) {
|
||||
syncMan.putDoc(oldDoc);
|
||||
} else if (oldCust) {
|
||||
uuidIndex.custom[id] = doc;
|
||||
} else {
|
||||
delete doc.id;
|
||||
if (id) doc.id = id;
|
||||
doc.id = await db.styles.put(doc);
|
||||
await styleUtil.handleSave(doc, {reason: 'sync'});
|
||||
}
|
||||
},
|
||||
onDelete(_id, rev) {
|
||||
const id = uuidIndex.get(_id);
|
||||
const oldDoc = styleUtil.id2style(id);
|
||||
return oldDoc &&
|
||||
compareRevision(oldDoc._rev, rev) <= 0 &&
|
||||
API.styles.delete(id, 'sync');
|
||||
},
|
||||
async onFirstSync() {
|
||||
for (const i of Object.values(uuidIndex.custom).concat(await API.styles.getAll())) {
|
||||
ctrl.put(i._id, i._rev);
|
||||
}
|
||||
},
|
||||
onProgress(e) {
|
||||
if (e.phase === 'start') {
|
||||
status.syncing = true;
|
||||
} else if (e.phase === 'end') {
|
||||
status.syncing = false;
|
||||
status.progress = null;
|
||||
} else {
|
||||
status.progress = e;
|
||||
}
|
||||
emitStatusChange();
|
||||
},
|
||||
compareRevision,
|
||||
getState(drive) {
|
||||
return chromeLocal.getValue(STORAGE_KEY + drive.name);
|
||||
},
|
||||
setState(drive, state) {
|
||||
return chromeLocal.setValue(STORAGE_KEY + drive.name, state);
|
||||
},
|
||||
retryMaxAttempts: 10,
|
||||
retryExp: 1.2,
|
||||
retryDelay: 6,
|
||||
});
|
||||
}
|
||||
|
||||
function emitStatusChange() {
|
||||
msg.broadcastExtension({method: 'syncStatusUpdate', status});
|
||||
iconMan.overrideBadge(getErrorBadge());
|
||||
}
|
||||
|
||||
function isNetworkError(err) {
|
||||
return (
|
||||
err.name === 'TypeError' && /networkerror|failed to fetch/i.test(err.message) ||
|
||||
err.code === 502
|
||||
);
|
||||
}
|
||||
|
||||
function isGrantError(err) {
|
||||
if (err.code === 401) return true;
|
||||
if (err.code === 400 && /invalid_grant/.test(err.message)) return true;
|
||||
if (err.name === 'TokenError') return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
function getErrorBadge() {
|
||||
if (status.state === STATES.connected &&
|
||||
(!status.login || lastError && !isNetworkError(lastError))) {
|
||||
return {
|
||||
text: 'x',
|
||||
color: '#F00',
|
||||
title: !status.login ? 'syncErrorRelogin' : `${
|
||||
chrome.i18n.getMessage('syncError')
|
||||
}\n---------------------\n${
|
||||
// splitting to limit each line length
|
||||
lastError.message.replace(/.{60,}?\s(?=.{30,})/g, '$&\n')
|
||||
}`,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
async function getDrive(name) {
|
||||
if (name === 'dropbox' || name === 'google' || name === 'onedrive' || name === 'webdav') {
|
||||
const options = await syncMan.getDriveOptions(name);
|
||||
options.getAccessToken = () => tokenMan.getToken(name);
|
||||
options.fetch = name === 'webdav' ? fetchWebDAV.bind(options) : fetch;
|
||||
return dbToCloud.drive[name](options);
|
||||
}
|
||||
throw new Error(`unknown cloud name: ${name}`);
|
||||
}
|
||||
|
||||
/** @this {Object} DriveOptions */
|
||||
function fetchWebDAV(url, init = {}) {
|
||||
init.credentials = 'omit'; // circumventing nextcloud CSRF token error
|
||||
init.headers = Object.assign({}, init.headers, {
|
||||
Authorization: `Basic ${btoa(`${this.username || ''}:${this.password || ''}`)}`,
|
||||
});
|
||||
return fetch(url, init);
|
||||
}
|
||||
|
||||
function schedule(delay = SYNC_DELAY) {
|
||||
chrome.alarms.create('syncNow', {
|
||||
delayInMinutes: delay, // fractional values are supported
|
||||
periodInMinutes: SYNC_INTERVAL,
|
||||
});
|
||||
}
|
||||
|
||||
function translateErrorMessage(err) {
|
||||
if (err.name === 'LockError') {
|
||||
return browser.i18n.getMessage('syncErrorLock', new Date(err.expire).toLocaleString([], {timeStyle: 'short'}));
|
||||
}
|
||||
return err.message || String(err);
|
||||
}
|
||||
|
||||
//#endregion
|
||||
})();
|
62
background/tab-manager.js
Normal file
62
background/tab-manager.js
Normal file
|
@ -0,0 +1,62 @@
|
|||
/* global bgReady */// common.js
|
||||
/* global navMan */
|
||||
'use strict';
|
||||
|
||||
const tabMan = (() => {
|
||||
const listeners = new Set();
|
||||
const cache = new Map();
|
||||
chrome.tabs.onRemoved.addListener(tabId => cache.delete(tabId));
|
||||
chrome.tabs.onReplaced.addListener((added, removed) => cache.delete(removed));
|
||||
|
||||
bgReady.all.then(() => {
|
||||
navMan.onUrlChange(({tabId, frameId, url}) => {
|
||||
const oldUrl = !frameId && tabMan.get(tabId, 'url', frameId);
|
||||
tabMan.set(tabId, 'url', frameId, url);
|
||||
if (frameId) return;
|
||||
for (const fn of listeners) {
|
||||
try {
|
||||
fn({tabId, url, oldUrl});
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
return {
|
||||
onUpdate(fn) {
|
||||
listeners.add(fn);
|
||||
},
|
||||
|
||||
get(tabId, ...keys) {
|
||||
return keys.reduce((meta, key) => meta && meta[key], cache.get(tabId));
|
||||
},
|
||||
|
||||
/**
|
||||
* number of keys is arbitrary, last arg is value, `undefined` will delete the last key from meta
|
||||
* (tabId, 'foo', 123) will set tabId's meta to {foo: 123},
|
||||
* (tabId, 'foo', 'bar', 'etc', 123) will set tabId's meta to {foo: {bar: {etc: 123}}}
|
||||
*/
|
||||
set(tabId, ...args) {
|
||||
let meta = cache.get(tabId);
|
||||
if (!meta) {
|
||||
meta = {};
|
||||
cache.set(tabId, meta);
|
||||
}
|
||||
const value = args.pop();
|
||||
const lastKey = args.pop();
|
||||
for (const key of args) meta = meta[key] || (meta[key] = {});
|
||||
if (value === undefined) {
|
||||
delete meta[lastKey];
|
||||
} else {
|
||||
meta[lastKey] = value;
|
||||
}
|
||||
},
|
||||
|
||||
/** @returns {IterableIterator<number>} */
|
||||
list() {
|
||||
return cache.keys();
|
||||
},
|
||||
};
|
||||
|
||||
})();
|
270
background/token-manager.js
Normal file
270
background/token-manager.js
Normal file
|
@ -0,0 +1,270 @@
|
|||
/* global FIREFOX getActiveTab waitForTabUrl URLS */// toolbox.js
|
||||
/* global chromeLocal */// storage-util.js
|
||||
'use strict';
|
||||
|
||||
/* exported tokenMan */
|
||||
const tokenMan = (() => {
|
||||
const AUTH = {
|
||||
dropbox: {
|
||||
flow: 'token',
|
||||
clientId: 'zg52vphuapvpng9',
|
||||
authURL: 'https://www.dropbox.com/oauth2/authorize',
|
||||
tokenURL: 'https://api.dropboxapi.com/oauth2/token',
|
||||
revoke: token =>
|
||||
fetch('https://api.dropboxapi.com/2/auth/token/revoke', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Authorization': `Bearer ${token}`,
|
||||
},
|
||||
}),
|
||||
},
|
||||
google: {
|
||||
flow: 'code',
|
||||
clientId: '283762574871-d4u58s4arra5jdan2gr00heasjlttt1e.apps.googleusercontent.com',
|
||||
clientSecret: 'J0nc5TlR_0V_ex9-sZk-5faf',
|
||||
authURL: 'https://accounts.google.com/o/oauth2/v2/auth',
|
||||
authQuery: {
|
||||
// NOTE: Google needs 'prompt' parameter to deliver multiple refresh
|
||||
// tokens for multiple machines.
|
||||
// https://stackoverflow.com/q/18519185
|
||||
access_type: 'offline',
|
||||
prompt: 'consent',
|
||||
},
|
||||
tokenURL: 'https://oauth2.googleapis.com/token',
|
||||
scopes: ['https://www.googleapis.com/auth/drive.appdata'],
|
||||
// FIXME: https://github.com/openstyles/stylus/issues/1248
|
||||
// revoke: token => {
|
||||
// const params = {token};
|
||||
// return postQuery(`https://accounts.google.com/o/oauth2/revoke?${new URLSearchParams(params)}`);
|
||||
// },
|
||||
},
|
||||
onedrive: {
|
||||
flow: 'code',
|
||||
clientId: '3864ce03-867c-4ad8-9856-371a097d47b1',
|
||||
clientSecret: '9Pj=TpsrStq8K@1BiwB9PIWLppM:@s=w',
|
||||
authURL: 'https://login.microsoftonline.com/common/oauth2/v2.0/authorize',
|
||||
tokenURL: 'https://login.microsoftonline.com/common/oauth2/v2.0/token',
|
||||
scopes: ['Files.ReadWrite.AppFolder', 'offline_access'],
|
||||
},
|
||||
userstylesworld: {
|
||||
flow: 'code',
|
||||
clientId: 'zeDmKhJIfJqULtcrGMsWaxRtWHEimKgS',
|
||||
clientSecret: 'wqHsvTuThQmXmDiVvOpZxPwSIbyycNFImpAOTxjaIRqDbsXcTOqrymMJKsOMuibFaij' +
|
||||
'ZZAkVYTDbLkQuYFKqgpMsMlFlgwQOYHvHFbgxQHDTwwdOroYhOwFuekCwXUlk',
|
||||
authURL: URLS.usw + 'api/oauth/style/link',
|
||||
tokenURL: URLS.usw + 'api/oauth/token',
|
||||
redirect_uri: 'https://gusted.xyz/callback_helper/',
|
||||
},
|
||||
};
|
||||
const NETWORK_LATENCY = 30; // seconds
|
||||
const DEFAULT_REDIRECT_URI = 'https://clngdbkpkpeebahjckkjfobafhncgmne.chromiumapp.org/';
|
||||
|
||||
let alwaysUseTab = !chrome.windows || (FIREFOX ? false : null);
|
||||
|
||||
class TokenError extends Error {
|
||||
constructor(provider, message) {
|
||||
super(`[${provider}] ${message}`);
|
||||
this.name = 'TokenError';
|
||||
this.provider = provider;
|
||||
if (Error.captureStackTrace) {
|
||||
Error.captureStackTrace(this, TokenError);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
buildKeys(name, hooks) {
|
||||
const prefix = `secure/token/${hooks ? hooks.keyName(name) : name}/`;
|
||||
const k = {
|
||||
TOKEN: `${prefix}token`,
|
||||
EXPIRE: `${prefix}expire`,
|
||||
REFRESH: `${prefix}refresh`,
|
||||
};
|
||||
k.LIST = Object.values(k);
|
||||
return k;
|
||||
},
|
||||
|
||||
getClientId(name) {
|
||||
return AUTH[name].clientId;
|
||||
},
|
||||
|
||||
async getToken(name, interactive, hooks) {
|
||||
const k = tokenMan.buildKeys(name, hooks);
|
||||
const obj = await chromeLocal.get(k.LIST);
|
||||
if (obj[k.TOKEN]) {
|
||||
if (!obj[k.EXPIRE] || Date.now() < obj[k.EXPIRE]) {
|
||||
return obj[k.TOKEN];
|
||||
}
|
||||
if (obj[k.REFRESH]) {
|
||||
return refreshToken(name, k, obj);
|
||||
}
|
||||
}
|
||||
if (!interactive) {
|
||||
throw new TokenError(name, 'Token is missing');
|
||||
}
|
||||
return authUser(k, name, interactive, hooks);
|
||||
},
|
||||
|
||||
async revokeToken(name, hooks) {
|
||||
const provider = AUTH[name];
|
||||
const k = tokenMan.buildKeys(name, hooks);
|
||||
if (provider.revoke) {
|
||||
try {
|
||||
const token = await chromeLocal.getValue(k.TOKEN);
|
||||
if (token) await provider.revoke(token);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
await chromeLocal.remove(k.LIST);
|
||||
},
|
||||
};
|
||||
|
||||
async function refreshToken(name, k, obj) {
|
||||
if (!obj[k.REFRESH]) {
|
||||
throw new TokenError(name, 'No refresh token');
|
||||
}
|
||||
const provider = AUTH[name];
|
||||
const body = {
|
||||
client_id: provider.clientId,
|
||||
refresh_token: obj[k.REFRESH],
|
||||
grant_type: 'refresh_token',
|
||||
scope: provider.scopes.join(' '),
|
||||
};
|
||||
if (provider.clientSecret) {
|
||||
body.client_secret = provider.clientSecret;
|
||||
}
|
||||
const result = await postQuery(provider.tokenURL, body);
|
||||
if (!result.refresh_token) {
|
||||
// reuse old refresh token
|
||||
result.refresh_token = obj[k.REFRESH];
|
||||
}
|
||||
return handleTokenResult(result, k);
|
||||
}
|
||||
|
||||
async function authUser(keys, name, interactive = false, hooks = null) {
|
||||
await require(['/vendor/webext-launch-web-auth-flow/webext-launch-web-auth-flow']);
|
||||
/* global webextLaunchWebAuthFlow */
|
||||
const provider = AUTH[name];
|
||||
const state = Math.random().toFixed(8).slice(2);
|
||||
const query = {
|
||||
response_type: provider.flow,
|
||||
client_id: provider.clientId,
|
||||
redirect_uri: provider.redirect_uri || DEFAULT_REDIRECT_URI,
|
||||
state,
|
||||
};
|
||||
if (provider.scopes) {
|
||||
query.scope = provider.scopes.join(' ');
|
||||
}
|
||||
if (provider.authQuery) {
|
||||
Object.assign(query, provider.authQuery);
|
||||
}
|
||||
if (alwaysUseTab == null) {
|
||||
alwaysUseTab = await detectVivaldiWebRequestBug();
|
||||
}
|
||||
if (hooks) hooks.query(query);
|
||||
const url = `${provider.authURL}?${new URLSearchParams(query)}`;
|
||||
const width = Math.min(screen.availWidth - 100, 800);
|
||||
const height = Math.min(screen.availHeight - 100, 800);
|
||||
const wnd = !alwaysUseTab && await browser.windows.getLastFocused();
|
||||
const finalUrl = await webextLaunchWebAuthFlow({
|
||||
url,
|
||||
alwaysUseTab,
|
||||
interactive,
|
||||
redirect_uri: query.redirect_uri,
|
||||
windowOptions: wnd && Object.assign({
|
||||
state: 'normal',
|
||||
width,
|
||||
height,
|
||||
}, wnd.state !== 'minimized' && {
|
||||
// Center the popup to the current window
|
||||
top: Math.ceil(wnd.top + (wnd.height - width) / 2),
|
||||
left: Math.ceil(wnd.left + (wnd.width - width) / 2),
|
||||
}),
|
||||
});
|
||||
const params = new URLSearchParams(
|
||||
provider.flow === 'token' ?
|
||||
new URL(finalUrl).hash.slice(1) :
|
||||
new URL(finalUrl).search.slice(1)
|
||||
);
|
||||
if (params.get('state') !== state) {
|
||||
throw new TokenError(name, `Unexpected state: ${params.get('state')}, expected: ${state}`);
|
||||
}
|
||||
let result;
|
||||
if (provider.flow === 'token') {
|
||||
const obj = {};
|
||||
for (const [key, value] of params) {
|
||||
obj[key] = value;
|
||||
}
|
||||
result = obj;
|
||||
} else {
|
||||
const code = params.get('code');
|
||||
const body = {
|
||||
code,
|
||||
grant_type: 'authorization_code',
|
||||
client_id: provider.clientId,
|
||||
redirect_uri: query.redirect_uri,
|
||||
state,
|
||||
};
|
||||
if (provider.clientSecret) {
|
||||
body.client_secret = provider.clientSecret;
|
||||
}
|
||||
result = await postQuery(provider.tokenURL, body);
|
||||
}
|
||||
return handleTokenResult(result, keys);
|
||||
}
|
||||
|
||||
async function handleTokenResult(result, k) {
|
||||
await chromeLocal.set({
|
||||
[k.TOKEN]: result.access_token,
|
||||
[k.EXPIRE]: result.expires_in
|
||||
? Date.now() + (result.expires_in - NETWORK_LATENCY) * 1000
|
||||
: undefined,
|
||||
[k.REFRESH]: result.refresh_token,
|
||||
});
|
||||
return result.access_token;
|
||||
}
|
||||
|
||||
async function postQuery(url, body) {
|
||||
const options = {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
},
|
||||
body: body ? new URLSearchParams(body) : null,
|
||||
};
|
||||
const r = await fetch(url, options);
|
||||
if (r.ok) {
|
||||
return r.json();
|
||||
}
|
||||
const text = await r.text();
|
||||
const err = new Error(`Failed to fetch (${r.status}): ${text}`);
|
||||
err.code = r.status;
|
||||
throw err;
|
||||
}
|
||||
|
||||
async function detectVivaldiWebRequestBug() {
|
||||
// Workaround for https://github.com/openstyles/stylus/issues/1182
|
||||
// Note that modern Vivaldi isn't exposed in `navigator.userAgent` but it adds `extData` to tabs
|
||||
const anyTab = await getActiveTab() || (await browser.tabs.query({}))[0];
|
||||
if (anyTab && !(anyTab.extData || anyTab.vivExtData)) {
|
||||
return false;
|
||||
}
|
||||
let bugged = true;
|
||||
const TEST_URL = chrome.runtime.getURL('manifest.json');
|
||||
const check = ({url}) => {
|
||||
bugged = url !== TEST_URL;
|
||||
};
|
||||
chrome.webRequest.onBeforeRequest.addListener(check, {urls: [TEST_URL], types: ['main_frame']});
|
||||
const {tabs: [tab]} = await browser.windows.create({
|
||||
type: 'popup',
|
||||
state: 'minimized',
|
||||
url: TEST_URL,
|
||||
});
|
||||
await waitForTabUrl(tab);
|
||||
chrome.windows.remove(tab.windowId);
|
||||
chrome.webRequest.onBeforeRequest.removeListener(check);
|
||||
return bugged;
|
||||
}
|
||||
})();
|
348
background/update-manager.js
Normal file
348
background/update-manager.js
Normal file
|
@ -0,0 +1,348 @@
|
|||
/* global API */// msg.js
|
||||
/* global RX_META URLS debounce deepMerge download ignoreChromeError */// toolbox.js
|
||||
/* global calcStyleDigest styleSectionsEqual */ // sections-util.js
|
||||
/* global chromeLocal */// storage-util.js
|
||||
/* global compareVersion */// cmpver.js
|
||||
/* global db */
|
||||
/* global prefs */
|
||||
'use strict';
|
||||
|
||||
/* exported updateMan */
|
||||
const updateMan = (() => {
|
||||
const STATES = /** @namespace UpdaterStates */ {
|
||||
UPDATED: 'updated',
|
||||
SKIPPED: 'skipped',
|
||||
UNREACHABLE: 'server unreachable',
|
||||
// details for SKIPPED status
|
||||
EDITED: 'locally edited',
|
||||
MAYBE_EDITED: 'may be locally edited',
|
||||
SAME_MD5: 'up-to-date: MD5 is unchanged',
|
||||
SAME_CODE: 'up-to-date: code sections are unchanged',
|
||||
SAME_VERSION: 'up-to-date: version is unchanged',
|
||||
ERROR_MD5: 'error: MD5 is invalid',
|
||||
ERROR_JSON: 'error: JSON is invalid',
|
||||
ERROR_VERSION: 'error: version is older than installed style',
|
||||
};
|
||||
const USO_STYLES_API = `${URLS.uso}api/v1/styles/`;
|
||||
const RH_ETAG = {responseHeaders: ['etag']}; // a hashsum of file contents
|
||||
const RX_DATE2VER = new RegExp([
|
||||
/^(\d{4})/,
|
||||
/(0[1-9]|1(?:0|[12](?=\d\d))?|[2-9])/, // in ambiguous cases like yyyy123 the month will be 1
|
||||
/(0[1-9]|[1-2][0-9]?|3[0-1]?|[4-9])/,
|
||||
/\.([01][0-9]?|2[0-3]?|[3-9])/,
|
||||
/\.([0-5][0-9]?|[6-9])$/,
|
||||
].map(rx => rx.source).join(''));
|
||||
const ALARM_NAME = 'scheduledUpdate';
|
||||
const MIN_INTERVAL_MS = 60e3;
|
||||
const RETRY_ERRORS = [
|
||||
503, // service unavailable
|
||||
429, // too many requests
|
||||
];
|
||||
let usoReferers = 0;
|
||||
let lastUpdateTime;
|
||||
let checkingAll = false;
|
||||
let logQueue = [];
|
||||
let logLastWriteTime = 0;
|
||||
|
||||
chromeLocal.getValue('lastUpdateTime').then(val => {
|
||||
lastUpdateTime = val || Date.now();
|
||||
prefs.subscribe('updateInterval', schedule, {runNow: true});
|
||||
chrome.alarms.onAlarm.addListener(onAlarm);
|
||||
});
|
||||
|
||||
return {
|
||||
checkAllStyles,
|
||||
checkStyle,
|
||||
getStates: () => STATES,
|
||||
};
|
||||
|
||||
async function checkAllStyles({
|
||||
save = true,
|
||||
ignoreDigest,
|
||||
observe,
|
||||
} = {}) {
|
||||
resetInterval();
|
||||
checkingAll = true;
|
||||
const port = observe && chrome.runtime.connect({name: 'updater'});
|
||||
const styles = (await API.styles.getAll())
|
||||
.filter(style => style.updateUrl && style.updatable !== false);
|
||||
if (port) port.postMessage({count: styles.length});
|
||||
log('');
|
||||
log(`${save ? 'Scheduled' : 'Manual'} update check for ${styles.length} styles`);
|
||||
await Promise.all(
|
||||
styles.map(style =>
|
||||
checkStyle({style, port, save, ignoreDigest})));
|
||||
if (port) port.postMessage({done: true});
|
||||
if (port) port.disconnect();
|
||||
log('');
|
||||
checkingAll = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {{
|
||||
id?: number,
|
||||
style?: StyleObj,
|
||||
port?: chrome.runtime.Port,
|
||||
save?: boolean,
|
||||
ignoreDigest?: boolean,
|
||||
}} opts
|
||||
* @returns {{
|
||||
style: StyleObj,
|
||||
updated?: boolean,
|
||||
error?: any,
|
||||
STATES: UpdaterStates,
|
||||
}}
|
||||
|
||||
Original style digests are calculated in these cases:
|
||||
* style is installed or updated from server
|
||||
* non-usercss style is checked for an update and styleSectionsEqual considers it unchanged
|
||||
|
||||
Update check proceeds in these cases:
|
||||
* style has the original digest and it's equal to the current digest
|
||||
* [ignoreDigest: true] style doesn't yet have the original digest but we ignore it
|
||||
* [ignoreDigest: none/false] style doesn't yet have the original digest
|
||||
so we compare the code to the server code and if it's the same we save the digest,
|
||||
otherwise we skip the style and report MAYBE_EDITED status
|
||||
|
||||
'ignoreDigest' option is set on the second manual individual update check on the manage page.
|
||||
*/
|
||||
async function checkStyle(opts) {
|
||||
let {id} = opts;
|
||||
const {
|
||||
style = await API.styles.get(id),
|
||||
ignoreDigest,
|
||||
port,
|
||||
save,
|
||||
} = opts;
|
||||
if (!id) id = style.id;
|
||||
const {md5Url} = style;
|
||||
let {usercssData: ucd, updateUrl} = style;
|
||||
let res, state;
|
||||
try {
|
||||
await checkIfEdited();
|
||||
res = {
|
||||
style: await (ucd && !md5Url ? updateUsercss : updateUSO)().then(maybeSave),
|
||||
updated: true,
|
||||
};
|
||||
state = STATES.UPDATED;
|
||||
} catch (err) {
|
||||
const error = err === 0 && STATES.UNREACHABLE ||
|
||||
err && err.message ||
|
||||
err;
|
||||
res = {error, style, STATES};
|
||||
state = `${STATES.SKIPPED} (${Array.isArray(err) ? err[0].message : error})`;
|
||||
}
|
||||
log(`${state} #${id} ${style.customName || style.name}`);
|
||||
if (port) port.postMessage(res);
|
||||
return res;
|
||||
|
||||
async function checkIfEdited() {
|
||||
if (!ignoreDigest &&
|
||||
style.originalDigest &&
|
||||
style.originalDigest !== await calcStyleDigest(style)) {
|
||||
return Promise.reject(STATES.EDITED);
|
||||
}
|
||||
}
|
||||
|
||||
async function updateUSO() {
|
||||
const md5 = await tryDownload(md5Url);
|
||||
if (!md5 || md5.length !== 32) {
|
||||
return Promise.reject(STATES.ERROR_MD5);
|
||||
}
|
||||
if (md5 === style.originalMd5 && style.originalDigest && !ignoreDigest) {
|
||||
return Promise.reject(STATES.SAME_MD5);
|
||||
}
|
||||
let varsUrl = '';
|
||||
if (!ucd) {
|
||||
ucd = {};
|
||||
varsUrl = updateUrl;
|
||||
updateUrl = style.updateUrl = `${USO_STYLES_API}${md5Url.match(/\/(\d+)/)[1]}`;
|
||||
}
|
||||
usoSpooferStart();
|
||||
let json;
|
||||
try {
|
||||
json = await tryDownload(style.updateUrl, {responseType: 'json'});
|
||||
json = await updateUsercss(json.css) ||
|
||||
(await API.uso.toUsercss(json)).style;
|
||||
if (varsUrl) await API.uso.useVarsUrl(json, varsUrl);
|
||||
} finally {
|
||||
usoSpooferStop();
|
||||
}
|
||||
// USO may not provide a correctly updated originalMd5 (#555)
|
||||
json.originalMd5 = md5;
|
||||
return json;
|
||||
}
|
||||
|
||||
async function updateUsercss(css) {
|
||||
let oldVer = ucd.version;
|
||||
let {etag: oldEtag, updateUrl} = style;
|
||||
const m2 = (css || URLS.extractUsoArchiveId(updateUrl)) &&
|
||||
await getUsoEmbeddedMeta(css);
|
||||
if (m2 && m2.updateUrl) {
|
||||
updateUrl = m2.updateUrl;
|
||||
oldVer = m2.usercssData.version || '0';
|
||||
oldEtag = '';
|
||||
} else if (css) {
|
||||
return;
|
||||
}
|
||||
if (oldEtag && oldEtag === await downloadEtag()) {
|
||||
return Promise.reject(STATES.SAME_CODE);
|
||||
}
|
||||
// TODO: when sourceCode is > 100kB use http range request(s) for version check
|
||||
const {headers: {etag}, response} = await tryDownload(updateUrl, RH_ETAG);
|
||||
const json = await API.usercss.buildMeta({sourceCode: response, etag, updateUrl});
|
||||
const delta = compareVersion(json.usercssData.version, oldVer);
|
||||
let err;
|
||||
if (!delta && !ignoreDigest) {
|
||||
// re-install is invalid in a soft upgrade
|
||||
err = response === style.sourceCode
|
||||
? STATES.SAME_CODE
|
||||
: !URLS.isLocalhost(updateUrl) && STATES.SAME_VERSION;
|
||||
}
|
||||
if (delta < 0) {
|
||||
// downgrade is always invalid
|
||||
err = STATES.ERROR_VERSION;
|
||||
}
|
||||
if (err && etag && !style.etag) {
|
||||
// first check of ETAG, gonna write it directly to DB as it's too trivial to sync or announce
|
||||
style.etag = etag;
|
||||
await db.styles.put(style);
|
||||
}
|
||||
return err
|
||||
? Promise.reject(err)
|
||||
: API.usercss.buildCode(json);
|
||||
}
|
||||
|
||||
async function maybeSave(json) {
|
||||
json.id = id;
|
||||
// keep current state
|
||||
delete json.customName;
|
||||
delete json.enabled;
|
||||
const newStyle = Object.assign({}, style, json);
|
||||
newStyle.updateDate = getDateFromVer(newStyle) || Date.now();
|
||||
// update digest even if save === false as there might be just a space added etc.
|
||||
if (!ucd && styleSectionsEqual(json, style)) {
|
||||
style.originalDigest = (await API.styles.install(newStyle)).originalDigest;
|
||||
return Promise.reject(STATES.SAME_CODE);
|
||||
}
|
||||
if (!style.originalDigest && !ignoreDigest) {
|
||||
return Promise.reject(STATES.MAYBE_EDITED);
|
||||
}
|
||||
return !save ? newStyle :
|
||||
(ucd ? API.usercss.install : API.styles.install)(newStyle);
|
||||
}
|
||||
|
||||
async function tryDownload(url, params) {
|
||||
let {retryDelay = 1000} = opts;
|
||||
while (true) {
|
||||
try {
|
||||
params = deepMerge(params || {}, {headers: {'Cache-Control': 'no-cache'}});
|
||||
return await download(url, params);
|
||||
} catch (code) {
|
||||
if (!RETRY_ERRORS.includes(code) ||
|
||||
retryDelay > MIN_INTERVAL_MS) {
|
||||
return Promise.reject(code);
|
||||
}
|
||||
}
|
||||
retryDelay *= 1.25;
|
||||
await new Promise(resolve => setTimeout(resolve, retryDelay));
|
||||
}
|
||||
}
|
||||
|
||||
async function downloadEtag() {
|
||||
const opts = Object.assign({method: 'head'}, RH_ETAG);
|
||||
const req = await tryDownload(style.updateUrl, opts);
|
||||
return req.headers.etag;
|
||||
}
|
||||
|
||||
function getDateFromVer(style) {
|
||||
const m = RX_DATE2VER.exec((style.usercssData || {}).version);
|
||||
if (m) {
|
||||
m[2]--; // month is 0-based in `Date` constructor
|
||||
return new Date(...m.slice(1)).getTime();
|
||||
}
|
||||
}
|
||||
|
||||
/** UserCSS metadata may be embedded in the original USO style so let's use its updateURL */
|
||||
function getUsoEmbeddedMeta(code = style.sourceCode) {
|
||||
const isRaw = arguments[0];
|
||||
const m = code.includes('@updateURL') && (isRaw ? code : code.replace(RX_META, '')).match(RX_META);
|
||||
return m && API.usercss.buildMeta({sourceCode: m[0]}).catch(() => null);
|
||||
}
|
||||
}
|
||||
|
||||
function schedule() {
|
||||
const interval = prefs.get('updateInterval') * 60 * 60 * 1000;
|
||||
if (interval > 0) {
|
||||
const elapsed = Math.max(0, Date.now() - lastUpdateTime);
|
||||
chrome.alarms.create(ALARM_NAME, {
|
||||
when: Date.now() + Math.max(MIN_INTERVAL_MS, interval - elapsed),
|
||||
});
|
||||
} else {
|
||||
chrome.alarms.clear(ALARM_NAME, ignoreChromeError);
|
||||
}
|
||||
}
|
||||
|
||||
function onAlarm({name}) {
|
||||
if (name === ALARM_NAME) checkAllStyles();
|
||||
}
|
||||
|
||||
function resetInterval() {
|
||||
chromeLocal.setValue('lastUpdateTime', lastUpdateTime = Date.now());
|
||||
schedule();
|
||||
}
|
||||
|
||||
function log(text) {
|
||||
logQueue.push({text, time: new Date().toLocaleString()});
|
||||
debounce(flushQueue, text && checkingAll ? 1000 : 0);
|
||||
}
|
||||
|
||||
async function flushQueue(lines) {
|
||||
if (!lines) {
|
||||
flushQueue(await chromeLocal.getValue('updateLog') || []);
|
||||
return;
|
||||
}
|
||||
const time = Date.now() - logLastWriteTime > 11e3 ?
|
||||
logQueue[0].time + ' ' :
|
||||
'';
|
||||
if (logQueue[0] && !logQueue[0].text) {
|
||||
logQueue.shift();
|
||||
if (lines[lines.length - 1]) lines.push('');
|
||||
}
|
||||
lines.splice(0, lines.length - 1000);
|
||||
lines.push(time + (logQueue[0] && logQueue[0].text || ''));
|
||||
lines.push(...logQueue.slice(1).map(item => item.text));
|
||||
|
||||
chromeLocal.setValue('updateLog', lines);
|
||||
logLastWriteTime = Date.now();
|
||||
logQueue = [];
|
||||
}
|
||||
|
||||
function usoSpooferStart() {
|
||||
if (++usoReferers === 1) {
|
||||
chrome.webRequest.onBeforeSendHeaders.addListener(
|
||||
usoSpoofer,
|
||||
{types: ['xmlhttprequest'], urls: [USO_STYLES_API + '*']},
|
||||
['blocking', 'requestHeaders', chrome.webRequest.OnBeforeSendHeadersOptions.EXTRA_HEADERS]
|
||||
.filter(Boolean));
|
||||
}
|
||||
}
|
||||
|
||||
function usoSpooferStop() {
|
||||
if (--usoReferers <= 0) {
|
||||
usoReferers = 0;
|
||||
chrome.webRequest.onBeforeSendHeaders.removeListener(usoSpoofer);
|
||||
}
|
||||
}
|
||||
|
||||
/** @param {chrome.webRequest.WebResponseHeadersDetails | browser.webRequest._OnBeforeSendHeadersDetails} info */
|
||||
function usoSpoofer(info) {
|
||||
if (info.tabId < 0 && URLS.ownOrigin.startsWith(info.initiator || info.originUrl || '')) {
|
||||
const {requestHeaders: hh} = info;
|
||||
const i = (hh.findIndex(h => /^referer$/i.test(h.name)) + 1 || hh.push({})) - 1;
|
||||
hh[i].name = 'referer';
|
||||
hh[i].value = URLS.uso;
|
||||
return {requestHeaders: hh};
|
||||
}
|
||||
}
|
||||
})();
|
|
@ -1,202 +0,0 @@
|
|||
/* global getStyles, saveStyle, styleSectionsEqual, chromeLocal */
|
||||
/* global calcStyleDigest */
|
||||
/* global usercss semverCompare usercssHelper */
|
||||
'use strict';
|
||||
|
||||
// eslint-disable-next-line no-var
|
||||
var updater = {
|
||||
|
||||
COUNT: 'count',
|
||||
UPDATED: 'updated',
|
||||
SKIPPED: 'skipped',
|
||||
DONE: 'done',
|
||||
|
||||
// details for SKIPPED status
|
||||
EDITED: 'locally edited',
|
||||
MAYBE_EDITED: 'may be locally edited',
|
||||
SAME_MD5: 'up-to-date: MD5 is unchanged',
|
||||
SAME_CODE: 'up-to-date: code sections are unchanged',
|
||||
SAME_VERSION: 'up-to-date: version is unchanged',
|
||||
ERROR_MD5: 'error: MD5 is invalid',
|
||||
ERROR_JSON: 'error: JSON is invalid',
|
||||
ERROR_VERSION: 'error: version is older than installed style',
|
||||
|
||||
lastUpdateTime: parseInt(localStorage.lastUpdateTime) || Date.now(),
|
||||
|
||||
checkAllStyles({observer = () => {}, save = true, ignoreDigest} = {}) {
|
||||
updater.resetInterval();
|
||||
updater.checkAllStyles.running = true;
|
||||
return getStyles({}).then(styles => {
|
||||
styles = styles.filter(style => style.updateUrl);
|
||||
observer(updater.COUNT, styles.length);
|
||||
updater.log('');
|
||||
updater.log(`${save ? 'Scheduled' : 'Manual'} update check for ${styles.length} styles`);
|
||||
return Promise.all(
|
||||
styles.map(style =>
|
||||
updater.checkStyle({style, observer, save, ignoreDigest})));
|
||||
}).then(() => {
|
||||
observer(updater.DONE);
|
||||
updater.log('');
|
||||
updater.checkAllStyles.running = false;
|
||||
});
|
||||
},
|
||||
|
||||
checkStyle({style, observer = () => {}, save = true, ignoreDigest}) {
|
||||
/*
|
||||
Original style digests are calculated in these cases:
|
||||
* style is installed or updated from server
|
||||
* style is checked for an update and its code is equal to the server code
|
||||
|
||||
Update check proceeds in these cases:
|
||||
* style has the original digest and it's equal to the current digest
|
||||
* [ignoreDigest: true] style doesn't yet have the original digest but we ignore it
|
||||
* [ignoreDigest: none/false] style doesn't yet have the original digest
|
||||
so we compare the code to the server code and if it's the same we save the digest,
|
||||
otherwise we skip the style and report MAYBE_EDITED status
|
||||
|
||||
'ignoreDigest' option is set on the second manual individual update check on the manage page.
|
||||
*/
|
||||
const maybeUpdate = style.usercssData ? maybeUpdateUsercss : maybeUpdateUSO;
|
||||
return (ignoreDigest ? Promise.resolve() : calcStyleDigest(style))
|
||||
.then(checkIfEdited)
|
||||
.then(maybeUpdate)
|
||||
.then(maybeValidate)
|
||||
.then(maybeSave)
|
||||
.then(saved => {
|
||||
observer(updater.UPDATED, saved);
|
||||
updater.log(updater.UPDATED + ` #${saved.id} ${saved.name}`);
|
||||
})
|
||||
.catch(err => {
|
||||
observer(updater.SKIPPED, style, err);
|
||||
err = err === 0 ? 'server unreachable' : err;
|
||||
updater.log(updater.SKIPPED + ` (${err}) #${style.id} ${style.name}`);
|
||||
});
|
||||
|
||||
function checkIfEdited(digest) {
|
||||
if (ignoreDigest) {
|
||||
return;
|
||||
}
|
||||
if (style.originalDigest && style.originalDigest !== digest) {
|
||||
return Promise.reject(updater.EDITED);
|
||||
}
|
||||
}
|
||||
|
||||
function maybeUpdateUSO() {
|
||||
return download(style.md5Url).then(md5 => {
|
||||
if (!md5 || md5.length !== 32) {
|
||||
return Promise.reject(updater.ERROR_MD5);
|
||||
}
|
||||
if (md5 === style.originalMd5 && style.originalDigest && !ignoreDigest) {
|
||||
return Promise.reject(updater.SAME_MD5);
|
||||
}
|
||||
return download(style.updateUrl)
|
||||
.then(text => tryJSONparse(text));
|
||||
});
|
||||
}
|
||||
|
||||
function maybeUpdateUsercss() {
|
||||
return download(style.updateUrl).then(text => {
|
||||
const json = usercss.buildMeta(text);
|
||||
const {usercssData: {version}} = style;
|
||||
const {usercssData: {version: newVersion}} = json;
|
||||
switch (Math.sign(semverCompare(version, newVersion))) {
|
||||
case 0:
|
||||
// re-install is invalid in a soft upgrade
|
||||
if (!ignoreDigest) {
|
||||
return Promise.reject(updater.SAME_VERSION);
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
// downgrade is always invalid
|
||||
return Promise.reject(updater.ERROR_VERSION);
|
||||
}
|
||||
return usercss.buildCode(json);
|
||||
});
|
||||
}
|
||||
|
||||
function maybeValidate(json) {
|
||||
if (json.usercssData) {
|
||||
// usercss is already validated while building
|
||||
return json;
|
||||
}
|
||||
if (!styleJSONseemsValid(json)) {
|
||||
return Promise.reject(updater.ERROR_JSON);
|
||||
}
|
||||
return json;
|
||||
}
|
||||
|
||||
function maybeSave(json) {
|
||||
json.id = style.id;
|
||||
if (styleSectionsEqual(json, style)) {
|
||||
// JSONs may have different order of items even if sections are effectively equal
|
||||
// so we'll update the digest anyway
|
||||
// always update digest even if (save === false)
|
||||
saveStyle(Object.assign(json, {reason: 'update-digest'}));
|
||||
return Promise.reject(updater.SAME_CODE);
|
||||
} else if (!style.originalDigest && !ignoreDigest) {
|
||||
return Promise.reject(updater.MAYBE_EDITED);
|
||||
}
|
||||
if (!save) {
|
||||
return json;
|
||||
}
|
||||
json.reason = 'update';
|
||||
if (json.usercssData) {
|
||||
return usercssHelper.save(json);
|
||||
}
|
||||
json.name = null; // keep local name customizations
|
||||
return saveStyle(json);
|
||||
}
|
||||
|
||||
function styleJSONseemsValid(json) {
|
||||
return json
|
||||
&& json.sections
|
||||
&& json.sections.length
|
||||
&& typeof json.sections.every === 'function'
|
||||
&& typeof json.sections[0].code === 'string';
|
||||
}
|
||||
},
|
||||
|
||||
schedule() {
|
||||
const interval = prefs.get('updateInterval') * 60 * 60 * 1000;
|
||||
if (interval) {
|
||||
const elapsed = Math.max(0, Date.now() - updater.lastUpdateTime);
|
||||
debounce(updater.checkAllStyles, Math.max(10e3, interval - elapsed));
|
||||
} else {
|
||||
debounce.unregister(updater.checkAllStyles);
|
||||
}
|
||||
},
|
||||
|
||||
resetInterval() {
|
||||
localStorage.lastUpdateTime = updater.lastUpdateTime = Date.now();
|
||||
updater.schedule();
|
||||
},
|
||||
|
||||
log: (() => {
|
||||
let queue = [];
|
||||
let lastWriteTime = 0;
|
||||
return text => {
|
||||
queue.push({text, time: new Date().toLocaleString()});
|
||||
debounce(flushQueue, text && updater.checkAllStyles.running ? 1000 : 0);
|
||||
};
|
||||
function flushQueue() {
|
||||
chromeLocal.getValue('updateLog').then((lines = []) => {
|
||||
const time = Date.now() - lastWriteTime > 11e3 ? queue[0].time + ' ' : '';
|
||||
if (!queue[0].text) {
|
||||
queue.shift();
|
||||
if (lines[lines.length - 1]) {
|
||||
lines.push('');
|
||||
}
|
||||
}
|
||||
lines.splice(0, lines.length - 1000);
|
||||
lines.push(time + queue[0].text);
|
||||
lines.push(...queue.slice(1).map(item => item.text));
|
||||
chromeLocal.setValue('updateLog', lines);
|
||||
lastWriteTime = Date.now();
|
||||
queue = [];
|
||||
});
|
||||
}
|
||||
})(),
|
||||
};
|
||||
|
||||
updater.schedule();
|
||||
prefs.subscribe(['updateInterval'], updater.schedule);
|
|
@ -1,93 +0,0 @@
|
|||
/* global usercss saveStyle getStyles */
|
||||
'use strict';
|
||||
|
||||
// eslint-disable-next-line no-var
|
||||
var usercssHelper = (() => {
|
||||
function buildMeta(style) {
|
||||
if (style.usercssData) {
|
||||
return Promise.resolve(style);
|
||||
}
|
||||
try {
|
||||
const {sourceCode} = style;
|
||||
// allow sourceCode to be normalized
|
||||
delete style.sourceCode;
|
||||
return Promise.resolve(Object.assign(usercss.buildMeta(sourceCode), style));
|
||||
} catch (e) {
|
||||
return Promise.reject(e);
|
||||
}
|
||||
}
|
||||
|
||||
function buildCode(style) {
|
||||
return usercss.buildCode(style);
|
||||
}
|
||||
|
||||
function wrapReject(pending) {
|
||||
return pending.then(result => ({success: true, result}))
|
||||
.catch(err => ({success: false, result: err.message || String(err)}));
|
||||
}
|
||||
|
||||
// Parse the source and find the duplication
|
||||
function build({sourceCode, checkDup = false}, noReject) {
|
||||
const pending = buildMeta({sourceCode})
|
||||
.then(style => Promise.all([
|
||||
buildCode(style),
|
||||
checkDup && findDup(style)
|
||||
]))
|
||||
.then(([style, dup]) => ({style, dup}));
|
||||
|
||||
return noReject ? wrapReject(pending) : pending;
|
||||
}
|
||||
|
||||
function save(style, noReject) {
|
||||
const pending = buildMeta(style)
|
||||
.then(assignVars)
|
||||
.then(buildCode)
|
||||
.then(saveStyle);
|
||||
|
||||
return noReject ? wrapReject(pending) : pending;
|
||||
|
||||
function assignVars(style) {
|
||||
if (style.reason === 'config' && style.id) {
|
||||
return style;
|
||||
}
|
||||
return findDup(style).then(dup => {
|
||||
if (dup) {
|
||||
style.id = dup.id;
|
||||
if (style.reason !== 'config') {
|
||||
// preserve style.vars during update
|
||||
usercss.assignVars(style, dup);
|
||||
}
|
||||
}
|
||||
return style;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function findDup(style) {
|
||||
if (style.id) {
|
||||
return getStyles({id: style.id}).then(s => s[0]);
|
||||
}
|
||||
return getStyles().then(styles =>
|
||||
styles.find(target => {
|
||||
if (!target.usercssData) {
|
||||
return false;
|
||||
}
|
||||
return target.usercssData.name === style.usercssData.name &&
|
||||
target.usercssData.namespace === style.usercssData.namespace;
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
function openInstallPage(tab, request) {
|
||||
const url = '/install-usercss.html' +
|
||||
'?updateUrl=' + encodeURIComponent(request.updateUrl) +
|
||||
'&tabId=' + tab.id;
|
||||
return wrapReject(openURL({
|
||||
url,
|
||||
index: tab.index + 1,
|
||||
openerTabId: tab.id,
|
||||
}));
|
||||
}
|
||||
|
||||
return {build, save, findDup, openInstallPage};
|
||||
})();
|
141
background/usercss-install-helper.js
Normal file
141
background/usercss-install-helper.js
Normal file
|
@ -0,0 +1,141 @@
|
|||
/* global RX_META URLS download openURL */// toolbox.js
|
||||
/* global addAPI bgReady */// common.js
|
||||
/* global tabMan */// msg.js
|
||||
'use strict';
|
||||
|
||||
bgReady.all.then(() => {
|
||||
const installCodeCache = {};
|
||||
|
||||
addAPI(/** @namespace API */ {
|
||||
usercss: {
|
||||
getInstallCode(url) {
|
||||
// when the installer tab is reloaded after the cache is expired, this will throw intentionally
|
||||
const {code, timer} = installCodeCache[url];
|
||||
clearInstallCode(url);
|
||||
clearTimeout(timer);
|
||||
return code;
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
// `glob`: pathname match pattern for webRequest
|
||||
// `rx`: pathname regex to verify the URL really looks like a raw usercss
|
||||
const maybeDistro = {
|
||||
// https://github.com/StylishThemes/GitHub-Dark/raw/master/github-dark.user.css
|
||||
'github.com': {
|
||||
glob: '/*/raw/*',
|
||||
rx: /^\/[^/]+\/[^/]+\/raw\/[^/]+\/[^/]+?\.user\.(css|styl)$/,
|
||||
},
|
||||
// https://raw.githubusercontent.com/StylishThemes/GitHub-Dark/master/github-dark.user.css
|
||||
'raw.githubusercontent.com': {
|
||||
glob: '/*',
|
||||
rx: /^(\/[^/]+?){4}\.user\.(css|styl)$/,
|
||||
},
|
||||
};
|
||||
|
||||
chrome.webRequest.onBeforeSendHeaders.addListener(maybeInstallFromDistro, {
|
||||
urls: [
|
||||
URLS.usw + 'api/style/*.user.css',
|
||||
...URLS.usoArchiveRaw.map(s => s + 'usercss/*.user.css'),
|
||||
...['greasy', 'sleazy'].map(s => `*://${s}fork.org/scripts/*/code/*.user.css`),
|
||||
...[].concat(
|
||||
...Object.entries(maybeDistro)
|
||||
.map(([host, {glob}]) => makeUsercssGlobs(host, glob))),
|
||||
],
|
||||
types: ['main_frame'],
|
||||
}, ['blocking']);
|
||||
|
||||
chrome.webRequest.onHeadersReceived.addListener(rememberContentType, {
|
||||
urls: makeUsercssGlobs('*', '/*'),
|
||||
types: ['main_frame'],
|
||||
}, ['responseHeaders']);
|
||||
|
||||
tabMan.onUpdate(maybeInstall);
|
||||
|
||||
function clearInstallCode(url) {
|
||||
return delete installCodeCache[url];
|
||||
}
|
||||
|
||||
/** Sites may be using custom types like text/stylus so this coarse filter only excludes html */
|
||||
function isContentTypeText(type) {
|
||||
return /^text\/(?!html)/i.test(type);
|
||||
}
|
||||
|
||||
// in Firefox we have to use a content script to read file://
|
||||
async function loadFromFile(tabId) {
|
||||
return (await browser.tabs.executeScript(tabId, {file: '/content/install-hook-usercss.js'}))[0];
|
||||
}
|
||||
|
||||
async function loadFromUrl(tabId, url) {
|
||||
return (
|
||||
url.startsWith('file:') ||
|
||||
tabMan.get(tabId, isContentTypeText.name) ||
|
||||
isContentTypeText((await fetch(url, {method: 'HEAD'})).headers.get('content-type'))
|
||||
) && download(url);
|
||||
}
|
||||
|
||||
function makeInstallerUrl(url) {
|
||||
return `${URLS.installUsercss}?updateUrl=${encodeURIComponent(url)}`;
|
||||
}
|
||||
|
||||
function makeUsercssGlobs(host, path) {
|
||||
return '%css,%css?*,%styl,%styl?*'.replace(/%/g, `*://${host}${path}.user.`).split(',');
|
||||
}
|
||||
|
||||
async function maybeInstall({tabId, url, oldUrl = ''}) {
|
||||
if (url.includes('.user.') &&
|
||||
/^(https?|file|ftps?):/.test(url) &&
|
||||
/\.user\.(css|styl)$/.test(url.split(/[#?]/, 1)[0]) &&
|
||||
!oldUrl.startsWith(makeInstallerUrl(url))) {
|
||||
const inTab = url.startsWith('file:') && !chrome.app;
|
||||
const code = await (inTab ? loadFromFile : loadFromUrl)(tabId, url);
|
||||
if (!/^\s*</.test(code) && RX_META.test(code)) {
|
||||
await openInstallerPage(tabId, url, {code, inTab});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Faster installation on known distribution sites to avoid flicker of css text */
|
||||
function maybeInstallFromDistro({tabId, url}) {
|
||||
const u = new URL(url);
|
||||
const m = maybeDistro[u.hostname];
|
||||
if (!m || m.rx.test(u.pathname)) {
|
||||
openInstallerPage(tabId, url, {});
|
||||
// Silently suppress navigation.
|
||||
// Don't redirect to the install URL as it'll flash the text!
|
||||
return {cancel: true};
|
||||
}
|
||||
}
|
||||
|
||||
async function openInstallerPage(tabId, url, {code, inTab} = {}) {
|
||||
const newUrl = makeInstallerUrl(url);
|
||||
if (inTab) {
|
||||
const tab = await browser.tabs.get(tabId);
|
||||
return openURL({
|
||||
url: `${newUrl}&tabId=${tabId}`,
|
||||
active: tab.active,
|
||||
index: tab.index + 1,
|
||||
openerTabId: tabId,
|
||||
currentWindow: null,
|
||||
});
|
||||
}
|
||||
const timer = setTimeout(clearInstallCode, 10e3, url);
|
||||
installCodeCache[url] = {code, timer};
|
||||
try {
|
||||
await browser.tabs.update(tabId, {url: newUrl});
|
||||
} catch (err) {
|
||||
// FIXME: remove this when kiwi supports tabs.update
|
||||
// https://github.com/openstyles/stylus/issues/1367
|
||||
if (/Tabs cannot be edited right now/i.test(err.message)) {
|
||||
return browser.tabs.create({url: newUrl});
|
||||
}
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
/** Remember Content-Type to avoid wasting time to re-fetch in loadFromUrl **/
|
||||
function rememberContentType({tabId, responseHeaders}) {
|
||||
const h = responseHeaders.find(h => h.name.toLowerCase() === 'content-type');
|
||||
tabMan.set(tabId, isContentTypeText.name, h && isContentTypeText(h.value) || undefined);
|
||||
}
|
||||
});
|
163
background/usercss-manager.js
Normal file
163
background/usercss-manager.js
Normal file
|
@ -0,0 +1,163 @@
|
|||
/* global API */// msg.js
|
||||
/* global RX_META deepCopy download */// toolbox.js
|
||||
'use strict';
|
||||
|
||||
const usercssMan = {
|
||||
|
||||
GLOBAL_META: Object.entries({
|
||||
author: null,
|
||||
description: null,
|
||||
homepageURL: 'url',
|
||||
updateURL: 'updateUrl',
|
||||
name: null,
|
||||
}),
|
||||
|
||||
/** `src` is a style or vars */
|
||||
async assignVars(style, src) {
|
||||
const meta = style.usercssData;
|
||||
const meta2 = src.usercssData;
|
||||
const {vars} = meta;
|
||||
const oldVars = meta2 ? meta2.vars : src;
|
||||
if (vars && oldVars) {
|
||||
// The type of var might be changed during the update. Set value to null if the value is invalid.
|
||||
for (const [key, v] of Object.entries(vars)) {
|
||||
const old = oldVars[key] && oldVars[key].value;
|
||||
if (old) v.value = old;
|
||||
}
|
||||
meta.vars = await API.worker.nullifyInvalidVars(vars);
|
||||
}
|
||||
},
|
||||
|
||||
async build({
|
||||
styleId,
|
||||
sourceCode,
|
||||
vars,
|
||||
checkDup,
|
||||
metaOnly,
|
||||
assignVars,
|
||||
initialUrl,
|
||||
}) {
|
||||
// downloading here while install-usercss page is loading to avoid the wait
|
||||
if (initialUrl) sourceCode = await download(initialUrl);
|
||||
const style = await usercssMan.buildMeta({sourceCode});
|
||||
const dup = (checkDup || assignVars) &&
|
||||
await usercssMan.find(styleId ? {id: styleId} : style);
|
||||
let log;
|
||||
if (!metaOnly) {
|
||||
if (vars || assignVars) {
|
||||
await usercssMan.assignVars(style, vars || dup);
|
||||
}
|
||||
await usercssMan.buildCode(style);
|
||||
log = style.log; // extracting the non-enumerable prop, otherwise it won't survive messaging
|
||||
}
|
||||
return {style, dup, log};
|
||||
},
|
||||
|
||||
async buildCode(style) {
|
||||
const {sourceCode: code, usercssData: {vars, preprocessor}} = style;
|
||||
const match = code.match(RX_META);
|
||||
const i = match.index;
|
||||
const j = i + match[0].length;
|
||||
const codeNoMeta = code.slice(0, i) + blankOut(code, i, j) + code.slice(j);
|
||||
const {sections, errors, log} = await API.worker.compileUsercss(preprocessor, codeNoMeta, vars);
|
||||
const recoverable = errors.every(e => e.recoverable);
|
||||
if (!sections.length || !recoverable) {
|
||||
throw !recoverable ? errors : 'Style does not contain any actual CSS to apply.';
|
||||
}
|
||||
style.sections = sections;
|
||||
// adding a non-enumerable prop so it won't be written to storage
|
||||
if (log) Object.defineProperty(style, 'log', {value: log});
|
||||
return style;
|
||||
},
|
||||
|
||||
async buildMeta(style) {
|
||||
if (style.usercssData) {
|
||||
return style;
|
||||
}
|
||||
// remember normalized sourceCode
|
||||
let code = style.sourceCode = style.sourceCode.replace(/\r\n?/g, '\n');
|
||||
style = Object.assign({
|
||||
enabled: true,
|
||||
sections: [],
|
||||
}, style);
|
||||
const match = code.match(RX_META);
|
||||
if (!match) {
|
||||
return Promise.reject(new Error('Could not find metadata.'));
|
||||
}
|
||||
try {
|
||||
code = blankOut(code, 0, match.index) + match[0];
|
||||
const {metadata} = await API.worker.parseUsercssMeta(code);
|
||||
style.usercssData = metadata;
|
||||
// https://github.com/openstyles/stylus/issues/560#issuecomment-440561196
|
||||
for (const [key, globalKey] of usercssMan.GLOBAL_META) {
|
||||
const val = metadata[key];
|
||||
if (val !== undefined) {
|
||||
style[globalKey || key] = val;
|
||||
}
|
||||
}
|
||||
return style;
|
||||
} catch (err) {
|
||||
if (err.code) {
|
||||
const args = err.code === 'missingMandatory' || err.code === 'missingChar'
|
||||
? err.args.map(e => e.length === 1 ? JSON.stringify(e) : e).join(', ')
|
||||
: err.args;
|
||||
const msg = chrome.i18n.getMessage(`meta_${(err.code)}`, args);
|
||||
if (msg) err.message = msg;
|
||||
}
|
||||
return Promise.reject(err);
|
||||
}
|
||||
},
|
||||
|
||||
async configVars(id, vars) {
|
||||
const style = deepCopy(await API.styles.get(id));
|
||||
style.usercssData.vars = vars;
|
||||
await usercssMan.buildCode(style);
|
||||
return (await API.styles.install(style, 'config'))
|
||||
.usercssData.vars;
|
||||
},
|
||||
|
||||
async editSave(style) {
|
||||
style = await usercssMan.parse(style);
|
||||
return {
|
||||
log: style.log, // extracting the non-enumerable prop, otherwise it won't survive messaging
|
||||
style: await API.styles.editSave(style),
|
||||
};
|
||||
},
|
||||
|
||||
async find(styleOrData) {
|
||||
if (styleOrData.id) {
|
||||
return API.styles.get(styleOrData.id);
|
||||
}
|
||||
const {name, namespace} = styleOrData.usercssData || styleOrData;
|
||||
for (const dup of await API.styles.getAll()) {
|
||||
const data = dup.usercssData;
|
||||
if (data &&
|
||||
data.name === name &&
|
||||
data.namespace === namespace) {
|
||||
return dup;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
async install(style, opts) {
|
||||
return API.styles.install(await usercssMan.parse(style, opts));
|
||||
},
|
||||
|
||||
async parse(style, {dup, vars} = {}) {
|
||||
style = await usercssMan.buildMeta(style);
|
||||
// preserve style.vars during update
|
||||
if (dup || (dup = await usercssMan.find(style))) {
|
||||
style.id = dup.id;
|
||||
}
|
||||
if (vars || (vars = dup)) {
|
||||
await usercssMan.assignVars(style, vars);
|
||||
}
|
||||
return usercssMan.buildCode(style);
|
||||
},
|
||||
};
|
||||
|
||||
/** Replaces everything with spaces to keep the original length,
|
||||
* but preserves the line breaks to keep the original line/col relation */
|
||||
function blankOut(str, start = 0, end = str.length) {
|
||||
return str.slice(start, end).replace(/[^\r\n]/g, ' ');
|
||||
}
|
158
background/uso-api.js
Normal file
158
background/uso-api.js
Normal file
|
@ -0,0 +1,158 @@
|
|||
/* global URLS stringAsRegExp */// toolbox.js
|
||||
/* global usercssMan */
|
||||
'use strict';
|
||||
|
||||
const usoApi = {};
|
||||
|
||||
(() => {
|
||||
const pingers = {};
|
||||
|
||||
usoApi.pingback = (usoId, delay) => {
|
||||
clearTimeout(pingers[usoId]);
|
||||
delete pingers[usoId];
|
||||
if (delay > 0) {
|
||||
return new Promise(resolve => (pingers[usoId] = setTimeout(ping, delay, usoId, resolve)));
|
||||
} else if (delay !== false) {
|
||||
return ping(usoId);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Replicating USO-Archive format
|
||||
* https://github.com/33kk/uso-archive/blob/flomaster/lib/uso.js
|
||||
* https://github.com/33kk/uso-archive/blob/flomaster/lib/converters.js
|
||||
*/
|
||||
usoApi.toUsercss = async (data, {metaOnly = true, varsUrl} = {}) => {
|
||||
const badKeys = {};
|
||||
const newKeys = [];
|
||||
const descr = JSON.stringify(data.description.trim());
|
||||
const vars = (data.style_settings || []).map(makeVar, {badKeys, newKeys}).join('');
|
||||
const sourceCode = `\
|
||||
/* ==UserStyle==
|
||||
@name ${data.name}
|
||||
@namespace USO Archive
|
||||
@version ${data.updated.replace(/-/g, '').replace(/[T:]/g, '.').slice(0, 14)}
|
||||
@description ${/^"['`]|\\/.test(descr) ? descr : descr.slice(1, -1)}
|
||||
@author ${(data.user || {}).name || '?'}
|
||||
@license ${makeLicense(data.license)}${vars ? '\n@preprocessor uso' + vars : ''}`
|
||||
.replace(/\*\//g, '*\\/') +
|
||||
`==/UserStyle== */\n${newKeys[0] ? useNewKeys(data.css, badKeys) : data.css}`;
|
||||
const {style} = await usercssMan.build({sourceCode, metaOnly});
|
||||
usoApi.useVarsUrl(style, varsUrl);
|
||||
return {style, badKeys, newKeys};
|
||||
};
|
||||
|
||||
usoApi.useVarsUrl = (style, url) => {
|
||||
if (!/\?ik-/.test(url)) {
|
||||
return;
|
||||
}
|
||||
const cfg = {badKeys: {}, newKeys: []};
|
||||
const {vars} = style.usercssData;
|
||||
if (!vars) {
|
||||
return;
|
||||
}
|
||||
for (let [key, val] of new URLSearchParams(url.split('?')[1])) {
|
||||
if (!key.startsWith('ik-')) continue;
|
||||
key = makeKey(key.slice(3), cfg);
|
||||
const v = vars[key];
|
||||
if (!v) continue;
|
||||
if (v.options) {
|
||||
let sel = val.startsWith('ik-') && optByName(v, makeKey(val.slice(3), cfg));
|
||||
if (!sel) {
|
||||
key += '-custom';
|
||||
sel = optByName(v, key + '-dropdown');
|
||||
if (sel) vars[key].value = val;
|
||||
}
|
||||
if (sel) v.value = sel.name;
|
||||
} else {
|
||||
v.value = val;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
async function ping(id, resolve) {
|
||||
await fetch(`${URLS.uso}styles/install/${id}?source=stylish-ch`);
|
||||
if (resolve) resolve(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
function makeKey(key, {badKeys, newKeys}) {
|
||||
let res = badKeys[key];
|
||||
if (!res) {
|
||||
res = key.replace(/[^-\w]/g, '-');
|
||||
res += newKeys.includes(res) ? '-' : '';
|
||||
if (key !== res) {
|
||||
badKeys[key] = res;
|
||||
newKeys.push(res);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
function makeLicense(s) {
|
||||
return !s ? 'NO-REDISTRIBUTION' :
|
||||
s === 'publicdomain' ? 'CC0-1.0' :
|
||||
s.startsWith('ccby') ? `${s.toUpperCase().match(/(..)/g).join('-')}-4.0` :
|
||||
s;
|
||||
}
|
||||
|
||||
function makeVar({
|
||||
label,
|
||||
setting_type: type,
|
||||
install_key: ik,
|
||||
style_setting_options: opts,
|
||||
}) {
|
||||
const cfg = this;
|
||||
let value, suffix;
|
||||
ik = makeKey(ik, cfg);
|
||||
label = JSON.stringify(label);
|
||||
switch (type) {
|
||||
|
||||
case 'color':
|
||||
value = opts[0].value;
|
||||
break;
|
||||
|
||||
case 'text':
|
||||
value = JSON.stringify(opts[0].value);
|
||||
break;
|
||||
|
||||
case 'image': {
|
||||
const ikCust = `${ik}-custom`;
|
||||
opts.push({
|
||||
label: 'Custom',
|
||||
install_key: `${ikCust}-dropdown`,
|
||||
value: `/*[[${ikCust}]]*/`,
|
||||
});
|
||||
suffix = `\n@advanced text ${ikCust} ${label.slice(0, -1)} (Custom)" "https://foo.com/123.jpg"`;
|
||||
type = 'dropdown';
|
||||
} // fallthrough
|
||||
|
||||
case 'dropdown':
|
||||
value = '';
|
||||
for (const o of opts) {
|
||||
const def = o.default ? '*' : '';
|
||||
const val = o.value;
|
||||
const s = ` ${makeKey(o.install_key, cfg)} ${JSON.stringify(o.label + def)} <<<EOT${
|
||||
val.includes('\n') ? '\n' : ' '}${val} EOT;\n`;
|
||||
value = def ? s + value : value + s;
|
||||
}
|
||||
value = `{\n${value}}`;
|
||||
break;
|
||||
|
||||
default:
|
||||
value = '"ERROR: unknown type"';
|
||||
}
|
||||
return `\n@advanced ${type} ${ik} ${label} ${value}${suffix || ''}`;
|
||||
}
|
||||
|
||||
function optByName(v, name) {
|
||||
return v.options.find(o => o.name === name);
|
||||
}
|
||||
|
||||
function useNewKeys(css, badKeys) {
|
||||
const rxsKeys = stringAsRegExp(Object.keys(badKeys).join('\n'), '', true).replace(/\n/g, '|');
|
||||
const rxUsoVars = new RegExp(`(/\\*\\[\\[)(${rxsKeys})(?=]]\\*/)`, 'g');
|
||||
return css.replace(rxUsoVars, (s, a, key) => a + badKeys[key]);
|
||||
}
|
||||
})();
|
120
background/usw-api.js
Normal file
120
background/usw-api.js
Normal file
|
@ -0,0 +1,120 @@
|
|||
/* global API msg */// msg.js
|
||||
/* global URLS */ // toolbox.js
|
||||
/* global tokenMan */
|
||||
'use strict';
|
||||
|
||||
const uswApi = (() => {
|
||||
|
||||
//#region Internals
|
||||
|
||||
class TokenHooks {
|
||||
constructor(id) {
|
||||
this.id = id;
|
||||
}
|
||||
keyName(name) {
|
||||
return `${name}/${this.id}`;
|
||||
}
|
||||
query(query) {
|
||||
return Object.assign(query, {vendor_data: this.id});
|
||||
}
|
||||
}
|
||||
|
||||
function fakeUsercssHeader(style) {
|
||||
const {name, _usw: u = {}} = style;
|
||||
const meta = Object.entries({
|
||||
'@name': u.name || name || '?',
|
||||
'@version': // Same as USO-archive version: YYYYMMDD.hh.mm
|
||||
new Date().toISOString().replace(/^(\d+)-(\d+)-(\d+)T(\d+):(\d+).+/, '$1$2$3.$4.$5'),
|
||||
'@namespace': u.namespace !== '?' && u.namespace ||
|
||||
u.username && `userstyles.world/user/${u.username}` ||
|
||||
'?',
|
||||
'@description': u.description,
|
||||
'@author': u.username,
|
||||
'@license': u.license,
|
||||
});
|
||||
const maxKeyLen = meta.reduce((res, [k]) => Math.max(res, k.length), 0);
|
||||
return [
|
||||
'/* ==UserStyle==',
|
||||
...meta.map(([k, v]) => v && `${k}${' '.repeat(maxKeyLen - k.length + 2)}${v}`).filter(Boolean),
|
||||
'==/UserStyle== */',
|
||||
].join('\n') + '\n\n';
|
||||
}
|
||||
|
||||
async function linkStyle(style, sourceCode) {
|
||||
const {id} = style;
|
||||
const metadata = await API.worker.parseUsercssMeta(sourceCode).catch(console.warn) || {};
|
||||
const uswData = Object.assign({}, style, {metadata, sourceCode});
|
||||
API.data.set('usw' + id, uswData);
|
||||
const token = await tokenMan.getToken('userstylesworld', true, new TokenHooks(id));
|
||||
const info = await uswFetch('style', token);
|
||||
const data = style._usw = Object.assign({token}, info);
|
||||
style.url = style.url || data.homepage || `${URLS.usw}style/${data.id}`;
|
||||
await uswSave(style);
|
||||
return data;
|
||||
}
|
||||
|
||||
async function uswFetch(path, token, opts) {
|
||||
opts = Object.assign({credentials: 'omit'}, opts);
|
||||
opts.headers = Object.assign({Authorization: `Bearer ${token}`}, opts.headers);
|
||||
return (await (await fetch(`${URLS.usw}api/${path}`, opts)).json()).data;
|
||||
}
|
||||
|
||||
/** Uses a custom method when broadcasting and avoids needlessly sending the entire style */
|
||||
async function uswSave(style) {
|
||||
const {id, _usw} = style;
|
||||
await API.styles.save(style, {broadcast: false});
|
||||
msg.broadcastExtension({method: 'uswData', style: {id, _usw}});
|
||||
}
|
||||
|
||||
//#endregion
|
||||
//#region Exports
|
||||
|
||||
return {
|
||||
/**
|
||||
* @param {number} id
|
||||
* @param {string} sourceCode
|
||||
* @return {Promise<string>}
|
||||
*/
|
||||
async publish(id, sourceCode) {
|
||||
const style = await API.styles.get(id);
|
||||
const code = style.usercssData ? sourceCode
|
||||
: fakeUsercssHeader(style) + sourceCode;
|
||||
const data = (style._usw || {}).token
|
||||
? style._usw
|
||||
: await linkStyle(style, code);
|
||||
return uswFetch(`style/${data.id}`, data.token, {
|
||||
method: 'POST',
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
body: JSON.stringify({code}),
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {number} id
|
||||
* @return {Promise<void>}
|
||||
*/
|
||||
async revoke(id) {
|
||||
await tokenMan.revokeToken('userstylesworld', new TokenHooks(id));
|
||||
const style = await API.styles.get(id);
|
||||
if (style) {
|
||||
style._usw = {};
|
||||
await uswSave(style);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
//#endregion
|
||||
})();
|
||||
|
||||
/* Doing this outside so we don't break IDE's recognition of the exported methods in IIFE */
|
||||
for (const [k, fn] of Object.entries(uswApi)) {
|
||||
uswApi[k] = async (id, ...args) => {
|
||||
API.data.set('usw' + id, true);
|
||||
try {
|
||||
/* Awaiting inside `try` so that `finally` runs when done */
|
||||
return await fn(id, ...args);
|
||||
} finally {
|
||||
API.data.del('usw' + id);
|
||||
}
|
||||
};
|
||||
}
|
649
content/apply.js
649
content/apply.js
|
@ -1,398 +1,271 @@
|
|||
/* eslint no-var: 0 */
|
||||
/* global API msg */// msg.js
|
||||
/* global StyleInjector */
|
||||
/* global prefs */
|
||||
'use strict';
|
||||
|
||||
var ID_PREFIX = 'stylus-';
|
||||
var ROOT = document.documentElement;
|
||||
var isOwnPage = location.protocol.endsWith('-extension:');
|
||||
var disableAll = false;
|
||||
var exposeIframes = false;
|
||||
var styleElements = new Map();
|
||||
var disabledElements = new Map();
|
||||
var retiredStyleTimers = new Map();
|
||||
var docRewriteObserver;
|
||||
var docRootObserver;
|
||||
(() => {
|
||||
if (window.INJECTED === 1) return;
|
||||
window.INJECTED = 1;
|
||||
|
||||
requestStyles();
|
||||
chrome.runtime.onMessage.addListener(applyOnMessage);
|
||||
/** true -> when the page styles are received,
|
||||
* false -> when disableAll mode is on at start, the styles won't be sent
|
||||
* so while disableAll lasts we can ignore messages about style updates because
|
||||
* the tab will explicitly ask for all styles in bulk when disableAll mode ends */
|
||||
let hasStyles = false;
|
||||
let isDisabled = false;
|
||||
let isTab = !chrome.tabs || location.pathname !== '/popup.html';
|
||||
const order = {main: [], prio: []};
|
||||
const calcOrder = ({id}) =>
|
||||
(order.prio[id] || 0) * 1e6 ||
|
||||
order.main[id] ||
|
||||
id + .5e6; // no order = at the end of `main`
|
||||
const isFrame = window !== parent;
|
||||
const isFrameAboutBlank = isFrame && location.href === 'about:blank';
|
||||
const isUnstylable = !chrome.app && document instanceof XMLDocument;
|
||||
const styleInjector = StyleInjector({
|
||||
compare: (a, b) => calcOrder(a) - calcOrder(b),
|
||||
onUpdate: onInjectorUpdate,
|
||||
});
|
||||
// dynamic iframes don't have a URL yet so we'll use their parent's URL (hash isn't inherited)
|
||||
let matchUrl = isFrameAboutBlank && tryCatch(() => parent.location.href.split('#')[0]) ||
|
||||
location.href;
|
||||
|
||||
if (!isOwnPage) {
|
||||
window.dispatchEvent(new CustomEvent(chrome.runtime.id));
|
||||
window.addEventListener(chrome.runtime.id, orphanCheck, true);
|
||||
}
|
||||
// save it now because chrome.runtime will be unavailable in the orphaned script
|
||||
const orphanEventId = chrome.runtime.id;
|
||||
let isOrphaned;
|
||||
// firefox doesn't orphanize content scripts so the old elements stay
|
||||
if (!chrome.app) styleInjector.clearOrphans();
|
||||
|
||||
function requestStyles(options, callback = applyStyles) {
|
||||
if (!chrome.app && document instanceof XMLDocument) {
|
||||
chrome.runtime.sendMessage({method: 'styleViaAPI', action: 'styleApply'});
|
||||
return;
|
||||
/** @type chrome.runtime.Port */
|
||||
let port;
|
||||
let lazyBadge = isFrame;
|
||||
let parentDomain;
|
||||
|
||||
/* about:blank iframes are often used by sites for file upload or background tasks
|
||||
* and they may break if unexpected DOM stuff is present at `load` event
|
||||
* so we'll add the styles only if the iframe becomes visible */
|
||||
const xoEventId = `${Math.random()}`;
|
||||
/** @type IntersectionObserver */
|
||||
let xo;
|
||||
window[Symbol.for('xo')] = (el, cb) => {
|
||||
if (!xo) xo = new IntersectionObserver(onIntersect, {rootMargin: '100%'});
|
||||
el.addEventListener(xoEventId, cb, {once: true});
|
||||
xo.observe(el);
|
||||
};
|
||||
|
||||
// FIXME: move this to background page when following bugs are fixed:
|
||||
// https://bugzil.la/1587723, https://crbug.com/968651
|
||||
const mqDark = matchMedia('(prefers-color-scheme: dark)');
|
||||
mqDark.onchange = e => API.colorScheme.updateSystemPreferDark(e.matches);
|
||||
mqDark.onchange(mqDark);
|
||||
|
||||
// Declare all vars before init() or it'll throw due to "temporal dead zone" of const/let
|
||||
init();
|
||||
|
||||
// the popup needs a check as it's not a tab but can be opened in a tab manually for whatever reason
|
||||
if (!isTab) {
|
||||
chrome.tabs.getCurrent(tab => {
|
||||
isTab = Boolean(tab);
|
||||
if (tab && styleInjector.list.length) updateCount();
|
||||
});
|
||||
}
|
||||
var matchUrl = location.href;
|
||||
if (!matchUrl.match(/^(http|file|chrome|ftp)/)) {
|
||||
// dynamic about: and javascript: iframes don't have an URL yet
|
||||
// so we'll try the parent frame which is guaranteed to have a real URL
|
||||
try {
|
||||
if (window !== parent) {
|
||||
matchUrl = parent.location.href;
|
||||
|
||||
msg.onTab(applyOnMessage);
|
||||
window.addEventListener('pageshow', e => {
|
||||
if (e.isTrusted && e.persisted) { // bfcache
|
||||
updateCount();
|
||||
}
|
||||
});
|
||||
|
||||
if (!chrome.tabs) {
|
||||
window.dispatchEvent(new CustomEvent(orphanEventId));
|
||||
window.addEventListener(orphanEventId, orphanCheck, true);
|
||||
}
|
||||
|
||||
function onInjectorUpdate() {
|
||||
if (!isOrphaned) {
|
||||
updateCount();
|
||||
const onOff = prefs[styleInjector.list.length ? 'subscribe' : 'unsubscribe'];
|
||||
onOff('disableAll', updateDisableAll);
|
||||
if (isFrame) {
|
||||
updateExposeIframes();
|
||||
onOff('exposeIframes', updateExposeIframes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function init() {
|
||||
if (isUnstylable) {
|
||||
await API.styleViaAPI({method: 'styleApply'});
|
||||
} else {
|
||||
const SYM_ID = 'styles';
|
||||
const SYM = Symbol.for(SYM_ID);
|
||||
const parentStyles = isFrameAboutBlank &&
|
||||
tryCatch(() => parent[parent.Symbol.for(SYM_ID)]);
|
||||
const styles =
|
||||
window[SYM] ||
|
||||
parentStyles && await new Promise(onFrameElementInView) && parentStyles ||
|
||||
!isFrameAboutBlank && chrome.app && !chrome.tabs && tryCatch(getStylesViaXhr) ||
|
||||
await API.styles.getSectionsByUrl(matchUrl, null, true);
|
||||
if (styles.cfg) {
|
||||
isDisabled = styles.cfg.disableAll;
|
||||
Object.assign(order, styles.cfg.order);
|
||||
}
|
||||
hasStyles = !isDisabled;
|
||||
if (hasStyles) {
|
||||
window[SYM] = styles;
|
||||
await styleInjector.apply(styles);
|
||||
} else {
|
||||
delete window[SYM];
|
||||
prefs.subscribe('disableAll', updateDisableAll);
|
||||
}
|
||||
styleInjector.toggle(hasStyles);
|
||||
}
|
||||
}
|
||||
|
||||
/** Must be executed inside try/catch */
|
||||
function getStylesViaXhr() {
|
||||
const blobId = document.cookie.split(chrome.runtime.id + '=')[1].split(';')[0];
|
||||
const url = 'blob:' + chrome.runtime.getURL(blobId);
|
||||
document.cookie = `${chrome.runtime.id}=1; max-age=0`; // remove our cookie
|
||||
const xhr = new XMLHttpRequest();
|
||||
xhr.open('GET', url, false); // synchronous
|
||||
xhr.send();
|
||||
URL.revokeObjectURL(url);
|
||||
return JSON.parse(xhr.response);
|
||||
}
|
||||
|
||||
function applyOnMessage(request) {
|
||||
const {method} = request;
|
||||
if (isUnstylable) {
|
||||
if (method === 'urlChanged') {
|
||||
request.method = 'styleReplaceAll';
|
||||
}
|
||||
if (/^(style|updateCount)/.test(method)) {
|
||||
API.styleViaAPI(request);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const {style} = request;
|
||||
switch (method) {
|
||||
case 'ping':
|
||||
return true;
|
||||
|
||||
case 'styleDeleted':
|
||||
styleInjector.remove(style.id);
|
||||
break;
|
||||
|
||||
case 'styleUpdated':
|
||||
if (!hasStyles && isDisabled) break;
|
||||
if (style.enabled) {
|
||||
API.styles.getSectionsByUrl(matchUrl, style.id).then(sections =>
|
||||
sections[style.id]
|
||||
? styleInjector.apply(sections)
|
||||
: styleInjector.remove(style.id));
|
||||
} else {
|
||||
styleInjector.remove(style.id);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'styleAdded':
|
||||
if (!hasStyles && isDisabled) break;
|
||||
if (style.enabled) {
|
||||
API.styles.getSectionsByUrl(matchUrl, style.id)
|
||||
.then(styleInjector.apply);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'styleSort':
|
||||
Object.assign(order, request.order);
|
||||
styleInjector.sort();
|
||||
break;
|
||||
|
||||
case 'urlChanged':
|
||||
if (!hasStyles && isDisabled || matchUrl === request.url) break;
|
||||
matchUrl = request.url;
|
||||
API.styles.getSectionsByUrl(matchUrl).then(sections => {
|
||||
hasStyles = true;
|
||||
styleInjector.replace(sections);
|
||||
});
|
||||
break;
|
||||
|
||||
case 'updateCount':
|
||||
updateCount();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function updateDisableAll(key, disableAll) {
|
||||
isDisabled = disableAll;
|
||||
if (isUnstylable) {
|
||||
API.styleViaAPI({method: 'prefChanged', prefs: {disableAll}});
|
||||
} else if (!hasStyles && !disableAll) {
|
||||
init();
|
||||
} else {
|
||||
styleInjector.toggle(!disableAll);
|
||||
}
|
||||
}
|
||||
|
||||
async function updateExposeIframes(key, value = prefs.get('exposeIframes')) {
|
||||
const attr = 'stylus-iframe';
|
||||
const el = document.documentElement;
|
||||
if (!el) return; // got no styles so styleInjector didn't wait for <html>
|
||||
if (!value || !styleInjector.list.length) {
|
||||
el.removeAttribute(attr);
|
||||
} else {
|
||||
if (!parentDomain) parentDomain = await API.getTabUrlPrefix();
|
||||
// Check first to avoid triggering DOM mutation
|
||||
if (el.getAttribute(attr) !== parentDomain) {
|
||||
el.setAttribute(attr, parentDomain);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function updateCount() {
|
||||
if (!isTab) return;
|
||||
if (isFrame) {
|
||||
if (!port && styleInjector.list.length) {
|
||||
port = chrome.runtime.connect({name: 'iframe'});
|
||||
} else if (port && !styleInjector.list.length) {
|
||||
port.disconnect();
|
||||
}
|
||||
if (lazyBadge && performance.now() > 1000) lazyBadge = false;
|
||||
}
|
||||
(isUnstylable ?
|
||||
API.styleViaAPI({method: 'updateCount'}) :
|
||||
API.updateIconBadge(styleInjector.list.map(style => style.id), {lazyBadge})
|
||||
).catch(msg.ignoreError);
|
||||
}
|
||||
|
||||
function onFrameElementInView(cb) {
|
||||
parent[parent.Symbol.for('xo')](frameElement, cb);
|
||||
}
|
||||
|
||||
/** @param {IntersectionObserverEntry[]} entries */
|
||||
function onIntersect(entries) {
|
||||
for (const e of entries) {
|
||||
if (e.isIntersecting) {
|
||||
xo.unobserve(e.target);
|
||||
e.target.dispatchEvent(new Event(xoEventId));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function tryCatch(func, ...args) {
|
||||
try {
|
||||
return func(...args);
|
||||
} catch (e) {}
|
||||
}
|
||||
const request = Object.assign({
|
||||
method: 'getStyles',
|
||||
matchUrl,
|
||||
enabled: true,
|
||||
asHash: true,
|
||||
}, options);
|
||||
// On own pages we request the styles directly to minimize delay and flicker
|
||||
if (typeof getStylesSafe === 'function') {
|
||||
getStylesSafe(request).then(callback);
|
||||
} else {
|
||||
chrome.runtime.sendMessage(request, callback);
|
||||
|
||||
function orphanCheck() {
|
||||
if (chrome.runtime.id) return;
|
||||
// In Chrome content script is orphaned on an extension update/reload
|
||||
// so we need to detach event listeners
|
||||
window.removeEventListener(orphanEventId, orphanCheck, true);
|
||||
mqDark.onchange = null;
|
||||
isOrphaned = true;
|
||||
setTimeout(styleInjector.clear, 1000); // avoiding FOUC
|
||||
tryCatch(msg.off, applyOnMessage);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function applyOnMessage(request, sender, sendResponse) {
|
||||
if (request.styles === 'DIY') {
|
||||
// Do-It-Yourself tells our built-in pages to fetch the styles directly
|
||||
// which is faster because IPC messaging JSON-ifies everything internally
|
||||
requestStyles({}, styles => {
|
||||
request.styles = styles;
|
||||
applyOnMessage(request);
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (!chrome.app && document instanceof XMLDocument && request.method !== 'ping') {
|
||||
request.action = request.method;
|
||||
request.method = 'styleViaAPI';
|
||||
request.styles = null;
|
||||
if (request.style) {
|
||||
request.style.sections = null;
|
||||
}
|
||||
chrome.runtime.sendMessage(request);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (request.method) {
|
||||
case 'styleDeleted':
|
||||
removeStyle(request);
|
||||
break;
|
||||
|
||||
case 'styleUpdated':
|
||||
if (request.codeIsUpdated === false) {
|
||||
applyStyleState(request.style);
|
||||
break;
|
||||
}
|
||||
if (request.style.enabled) {
|
||||
removeStyle({id: request.style.id, retire: true});
|
||||
requestStyles({id: request.style.id});
|
||||
} else {
|
||||
removeStyle(request.style);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'styleAdded':
|
||||
if (request.style.enabled) {
|
||||
requestStyles({id: request.style.id});
|
||||
}
|
||||
break;
|
||||
|
||||
case 'styleApply':
|
||||
applyStyles(request.styles);
|
||||
break;
|
||||
|
||||
case 'styleReplaceAll':
|
||||
replaceAll(request.styles);
|
||||
break;
|
||||
|
||||
case 'prefChanged':
|
||||
if ('disableAll' in request.prefs) {
|
||||
doDisableAll(request.prefs.disableAll);
|
||||
}
|
||||
if ('exposeIframes' in request.prefs) {
|
||||
doExposeIframes(request.prefs.exposeIframes);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'ping':
|
||||
sendResponse(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function doDisableAll(disable = disableAll) {
|
||||
if (!disable === !disableAll) {
|
||||
return;
|
||||
}
|
||||
disableAll = disable;
|
||||
Array.prototype.forEach.call(document.styleSheets, stylesheet => {
|
||||
if (stylesheet.ownerNode.matches(`style.stylus[id^="${ID_PREFIX}"]`)
|
||||
&& stylesheet.disabled !== disable) {
|
||||
stylesheet.disabled = disable;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function doExposeIframes(state = exposeIframes) {
|
||||
if (state === exposeIframes || window === parent) {
|
||||
return;
|
||||
}
|
||||
exposeIframes = state;
|
||||
const attr = document.documentElement.getAttribute('stylus-iframe');
|
||||
if (state && attr !== '') {
|
||||
document.documentElement.setAttribute('stylus-iframe', '');
|
||||
} else if (!state && attr === '') {
|
||||
document.documentElement.removeAttribute('stylus-iframe');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function applyStyleState({id, enabled}) {
|
||||
const inCache = disabledElements.get(id) || styleElements.get(id);
|
||||
const inDoc = document.getElementById(ID_PREFIX + id);
|
||||
if (enabled) {
|
||||
if (inDoc) {
|
||||
return;
|
||||
} else if (inCache) {
|
||||
addStyleElement(inCache);
|
||||
disabledElements.delete(id);
|
||||
} else {
|
||||
requestStyles({id});
|
||||
}
|
||||
} else {
|
||||
if (inDoc) {
|
||||
disabledElements.set(id, inDoc);
|
||||
inDoc.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function removeStyle({id, retire = false}) {
|
||||
const el = document.getElementById(ID_PREFIX + id);
|
||||
if (el) {
|
||||
if (retire) {
|
||||
// to avoid page flicker when the style is updated
|
||||
// instead of removing it immediately we rename its ID and queue it
|
||||
// to be deleted in applyStyles after a new version is fetched and applied
|
||||
const deadID = 'ghost-' + id;
|
||||
el.id = ID_PREFIX + deadID;
|
||||
// in case something went wrong and new style was never applied
|
||||
retiredStyleTimers.set(deadID, setTimeout(removeStyle, 1000, {id: deadID}));
|
||||
} else {
|
||||
el.remove();
|
||||
}
|
||||
}
|
||||
styleElements.delete(ID_PREFIX + id);
|
||||
disabledElements.delete(id);
|
||||
retiredStyleTimers.delete(id);
|
||||
}
|
||||
|
||||
|
||||
function applyStyles(styles) {
|
||||
if (!styles) {
|
||||
// Chrome is starting up
|
||||
requestStyles();
|
||||
return;
|
||||
}
|
||||
if ('disableAll' in styles) {
|
||||
doDisableAll(styles.disableAll);
|
||||
delete styles.disableAll;
|
||||
}
|
||||
if ('exposeIframes' in styles) {
|
||||
doExposeIframes(styles.exposeIframes);
|
||||
delete styles.exposeIframes;
|
||||
}
|
||||
if (styles.needTransitionPatch) {
|
||||
// CSS transition bug workaround: since we insert styles asynchronously,
|
||||
// the browsers, especially Firefox, may apply all transitions on page load
|
||||
delete styles.needTransitionPatch;
|
||||
const className = chrome.runtime.id + '-transition-bug-fix';
|
||||
const docId = document.documentElement.id ? '#' + document.documentElement.id : '';
|
||||
document.documentElement.classList.add(className);
|
||||
applySections(0, `
|
||||
${docId}.${className}:root * {
|
||||
transition: none !important;
|
||||
}
|
||||
`);
|
||||
setTimeout(() => {
|
||||
removeStyle({id: 0});
|
||||
document.documentElement.classList.remove(className);
|
||||
});
|
||||
}
|
||||
for (const id in styles) {
|
||||
applySections(id, styles[id].map(section => section.code).join('\n'));
|
||||
}
|
||||
initDocRewriteObserver();
|
||||
initDocRootObserver();
|
||||
if (retiredStyleTimers.size) {
|
||||
setTimeout(() => {
|
||||
for (const [id, timer] of retiredStyleTimers.entries()) {
|
||||
removeStyle({id});
|
||||
clearTimeout(timer);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function applySections(styleId, code) {
|
||||
let el = document.getElementById(ID_PREFIX + styleId);
|
||||
if (el) {
|
||||
return;
|
||||
}
|
||||
if (document.documentElement instanceof SVGSVGElement) {
|
||||
// SVG document style
|
||||
el = document.createElementNS('http://www.w3.org/2000/svg', 'style');
|
||||
} else if (document instanceof XMLDocument) {
|
||||
// XML document style
|
||||
el = document.createElementNS('http://www.w3.org/1999/xhtml', 'style');
|
||||
} else {
|
||||
// HTML document style; also works on HTML-embedded SVG
|
||||
el = document.createElement('style');
|
||||
}
|
||||
Object.assign(el, {
|
||||
id: ID_PREFIX + styleId,
|
||||
type: 'text/css',
|
||||
textContent: code,
|
||||
});
|
||||
// SVG className is not a string, but an instance of SVGAnimatedString
|
||||
el.classList.add('stylus');
|
||||
addStyleElement(el);
|
||||
styleElements.set(el.id, el);
|
||||
disabledElements.delete(Number(styleId));
|
||||
return el;
|
||||
}
|
||||
|
||||
|
||||
function addStyleElement(el) {
|
||||
if (ROOT && !document.getElementById(el.id)) {
|
||||
ROOT.appendChild(el);
|
||||
if (disableAll) {
|
||||
el.disabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function replaceAll(newStyles) {
|
||||
const oldStyles = Array.prototype.slice.call(
|
||||
document.querySelectorAll(`style.stylus[id^="${ID_PREFIX}"]`));
|
||||
oldStyles.forEach(el => (el.id += '-ghost'));
|
||||
styleElements.clear();
|
||||
disabledElements.clear();
|
||||
[...retiredStyleTimers.values()].forEach(clearTimeout);
|
||||
retiredStyleTimers.clear();
|
||||
applyStyles(newStyles);
|
||||
oldStyles.forEach(el => el.remove());
|
||||
}
|
||||
|
||||
|
||||
function initDocRewriteObserver() {
|
||||
if (isOwnPage || docRewriteObserver || !styleElements.size) {
|
||||
return;
|
||||
}
|
||||
// re-add styles if we detect documentElement being recreated
|
||||
const reinjectStyles = () => {
|
||||
if (!styleElements) {
|
||||
return orphanCheck && orphanCheck();
|
||||
}
|
||||
ROOT = document.documentElement;
|
||||
for (const el of styleElements.values()) {
|
||||
el.textContent += ' '; // invalidate CSSOM cache
|
||||
addStyleElement(document.importNode(el, true));
|
||||
}
|
||||
};
|
||||
// detect documentElement being rewritten from inside the script
|
||||
docRewriteObserver = new MutationObserver(mutations => {
|
||||
for (let m = mutations.length; --m >= 0;) {
|
||||
const added = mutations[m].addedNodes;
|
||||
for (let n = added.length; --n >= 0;) {
|
||||
if (added[n].localName === 'html') {
|
||||
reinjectStyles();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
docRewriteObserver.observe(document, {childList: true});
|
||||
// detect dynamic iframes rewritten after creation by the embedder i.e. externally
|
||||
setTimeout(() => {
|
||||
if (document.documentElement !== ROOT) {
|
||||
reinjectStyles();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function initDocRootObserver() {
|
||||
if (!styleElements.size || document.body || docRootObserver) {
|
||||
return;
|
||||
}
|
||||
// wait for BODY and move all style elements after it
|
||||
docRootObserver = new MutationObserver(() => {
|
||||
let expectedPrevSibling = document.body || document.head;
|
||||
if (!expectedPrevSibling) {
|
||||
return;
|
||||
}
|
||||
docRootObserver.disconnect();
|
||||
for (const el of styleElements.values()) {
|
||||
if (el.previousElementSibling !== expectedPrevSibling) {
|
||||
ROOT.insertBefore(el, expectedPrevSibling.nextSibling);
|
||||
if (el.disabled !== disableAll) {
|
||||
// moving an element resets its 'disabled' state
|
||||
el.disabled = disableAll;
|
||||
}
|
||||
}
|
||||
expectedPrevSibling = el;
|
||||
}
|
||||
if (document.body) {
|
||||
docRootObserver = null;
|
||||
} else {
|
||||
docRootObserver.connect();
|
||||
}
|
||||
});
|
||||
docRootObserver.connect = () => {
|
||||
docRootObserver.observe(ROOT, {childList: true});
|
||||
};
|
||||
docRootObserver.connect();
|
||||
}
|
||||
|
||||
|
||||
function orphanCheck() {
|
||||
const port = chrome.runtime.connect();
|
||||
if (port) {
|
||||
port.disconnect();
|
||||
return;
|
||||
}
|
||||
|
||||
// we're orphaned due to an extension update
|
||||
// we can detach the mutation observer
|
||||
[docRewriteObserver, docRootObserver].forEach(ob => ob && ob.disconnect());
|
||||
// we can detach event listeners
|
||||
window.removeEventListener(chrome.runtime.id, orphanCheck, true);
|
||||
// we can't detach chrome.runtime.onMessage because it's no longer connected internally
|
||||
// we can destroy our globals in this context to free up memory
|
||||
[ // functions
|
||||
'addStyleElement',
|
||||
'applyOnMessage',
|
||||
'applySections',
|
||||
'applyStyles',
|
||||
'applyStyleState',
|
||||
'doDisableAll',
|
||||
'initDocRewriteObserver',
|
||||
'initDocRootObserver',
|
||||
'orphanCheck',
|
||||
'removeStyle',
|
||||
'replaceAll',
|
||||
'requestStyles',
|
||||
// variables
|
||||
'ROOT',
|
||||
'disabledElements',
|
||||
'retiredStyleTimers',
|
||||
'styleElements',
|
||||
'docRewriteObserver',
|
||||
'docRootObserver',
|
||||
].forEach(fn => (window[fn] = null));
|
||||
}
|
||||
})();
|
||||
|
|
21
content/install-hook-greasyfork.js
Normal file
21
content/install-hook-greasyfork.js
Normal file
|
@ -0,0 +1,21 @@
|
|||
/* global API */// msg.js
|
||||
'use strict';
|
||||
|
||||
// onCommitted may fire twice
|
||||
// Note, we're checking against a literal `1`, not just `if (truthy)`,
|
||||
// because <html id="INJECTED"> is exposed per HTML spec as a global variable and `window.INJECTED`.
|
||||
|
||||
if (window.INJECTED_GREASYFORK !== 1) {
|
||||
window.INJECTED_GREASYFORK = 1;
|
||||
addEventListener('message', async function onMessage(e) {
|
||||
if (e.origin === location.origin &&
|
||||
e.data &&
|
||||
e.data.name &&
|
||||
e.data.type === 'style-version-query') {
|
||||
removeEventListener('message', onMessage);
|
||||
const style = await API.usercss.find(e.data) || {};
|
||||
const {version} = style.usercssData || {};
|
||||
postMessage({type: 'style-version', version}, '*');
|
||||
}
|
||||
});
|
||||
}
|
26
content/install-hook-usercss.js
Normal file
26
content/install-hook-usercss.js
Normal file
|
@ -0,0 +1,26 @@
|
|||
'use strict';
|
||||
|
||||
// preventing reregistration if reinjected by tabs.executeScript for whatever reason, just in case
|
||||
if (typeof window.oldCode !== 'string') {
|
||||
window.oldCode = (document.querySelector('body > pre') || document.body).textContent;
|
||||
chrome.runtime.onConnect.addListener(port => {
|
||||
if (port.name !== 'downloadSelf') return;
|
||||
port.onMessage.addListener(async ({id, force}) => {
|
||||
const msg = {id};
|
||||
try {
|
||||
const code = await (await fetch(location.href, {mode: 'same-origin'})).text();
|
||||
if (code !== window.oldCode || force) {
|
||||
msg.code = window.oldCode = code;
|
||||
}
|
||||
} catch (error) {
|
||||
msg.error = error.message || `${error}`;
|
||||
}
|
||||
port.postMessage(msg);
|
||||
});
|
||||
// FF keeps content scripts connected on navigation https://github.com/openstyles/stylus/issues/864
|
||||
addEventListener('pagehide', () => port.disconnect(), {once: true});
|
||||
});
|
||||
}
|
||||
|
||||
// passing the result to tabs.executeScript
|
||||
window.oldCode; // eslint-disable-line no-unused-expressions
|
324
content/install-hook-userstyles.js
Normal file
324
content/install-hook-userstyles.js
Normal file
|
@ -0,0 +1,324 @@
|
|||
/* global API */// msg.js
|
||||
'use strict';
|
||||
|
||||
// eslint-disable-next-line no-unused-expressions
|
||||
/^\/styles\/(\d+)(\/([^/]*))?([?#].*)?$/.test(location.pathname) && (async () => {
|
||||
if (window.INJECTED_USO === 1) return;
|
||||
window.INJECTED_USO = 1;
|
||||
|
||||
const usoId = RegExp.$1;
|
||||
const USO = 'https://userstyles.org';
|
||||
const apiUrl = `${USO}/api/v1/styles/${usoId}`;
|
||||
const md5Url = `https://update.userstyles.org/${usoId}.md5`;
|
||||
const CLICK = [
|
||||
['#install_stylish_style_button', onInstall],
|
||||
['#update_stylish_style_button', onInstall],
|
||||
['.customize_style_button', onCustomize],
|
||||
['.uninstall_stylish_style_button', onUninstall],
|
||||
];
|
||||
const pageEventId = `${performance.now()}${Math.random()}`;
|
||||
const contentEventId = pageEventId + ':';
|
||||
const orphanEventId = chrome.runtime.id; // id won't be available in the orphaned script
|
||||
const $ = (sel, base = document) => base.querySelector(sel);
|
||||
const toggleListener = (isOn, ...args) => (isOn ? addEventListener : removeEventListener)(...args);
|
||||
const togglePageListener = isOn => toggleListener(isOn, contentEventId, onPageEvent, true);
|
||||
|
||||
const mo = new MutationObserver(onMutation);
|
||||
const observeColors = isOn =>
|
||||
isOn ? mo.observe(document.body, {subtree: true, attributes: true, attributeFilter: ['value']})
|
||||
: mo.disconnect();
|
||||
|
||||
let style, dup, md5, pageData, badKeys;
|
||||
|
||||
runInPage(inPageContext, pageEventId, contentEventId, usoId, apiUrl);
|
||||
addEventListener(orphanEventId, orphanCheck, true);
|
||||
addEventListener('click', onClick, true);
|
||||
togglePageListener(true);
|
||||
|
||||
[md5, dup] = await Promise.all([
|
||||
fetch(md5Url).then(r => r.text()),
|
||||
API.styles.find({md5Url}, {installationUrl: `https://uso.kkx.one/style/${usoId}`})
|
||||
.then(sendVarsToPage),
|
||||
document.body || new Promise(resolve => addEventListener('load', resolve, {once: true})),
|
||||
]);
|
||||
|
||||
if (!dup) {
|
||||
sendStylishEvent('styleCanBeInstalledChrome');
|
||||
} else if (dup.originalMd5 && dup.originalMd5 !== md5 || !dup.usercssData || !dup.md5Url) {
|
||||
// allow update if 1) changed, 2) is a classic USO style, 3) is from USO-archive
|
||||
sendStylishEvent('styleCanBeUpdatedChrome');
|
||||
} else {
|
||||
sendStylishEvent('styleAlreadyInstalledChrome');
|
||||
}
|
||||
|
||||
async function onClick(e) {
|
||||
for (const [sel, fn] of CLICK) {
|
||||
const el = e.target.closest(sel);
|
||||
if (!el) continue;
|
||||
try {
|
||||
el.disabled = true;
|
||||
await fn(e);
|
||||
} catch (e) {
|
||||
alert(chrome.i18n.getMessage('styleInstallFailed', e.message || e));
|
||||
} finally {
|
||||
el.disabled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function onCustomize() {
|
||||
const ss = $('#style-settings');
|
||||
const willShow = !ss || !ss.offsetHeight;
|
||||
observeColors(willShow);
|
||||
toggleListener(willShow, 'change', onChange);
|
||||
}
|
||||
|
||||
async function onInstall(e) {
|
||||
const {id} = dup;
|
||||
e.stopPropagation();
|
||||
if (!style) await buildStyle();
|
||||
style = dup = await API.usercss.install(style, {
|
||||
dup: {id},
|
||||
vars: getPageVars(),
|
||||
});
|
||||
sendStylishEvent('styleInstalledChrome');
|
||||
API.uso.pingback(id);
|
||||
}
|
||||
|
||||
function onUninstall() {
|
||||
const {id} = dup;
|
||||
dup = style = false;
|
||||
observeColors(false);
|
||||
removeEventListener('change', onChange);
|
||||
return API.styles.delete(id);
|
||||
}
|
||||
|
||||
function onChange({target: el}) {
|
||||
if (dup && el.matches('[name^="ik-"], [type=file]')) {
|
||||
API.usercss.configVars(dup.id, getPageVars());
|
||||
}
|
||||
}
|
||||
|
||||
function onMutation(mutations) {
|
||||
for (const {target: el} of mutations) {
|
||||
if (el.style.display === 'none' &&
|
||||
/^ik-/.test(el.name) &&
|
||||
/^#[\da-f]{6}$/.test(el.value)) {
|
||||
onChange({target: el});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function onPageEvent(e) {
|
||||
pageData = e.detail;
|
||||
togglePageListener(false);
|
||||
}
|
||||
|
||||
async function buildStyle() {
|
||||
if (!pageData) pageData = await (await fetch(apiUrl)).json();
|
||||
({style, badKeys} = await API.uso.toUsercss(pageData, {varsUrl: dup.updateUrl}));
|
||||
Object.assign(style, {
|
||||
md5Url,
|
||||
id: dup.id,
|
||||
originalMd5: md5,
|
||||
updateUrl: apiUrl,
|
||||
});
|
||||
}
|
||||
|
||||
function getPageVars() {
|
||||
const {vars} = (style || dup).usercssData;
|
||||
for (const el of document.querySelectorAll('[name^="ik-"]')) {
|
||||
const name = el.name.slice(3); // dropping "ik-"
|
||||
const ik = (badKeys || {})[name] || name;
|
||||
const v = vars[ik] || false;
|
||||
const isImage = el.type === 'radio';
|
||||
if (v && (!isImage || el.checked)) {
|
||||
const val = el.value;
|
||||
const isFile = val === 'user-upload';
|
||||
if (isImage && (isFile || val === 'user-url')) {
|
||||
const el2 = $(`[type=${isFile ? 'file' : 'url'}]`, el.parentElement);
|
||||
const ikCust = `${ik}-custom`;
|
||||
v.value = `${ikCust}-dropdown`;
|
||||
vars[ikCust].value = isFile ? getFileUriFromPage(el2) : el2.value;
|
||||
} else {
|
||||
v.value = v.type === 'select' ? val.replace(/^ik-/, '') : val;
|
||||
}
|
||||
}
|
||||
}
|
||||
return vars;
|
||||
}
|
||||
|
||||
function getFileUriFromPage(el) {
|
||||
togglePageListener(true);
|
||||
sendPageEvent(el);
|
||||
return pageData;
|
||||
}
|
||||
|
||||
function runInPage(fn, ...args) {
|
||||
const div = document.createElement('div');
|
||||
div.attachShadow({mode: 'closed'})
|
||||
.appendChild(document.createElement('script'))
|
||||
.textContent = `(${fn})(${JSON.stringify(args).slice(1, -1)})`;
|
||||
document.documentElement.appendChild(div).remove();
|
||||
}
|
||||
|
||||
function sendPageEvent(data) {
|
||||
dispatchEvent(data instanceof Node
|
||||
? new MouseEvent(pageEventId, {relatedTarget: data})
|
||||
: new CustomEvent(pageEventId, {detail: data}));
|
||||
//* global cloneInto */// WARNING! Firefox requires cloning of an object `detail`
|
||||
}
|
||||
|
||||
function sendStylishEvent(type) {
|
||||
document.dispatchEvent(new Event(type));
|
||||
}
|
||||
|
||||
function sendVarsToPage(style) {
|
||||
if (style) {
|
||||
const vars = (style.usercssData || {}).vars || `${style.updateUrl}`.split('?')[1];
|
||||
if (vars) sendPageEvent('vars:' + JSON.stringify(vars));
|
||||
}
|
||||
return style || false;
|
||||
}
|
||||
|
||||
function orphanCheck() {
|
||||
if (chrome.runtime.id) return true;
|
||||
removeEventListener(orphanEventId, orphanCheck, true);
|
||||
removeEventListener('click', onClick, true);
|
||||
removeEventListener('change', onChange);
|
||||
sendPageEvent('quit');
|
||||
observeColors(false);
|
||||
togglePageListener(false);
|
||||
}
|
||||
})();
|
||||
|
||||
function inPageContext(eventId, eventIdHost, styleId, apiUrl) {
|
||||
let done, orphaned, vars;
|
||||
// `chrome` may be empty if no extensions use externally_connectable but USO needs it
|
||||
if (!window.chrome) window.chrome = {runtime: {sendMessage: () => {}}};
|
||||
const EXT_ID = 'fjnbnpbmkenffdnngjfgmeleoegfcffe';
|
||||
const {defineProperty} = Object;
|
||||
const {dispatchEvent, CustomEvent, removeEventListener} = window;
|
||||
const apply = Map.call.bind(Map.apply);
|
||||
const OVR = [
|
||||
[chrome.runtime, 'sendMessage', (fn, me, args) => {
|
||||
const [id, /*msg*/, opts, cb = opts] = args;
|
||||
if (id !== EXT_ID) return apply(fn, me, args);
|
||||
if (typeof cb !== 'function') return Promise.resolve(true);
|
||||
cb(true);
|
||||
}],
|
||||
[Response.prototype, 'json', async (fn, me, args) => {
|
||||
const res = await apply(fn, me, args);
|
||||
try {
|
||||
if (!done && me.url === apiUrl) {
|
||||
done = true;
|
||||
send(res);
|
||||
setVars(res);
|
||||
}
|
||||
} catch (e) {}
|
||||
return res;
|
||||
}],
|
||||
[window, 'fetch', (fn, me, args) =>
|
||||
args[0] === `chrome-extension://${EXT_ID}/index.html`
|
||||
? Promise.resolve(new Response('<!doctype html><html lang="en"></html>'))
|
||||
: apply(fn, me, args),
|
||||
],
|
||||
];
|
||||
OVR.forEach(([obj, name, caller], i) => {
|
||||
const orig = obj[name];
|
||||
const ovr = new Proxy(orig, {
|
||||
apply(fn, me, args) {
|
||||
if (orphaned) restore(obj, name, ovr, fn);
|
||||
return (orphaned ? apply : caller)(fn, me, args);
|
||||
},
|
||||
});
|
||||
defineProperty(obj, name, {value: ovr});
|
||||
OVR[i] = [obj, name, ovr, orig]; // same args as restore()
|
||||
});
|
||||
/* We set `isInstalled` at page start intentionally not trying to replicate Stylish login events.
|
||||
* This difference allows USO site to detect presence of Stylus (or another similar extension). */
|
||||
window.isInstalled = true;
|
||||
addEventListener(eventId, onCommand, true);
|
||||
function onCommand(e) {
|
||||
if (e.detail === 'quit') {
|
||||
removeEventListener(eventId, onCommand, true);
|
||||
OVR.forEach(restore);
|
||||
done = orphaned = true;
|
||||
} else if (/^vars:/.test(e.detail)) {
|
||||
vars = JSON.parse(e.detail.slice(5));
|
||||
} else if (e.relatedTarget) {
|
||||
send(e.relatedTarget.uploadedData);
|
||||
}
|
||||
}
|
||||
function restore(obj, name, ovr, orig) { // same order as OVR after patching
|
||||
if (obj[name] === ovr) {
|
||||
defineProperty(obj, name, {value: orig});
|
||||
}
|
||||
}
|
||||
function send(data) {
|
||||
dispatchEvent(new CustomEvent(eventIdHost, {__proto: null, detail: data}));
|
||||
}
|
||||
function setVars(json) {
|
||||
const images = new Map();
|
||||
const isNew = typeof vars === 'object';
|
||||
const badKeys = {};
|
||||
const newKeys = [];
|
||||
const makeKey = ({install_key: key}) => {
|
||||
let res = isNew ? badKeys[key] : key;
|
||||
if (!res) {
|
||||
res = key.replace(/[^-\w]/g, '-');
|
||||
res += newKeys.includes(res) ? '-' : '';
|
||||
if (key !== res) {
|
||||
badKeys[key] = res;
|
||||
newKeys.push(res);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
};
|
||||
if (!isNew) vars = new URLSearchParams(vars);
|
||||
for (const ss of json.style_settings || []) {
|
||||
const ik = makeKey(ss);
|
||||
let value = isNew ? (vars[ik] || {}).value : vars.get('ik-' + ik);
|
||||
if (value == null || !(ss.style_setting_options || [])[0]) {
|
||||
continue;
|
||||
}
|
||||
if (ss.setting_type === 'image') {
|
||||
let isListed;
|
||||
for (const opt of ss.style_setting_options) {
|
||||
isListed |= opt.default = (opt.install_key === value);
|
||||
}
|
||||
images.set(ik, {url: isNew && !isListed ? vars[`${ik}-custom`].value : value, isListed});
|
||||
} else if (value.startsWith('ik-') || isNew && vars[ik].type === 'select') {
|
||||
value = value.replace(/^ik-/, '');
|
||||
const def = ss.style_setting_options.find(item => item.default);
|
||||
if (!def || makeKey(def) !== value) {
|
||||
if (def) def.default = false;
|
||||
for (const item of ss.style_setting_options) {
|
||||
if (makeKey(item) === value) {
|
||||
item.default = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
const item = ss.style_setting_options[0];
|
||||
if (item.value !== value && item.install_key === 'placeholder') {
|
||||
item.value = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!images.size) return;
|
||||
new MutationObserver((_, observer) => {
|
||||
if (!document.getElementById('style-settings')) return;
|
||||
observer.disconnect();
|
||||
for (const [name, {url, isListed}] of images) {
|
||||
const elRadio = document.querySelector(`input[name="ik-${name}"][value="user-url"]`);
|
||||
const elUrl = elRadio && document.getElementById(elRadio.id.replace('url-choice', 'user-url'));
|
||||
if (elUrl) {
|
||||
elRadio.checked = !isListed;
|
||||
elUrl.value = url;
|
||||
}
|
||||
}
|
||||
}).observe(document, {childList: true, subtree: true});
|
||||
}
|
||||
}
|
43
content/install-hook-userstylesworld.js
Normal file
43
content/install-hook-userstylesworld.js
Normal file
|
@ -0,0 +1,43 @@
|
|||
/* global API */// msg.js
|
||||
'use strict';
|
||||
|
||||
(() => {
|
||||
const ORIGIN = 'https://userstyles.world';
|
||||
const HANDLERS = Object.assign(Object.create(null), {
|
||||
|
||||
async 'usw-ready'() {
|
||||
send({type: 'usw-remove-stylus-button'});
|
||||
if (location.pathname === '/api/oauth/style/new') {
|
||||
const styleId = Number(new URLSearchParams(location.search).get('vendor_data'));
|
||||
const data = await API.data.pop('usw' + styleId);
|
||||
send({type: 'usw-fill-new-style', data});
|
||||
}
|
||||
},
|
||||
|
||||
async 'usw-style-info-request'(data) {
|
||||
switch (data.requestType) {
|
||||
case 'installed': {
|
||||
const updateUrl = `${ORIGIN}/api/style/${data.styleID}.user.css`;
|
||||
const style = await API.styles.find({updateUrl});
|
||||
send({
|
||||
type: 'usw-style-info-response',
|
||||
data: {installed: Boolean(style), requestType: 'installed'},
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
window.addEventListener('message', ({data, source, origin}) => {
|
||||
// Some browsers don't reveal `source` to extensions e.g. Firefox
|
||||
if (data && (source ? source === window : origin === ORIGIN)) {
|
||||
const fn = HANDLERS[data.type];
|
||||
if (fn) fn(data);
|
||||
}
|
||||
});
|
||||
|
||||
function send(msg) {
|
||||
window.postMessage(msg, ORIGIN);
|
||||
}
|
||||
})();
|
|
@ -1,122 +0,0 @@
|
|||
/* global runtimeSend */
|
||||
'use strict';
|
||||
|
||||
function createSourceLoader() {
|
||||
let source;
|
||||
|
||||
function fetchText(url) {
|
||||
return new Promise((resolve, reject) => {
|
||||
// you can't use fetch in Chrome under 'file:' protocol
|
||||
const xhr = new XMLHttpRequest();
|
||||
xhr.open('GET', url);
|
||||
xhr.addEventListener('load', () => resolve(xhr.responseText));
|
||||
xhr.addEventListener('error', () => reject(xhr));
|
||||
xhr.send();
|
||||
});
|
||||
}
|
||||
|
||||
function load() {
|
||||
return fetchText(location.href).then(newSource => {
|
||||
source = newSource;
|
||||
return source;
|
||||
});
|
||||
}
|
||||
|
||||
function watch(cb) {
|
||||
let timer;
|
||||
const DELAY = 1000;
|
||||
|
||||
function start() {
|
||||
if (timer) {
|
||||
return;
|
||||
}
|
||||
timer = setTimeout(check, DELAY);
|
||||
}
|
||||
|
||||
function stop() {
|
||||
clearTimeout(timer);
|
||||
timer = null;
|
||||
}
|
||||
|
||||
function check() {
|
||||
fetchText(location.href)
|
||||
.then(newSource => {
|
||||
if (source !== newSource) {
|
||||
source = newSource;
|
||||
return cb(source);
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.log(t('liveReloadError', error));
|
||||
})
|
||||
.then(() => {
|
||||
timer = setTimeout(check, DELAY);
|
||||
});
|
||||
}
|
||||
|
||||
return {start, stop};
|
||||
}
|
||||
|
||||
return {load, watch, source: () => source};
|
||||
}
|
||||
|
||||
function initUsercssInstall() {
|
||||
const sourceLoader = createSourceLoader();
|
||||
const pendingSource = sourceLoader.load();
|
||||
let watcher;
|
||||
|
||||
chrome.runtime.onConnect.addListener(port => {
|
||||
// FIXME: is this the correct way to reject a connection?
|
||||
// https://developer.chrome.com/extensions/messaging#connect
|
||||
console.assert(port.name === 'usercss-install');
|
||||
|
||||
port.onMessage.addListener(msg => {
|
||||
switch (msg.method) {
|
||||
case 'getSourceCode':
|
||||
pendingSource
|
||||
.then(sourceCode => port.postMessage({method: msg.method + 'Response', sourceCode}))
|
||||
.catch(err => port.postMessage({method: msg.method + 'Response', error: err.message || String(err)}));
|
||||
break;
|
||||
|
||||
case 'liveReloadStart':
|
||||
if (!watcher) {
|
||||
watcher = sourceLoader.watch(sourceCode => {
|
||||
port.postMessage({method: 'sourceCodeChanged', sourceCode});
|
||||
});
|
||||
}
|
||||
watcher.start();
|
||||
break;
|
||||
|
||||
case 'liveReloadStop':
|
||||
watcher.stop();
|
||||
break;
|
||||
|
||||
case 'closeTab':
|
||||
if (history.length > 1) {
|
||||
history.back();
|
||||
} else {
|
||||
runtimeSend({method: 'closeTab'});
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
});
|
||||
return runtimeSend({
|
||||
method: 'openUsercssInstallPage',
|
||||
updateUrl: location.href
|
||||
}).catch(alert);
|
||||
}
|
||||
|
||||
function isUsercss() {
|
||||
if (!/text\/(css|plain)/.test(document.contentType)) {
|
||||
return false;
|
||||
}
|
||||
if (!/==userstyle==/i.test(document.body.textContent)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if (isUsercss()) {
|
||||
initUsercssInstall();
|
||||
}
|
|
@ -1,363 +0,0 @@
|
|||
'use strict';
|
||||
|
||||
const CHROMIUM = chrome.app && /Chromium/.test(navigator.userAgent); // non-Windows Chromium
|
||||
const FIREFOX = !chrome.app;
|
||||
const VIVALDI = chrome.app && /Vivaldi/.test(navigator.userAgent);
|
||||
const OPERA = chrome.app && /OPR/.test(navigator.userAgent);
|
||||
|
||||
document.addEventListener('stylishUpdate', onClick);
|
||||
document.addEventListener('stylishUpdateChrome', onClick);
|
||||
document.addEventListener('stylishUpdateOpera', onClick);
|
||||
|
||||
document.addEventListener('stylishInstall', onClick);
|
||||
document.addEventListener('stylishInstallChrome', onClick);
|
||||
document.addEventListener('stylishInstallOpera', onClick);
|
||||
|
||||
chrome.runtime.onMessage.addListener((msg, sender, sendResponse) => {
|
||||
// orphaned content script check
|
||||
if (msg.method === 'ping') {
|
||||
sendResponse(true);
|
||||
}
|
||||
});
|
||||
|
||||
// TODO: remove the following statement when USO is fixed
|
||||
document.documentElement.appendChild(document.createElement('script')).text = '(' +
|
||||
function () {
|
||||
let settings;
|
||||
document.addEventListener('stylusFixBuggyUSOsettings', function _({detail}) {
|
||||
document.removeEventListener('stylusFixBuggyUSOsettings', _);
|
||||
settings = /\?/.test(detail) && new URLSearchParams(new URL(detail).search);
|
||||
});
|
||||
const originalResponseJson = Response.prototype.json;
|
||||
Response.prototype.json = function (...args) {
|
||||
return originalResponseJson.call(this, ...args).then(json => {
|
||||
Response.prototype.json = originalResponseJson;
|
||||
if (!settings || typeof ((json || {}).style_settings || {}).every !== 'function') {
|
||||
return json;
|
||||
}
|
||||
const images = new Map();
|
||||
for (const jsonSetting of json.style_settings) {
|
||||
let value = settings.get('ik-' + jsonSetting.install_key);
|
||||
if (!value
|
||||
|| !jsonSetting.style_setting_options
|
||||
|| !jsonSetting.style_setting_options[0]) {
|
||||
continue;
|
||||
}
|
||||
if (value.startsWith('ik-')) {
|
||||
value = value.replace(/^ik-/, '');
|
||||
const defaultItem = jsonSetting.style_setting_options.find(item => item.default);
|
||||
if (!defaultItem || defaultItem.install_key !== value) {
|
||||
if (defaultItem) {
|
||||
defaultItem.default = false;
|
||||
}
|
||||
jsonSetting.style_setting_options.some(item => {
|
||||
if (item.install_key === value) {
|
||||
item.default = true;
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
} else if (jsonSetting.setting_type === 'image') {
|
||||
jsonSetting.style_setting_options.some(item => {
|
||||
if (item.default) {
|
||||
item.default = false;
|
||||
return true;
|
||||
}
|
||||
});
|
||||
images.set(jsonSetting.install_key, value);
|
||||
} else {
|
||||
const item = jsonSetting.style_setting_options[0];
|
||||
if (item.value !== value && item.install_key === 'placeholder') {
|
||||
item.value = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (images.size) {
|
||||
new MutationObserver((_, observer) => {
|
||||
if (!document.getElementById('style-settings')) {
|
||||
return;
|
||||
}
|
||||
observer.disconnect();
|
||||
for (const [name, url] of images.entries()) {
|
||||
const elRadio = document.querySelector(`input[name="ik-${name}"][value="user-url"]`);
|
||||
const elUrl = elRadio && document.getElementById(elRadio.id.replace('url-choice', 'user-url'));
|
||||
if (elUrl) {
|
||||
elUrl.value = url;
|
||||
}
|
||||
}
|
||||
}).observe(document, {childList: true, subtree: true});
|
||||
}
|
||||
return json;
|
||||
});
|
||||
};
|
||||
} + ')()';
|
||||
|
||||
// TODO: remove the following statement when USO pagination is fixed
|
||||
if (location.search.includes('category=')) {
|
||||
document.addEventListener('DOMContentLoaded', function _() {
|
||||
document.removeEventListener('DOMContentLoaded', _);
|
||||
new MutationObserver((_, observer) => {
|
||||
if (!document.getElementById('pagination')) {
|
||||
return;
|
||||
}
|
||||
observer.disconnect();
|
||||
const category = '&' + location.search.match(/category=[^&]+/)[0];
|
||||
const links = document.querySelectorAll('#pagination a[href*="page="]:not([href*="category="])');
|
||||
for (let i = 0; i < links.length; i++) {
|
||||
links[i].href += category;
|
||||
}
|
||||
}).observe(document, {childList: true, subtree: true});
|
||||
});
|
||||
}
|
||||
|
||||
new MutationObserver((mutations, observer) => {
|
||||
if (document.body) {
|
||||
observer.disconnect();
|
||||
// TODO: remove the following statement when USO pagination title is fixed
|
||||
document.title = document.title.replace(/^(\d+)&\w+=/, '#$1: ');
|
||||
chrome.runtime.sendMessage({
|
||||
method: 'getStyles',
|
||||
url: getMeta('stylish-id-url') || location.href
|
||||
}, checkUpdatability);
|
||||
}
|
||||
}).observe(document.documentElement, {childList: true});
|
||||
|
||||
/* since we are using "stylish-code-chrome" meta key on all browsers and
|
||||
US.o does not provide "advanced settings" on this url if browser is not Chrome,
|
||||
we need to fix this URL using "stylish-update-url" meta key
|
||||
*/
|
||||
function getStyleURL() {
|
||||
const url = getMeta('stylish-code-chrome');
|
||||
// TODO: remove when USO is fixed
|
||||
const directUrl = getMeta('stylish-update-url');
|
||||
if (directUrl.includes('?') && !url.includes('?')) {
|
||||
/* get custom settings from the update url */
|
||||
return Object.assign(new URL(url), {
|
||||
search: (new URL(directUrl)).search
|
||||
}).href;
|
||||
}
|
||||
return url;
|
||||
}
|
||||
|
||||
function checkUpdatability([installedStyle]) {
|
||||
// TODO: remove the following statement when USO is fixed
|
||||
document.dispatchEvent(new CustomEvent('stylusFixBuggyUSOsettings', {
|
||||
detail: installedStyle && installedStyle.updateUrl,
|
||||
}));
|
||||
if (!installedStyle) {
|
||||
sendEvent('styleCanBeInstalledChrome');
|
||||
return;
|
||||
}
|
||||
const md5Url = getMeta('stylish-md5-url');
|
||||
if (md5Url && installedStyle.md5Url && installedStyle.originalMd5) {
|
||||
getResource(md5Url).then(md5 => {
|
||||
reportUpdatable(md5 !== installedStyle.originalMd5);
|
||||
});
|
||||
} else {
|
||||
getResource(getStyleURL()).then(code => {
|
||||
reportUpdatable(code === null ||
|
||||
!styleSectionsEqual(JSON.parse(code), installedStyle));
|
||||
});
|
||||
}
|
||||
|
||||
function reportUpdatable(isUpdatable) {
|
||||
sendEvent(
|
||||
isUpdatable
|
||||
? 'styleCanBeUpdatedChrome'
|
||||
: 'styleAlreadyInstalledChrome',
|
||||
{
|
||||
updateUrl: installedStyle.updateUrl
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function sendEvent(type, detail = null) {
|
||||
if (FIREFOX) {
|
||||
type = type.replace('Chrome', '');
|
||||
} else if (OPERA || VIVALDI) {
|
||||
type = type.replace('Chrome', 'Opera');
|
||||
}
|
||||
detail = {detail};
|
||||
if (typeof cloneInto !== 'undefined') {
|
||||
// Firefox requires explicit cloning, however USO can't process our messages anyway
|
||||
// because USO tries to use a global "event" variable deprecated in Firefox
|
||||
detail = cloneInto(detail, document); // eslint-disable-line no-undef
|
||||
}
|
||||
onDOMready().then(() => {
|
||||
document.dispatchEvent(new CustomEvent(type, detail));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function onClick(event) {
|
||||
if (onClick.processing || !orphanCheck || !orphanCheck()) {
|
||||
return;
|
||||
}
|
||||
onClick.processing = true;
|
||||
(event.type.includes('Update') ? onUpdate() : onInstall())
|
||||
.then(done, done);
|
||||
function done() {
|
||||
setTimeout(() => {
|
||||
onClick.processing = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function onInstall() {
|
||||
return getResource(getMeta('stylish-description'))
|
||||
.then(name => saveStyleCode('styleInstall', name))
|
||||
.then(() => getResource(getMeta('stylish-install-ping-url-chrome')));
|
||||
}
|
||||
|
||||
|
||||
function onUpdate() {
|
||||
return new Promise((resolve, reject) => {
|
||||
chrome.runtime.sendMessage({
|
||||
method: 'getStyles',
|
||||
url: getMeta('stylish-id-url') || location.href,
|
||||
}, ([style]) => {
|
||||
saveStyleCode('styleUpdate', style.name, {id: style.id})
|
||||
.then(resolve, reject);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function saveStyleCode(message, name, addProps) {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (!confirm(chrome.i18n.getMessage(message, [name]))) {
|
||||
reject();
|
||||
return;
|
||||
}
|
||||
enableUpdateButton(false);
|
||||
getResource(getStyleURL()).then(code => {
|
||||
chrome.runtime.sendMessage(
|
||||
Object.assign(JSON.parse(code), addProps, {
|
||||
method: 'saveStyle',
|
||||
reason: 'update',
|
||||
}),
|
||||
style => {
|
||||
if (message === 'styleUpdate' && style.updateUrl.includes('?')) {
|
||||
enableUpdateButton(true);
|
||||
} else {
|
||||
sendEvent('styleInstalledChrome');
|
||||
}
|
||||
}
|
||||
);
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
|
||||
function enableUpdateButton(state) {
|
||||
const button = document.getElementById('update_style_button');
|
||||
if (button) {
|
||||
button.style.cssText = state ? '' :
|
||||
'pointer-events: none !important; opacity: .25 !important;';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function getMeta(name) {
|
||||
const e = document.querySelector(`link[rel="${name}"]`);
|
||||
return e ? e.getAttribute('href') : null;
|
||||
}
|
||||
|
||||
|
||||
function getResource(url) {
|
||||
return new Promise(resolve => {
|
||||
if (url.startsWith('#')) {
|
||||
resolve(document.getElementById(url.slice(1)).textContent);
|
||||
} else {
|
||||
chrome.runtime.sendMessage({method: 'download', url}, resolve);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function styleSectionsEqual({sections: a}, {sections: b}) {
|
||||
if (!a || !b) {
|
||||
return undefined;
|
||||
}
|
||||
if (a.length !== b.length) {
|
||||
return false;
|
||||
}
|
||||
// order of sections should be identical to account for the case of multiple
|
||||
// sections matching the same URL because the order of rules is part of cascading
|
||||
return a.every((sectionA, index) => propertiesEqual(sectionA, b[index]));
|
||||
|
||||
function propertiesEqual(secA, secB) {
|
||||
for (const name of ['urlPrefixes', 'urls', 'domains', 'regexps']) {
|
||||
if (!equalOrEmpty(secA[name], secB[name], 'every', arrayMirrors)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return equalOrEmpty(secA.code, secB.code, 'substr', (a, b) => a === b);
|
||||
}
|
||||
|
||||
function equalOrEmpty(a, b, telltale, comparator) {
|
||||
const typeA = a && typeof a[telltale] === 'function';
|
||||
const typeB = b && typeof b[telltale] === 'function';
|
||||
return (
|
||||
(a === null || a === undefined || (typeA && !a.length)) &&
|
||||
(b === null || b === undefined || (typeB && !b.length))
|
||||
) || typeA && typeB && a.length === b.length && comparator(a, b);
|
||||
}
|
||||
|
||||
function arrayMirrors(array1, array2) {
|
||||
return (
|
||||
array1.every(el => array2.includes(el)) &&
|
||||
array2.every(el => array1.includes(el))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function onDOMready() {
|
||||
if (document.readyState !== 'loading') {
|
||||
return Promise.resolve();
|
||||
}
|
||||
return new Promise(resolve => {
|
||||
document.addEventListener('DOMContentLoaded', function _() {
|
||||
document.removeEventListener('DOMContentLoaded', _);
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function orphanCheck() {
|
||||
const port = chrome.runtime.connect();
|
||||
if (port) {
|
||||
port.disconnect();
|
||||
return true;
|
||||
}
|
||||
// we're orphaned due to an extension update
|
||||
// we can detach event listeners
|
||||
document.removeEventListener('stylishUpdate', onClick);
|
||||
document.removeEventListener('stylishUpdateChrome', onClick);
|
||||
document.removeEventListener('stylishUpdateOpera', onClick);
|
||||
|
||||
document.removeEventListener('stylishInstall', onClick);
|
||||
document.removeEventListener('stylishInstallChrome', onClick);
|
||||
document.removeEventListener('stylishInstallOpera', onClick);
|
||||
|
||||
// we can't detach chrome.runtime.onMessage because it's no longer connected internally
|
||||
// we can destroy global functions in this context to free up memory
|
||||
[
|
||||
'checkUpdatability',
|
||||
'getMeta',
|
||||
'getResource',
|
||||
'onDOMready',
|
||||
'onClick',
|
||||
'onInstall',
|
||||
'onUpdate',
|
||||
'orphanCheck',
|
||||
'saveStyleCode',
|
||||
'sendEvent',
|
||||
'styleSectionsEqual',
|
||||
].forEach(fn => (window[fn] = null));
|
||||
}
|
345
content/style-injector.js
Normal file
345
content/style-injector.js
Normal file
|
@ -0,0 +1,345 @@
|
|||
'use strict';
|
||||
|
||||
/** @type {function(opts):StyleInjector} */
|
||||
window.StyleInjector = window.INJECTED === 1 ? window.StyleInjector : ({
|
||||
compare,
|
||||
onUpdate = () => {},
|
||||
}) => {
|
||||
const PREFIX = 'stylus-';
|
||||
const PATCH_ID = 'transition-patch';
|
||||
// styles are out of order if any of these elements is injected between them
|
||||
const ORDERED_TAGS = new Set(['head', 'body', 'frameset', 'style', 'link']);
|
||||
const docRewriteObserver = RewriteObserver(sort);
|
||||
const docRootObserver = RootObserver(sortIfNeeded);
|
||||
const toSafeChar = c => String.fromCharCode(0xFF00 + c.charCodeAt(0) - 0x20);
|
||||
const list = [];
|
||||
const table = new Map();
|
||||
let isEnabled = true;
|
||||
let isTransitionPatched = chrome.app && CSS.supports('accent-color', 'red'); // Chrome 93
|
||||
let exposeStyleName;
|
||||
// will store the original method refs because the page can override them
|
||||
let creationDoc, createElement, createElementNS;
|
||||
|
||||
return /** @namespace StyleInjector */ {
|
||||
|
||||
list,
|
||||
|
||||
async apply(styleMap) {
|
||||
const styles = styleMapToArray(styleMap);
|
||||
const value = !styles.length
|
||||
? []
|
||||
: await docRootObserver.evade(() => {
|
||||
if (!isTransitionPatched && isEnabled) {
|
||||
applyTransitionPatch(styles);
|
||||
}
|
||||
return styles.map(addUpdate);
|
||||
});
|
||||
emitUpdate();
|
||||
return value;
|
||||
},
|
||||
|
||||
clear() {
|
||||
addRemoveElements(false);
|
||||
list.length = 0;
|
||||
table.clear();
|
||||
emitUpdate();
|
||||
},
|
||||
|
||||
clearOrphans() {
|
||||
for (const el of document.querySelectorAll(`style[id^="${PREFIX}"].stylus`)) {
|
||||
const id = el.id.slice(PREFIX.length);
|
||||
if (/^\d+$/.test(id) || id === PATCH_ID) {
|
||||
el.remove();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
remove(id) {
|
||||
remove(id);
|
||||
emitUpdate();
|
||||
},
|
||||
|
||||
replace(styleMap) {
|
||||
const styles = styleMapToArray(styleMap);
|
||||
const added = new Set(styles.map(s => s.id));
|
||||
const removed = [];
|
||||
for (const style of list) {
|
||||
if (!added.has(style.id)) {
|
||||
removed.push(style.id);
|
||||
}
|
||||
}
|
||||
styles.forEach(addUpdate);
|
||||
removed.forEach(remove);
|
||||
emitUpdate();
|
||||
},
|
||||
|
||||
toggle(enable) {
|
||||
if (isEnabled === enable) return;
|
||||
isEnabled = enable;
|
||||
if (!enable) toggleObservers(false);
|
||||
addRemoveElements(enable);
|
||||
if (enable) toggleObservers(true);
|
||||
},
|
||||
|
||||
sort: sort,
|
||||
};
|
||||
|
||||
function add(style) {
|
||||
const el = style.el = createStyle(style);
|
||||
const i = list.findIndex(item => compare(item, style) > 0);
|
||||
table.set(style.id, style);
|
||||
if (isEnabled) {
|
||||
document.documentElement.insertBefore(el, i < 0 ? null : list[i].el);
|
||||
}
|
||||
list.splice(i < 0 ? list.length : i, 0, style);
|
||||
return el;
|
||||
}
|
||||
|
||||
function addRemoveElements(add) {
|
||||
for (const {el} of list) {
|
||||
if (add) {
|
||||
document.documentElement.appendChild(el);
|
||||
} else {
|
||||
el.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function addUpdate(style) {
|
||||
return table.has(style.id) ? update(style) : add(style);
|
||||
}
|
||||
|
||||
function applyTransitionPatch(styles) {
|
||||
isTransitionPatched = true;
|
||||
// CSS transition bug workaround: since we insert styles asynchronously,
|
||||
// the browsers, especially Firefox, may apply all transitions on page load
|
||||
if (document.readyState === 'complete' ||
|
||||
document.visibilityState === 'hidden' ||
|
||||
!styles.some(s => s.code.includes('transition'))) {
|
||||
return;
|
||||
}
|
||||
const el = createStyle({id: PATCH_ID, code: `
|
||||
:root:not(#\\0):not(#\\0) * {
|
||||
transition: none !important;
|
||||
}
|
||||
`});
|
||||
document.documentElement.appendChild(el);
|
||||
// wait for the next paint to complete
|
||||
// note: requestAnimationFrame won't fire in inactive tabs
|
||||
requestAnimationFrame(() => setTimeout(() => el.remove()));
|
||||
}
|
||||
|
||||
function createStyle(style = {}) {
|
||||
const {id} = style;
|
||||
if (!creationDoc) initCreationDoc();
|
||||
let el;
|
||||
if (document.documentElement instanceof SVGSVGElement) {
|
||||
// SVG document style
|
||||
el = createElementNS.call(creationDoc, 'http://www.w3.org/2000/svg', 'style');
|
||||
} else if (document instanceof XMLDocument) {
|
||||
// XML document style
|
||||
el = createElementNS.call(creationDoc, 'http://www.w3.org/1999/xhtml', 'style');
|
||||
} else {
|
||||
// HTML document style; also works on HTML-embedded SVG
|
||||
el = createElement.call(creationDoc, 'style');
|
||||
}
|
||||
if (id) {
|
||||
el.id = `${PREFIX}${id}`;
|
||||
const oldEl = document.getElementById(el.id);
|
||||
if (oldEl) oldEl.id += '-superseded-by-Stylus';
|
||||
}
|
||||
el.type = 'text/css';
|
||||
// SVG className is not a string, but an instance of SVGAnimatedString
|
||||
el.classList.add('stylus');
|
||||
setTextAndName(el, style);
|
||||
return el;
|
||||
}
|
||||
|
||||
function setTextAndName(el, {id, code = '', name}) {
|
||||
if (exposeStyleName && name) {
|
||||
el.dataset.name = name;
|
||||
name = encodeURIComponent(name.replace(/[?#/']/g, toSafeChar));
|
||||
code += `\n/*# sourceURL=${chrome.runtime.getURL(name)}.user.css#${id} */`;
|
||||
}
|
||||
el.textContent = code;
|
||||
}
|
||||
|
||||
function toggleObservers(shouldStart) {
|
||||
const onOff = shouldStart && isEnabled ? 'start' : 'stop';
|
||||
docRewriteObserver[onOff]();
|
||||
docRootObserver[onOff]();
|
||||
}
|
||||
|
||||
function emitUpdate() {
|
||||
toggleObservers(list.length);
|
||||
onUpdate();
|
||||
}
|
||||
|
||||
/*
|
||||
FF59+ workaround: allow the page to read our sheets, https://github.com/openstyles/stylus/issues/461
|
||||
First we're trying the page context document where inline styles may be forbidden by CSP
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=1579345#c3
|
||||
and since userAgent.navigator can be spoofed via about:config or devtools,
|
||||
we're checking for getPreventDefault that was removed in FF59
|
||||
*/
|
||||
function initCreationDoc() {
|
||||
creationDoc = !Event.prototype.getPreventDefault && document.wrappedJSObject;
|
||||
if (creationDoc) {
|
||||
({createElement, createElementNS} = creationDoc);
|
||||
const el = document.documentElement.appendChild(createStyle());
|
||||
const isApplied = el.sheet;
|
||||
el.remove();
|
||||
if (isApplied) return;
|
||||
}
|
||||
creationDoc = document;
|
||||
({createElement, createElementNS} = document);
|
||||
}
|
||||
|
||||
function remove(id) {
|
||||
const style = table.get(id);
|
||||
if (!style) return;
|
||||
table.delete(id);
|
||||
list.splice(list.indexOf(style), 1);
|
||||
style.el.remove();
|
||||
}
|
||||
|
||||
function sort() {
|
||||
docRootObserver.evade(() => {
|
||||
list.sort(compare);
|
||||
addRemoveElements(true);
|
||||
});
|
||||
}
|
||||
|
||||
function sortIfNeeded() {
|
||||
let needsSort;
|
||||
let el = list.length && list[0].el;
|
||||
if (!el) {
|
||||
needsSort = false;
|
||||
} else if (el.parentNode !== creationDoc.documentElement) {
|
||||
needsSort = true;
|
||||
} else {
|
||||
let i = 0;
|
||||
while (el) {
|
||||
if (i < list.length && el === list[i].el) {
|
||||
i++;
|
||||
} else if (ORDERED_TAGS.has(el.localName)) {
|
||||
needsSort = true;
|
||||
break;
|
||||
}
|
||||
el = el.nextElementSibling;
|
||||
}
|
||||
// some styles are not injected to the document
|
||||
if (i < list.length) needsSort = true;
|
||||
}
|
||||
if (needsSort) sort();
|
||||
return needsSort;
|
||||
}
|
||||
|
||||
function styleMapToArray(styleMap) {
|
||||
if (styleMap.cfg) {
|
||||
({exposeStyleName} = styleMap.cfg);
|
||||
delete styleMap.cfg;
|
||||
}
|
||||
return Object.values(styleMap).map(({id, code, name}) => ({
|
||||
id,
|
||||
name,
|
||||
code: code.join(''),
|
||||
}));
|
||||
}
|
||||
|
||||
function update(newStyle) {
|
||||
const {id, code} = newStyle;
|
||||
const style = table.get(id);
|
||||
if (style.code !== code ||
|
||||
style.name !== newStyle.name && exposeStyleName) {
|
||||
style.code = code;
|
||||
setTextAndName(style.el, newStyle);
|
||||
}
|
||||
}
|
||||
|
||||
function RewriteObserver(onChange) {
|
||||
// detect documentElement being rewritten from inside the script
|
||||
let root;
|
||||
let observing = false;
|
||||
let timer;
|
||||
const observer = new MutationObserver(check);
|
||||
return {start, stop};
|
||||
|
||||
function start() {
|
||||
if (observing) return;
|
||||
// detect dynamic iframes rewritten after creation by the embedder i.e. externally
|
||||
root = document.documentElement;
|
||||
timer = setTimeout(check);
|
||||
observer.observe(document, {childList: true});
|
||||
observing = true;
|
||||
}
|
||||
|
||||
function stop() {
|
||||
if (!observing) return;
|
||||
clearTimeout(timer);
|
||||
observer.disconnect();
|
||||
observing = false;
|
||||
}
|
||||
|
||||
function check() {
|
||||
if (root !== document.documentElement) {
|
||||
root = document.documentElement;
|
||||
onChange();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function RootObserver(onChange) {
|
||||
let digest = 0;
|
||||
let lastCalledTime = NaN;
|
||||
let observing = false;
|
||||
const observer = new MutationObserver(() => {
|
||||
if (digest) {
|
||||
if (performance.now() - lastCalledTime > 1000) {
|
||||
digest = 0;
|
||||
} else if (digest > 5) {
|
||||
throw new Error('The page keeps generating mutations. Skip the event.');
|
||||
}
|
||||
}
|
||||
if (onChange()) {
|
||||
digest++;
|
||||
lastCalledTime = performance.now();
|
||||
}
|
||||
});
|
||||
return {evade, start, stop};
|
||||
|
||||
function evade(fn) {
|
||||
const restore = observing && start;
|
||||
stop();
|
||||
return new Promise(resolve => run(fn, resolve, waitForRoot))
|
||||
.then(restore);
|
||||
}
|
||||
|
||||
function start() {
|
||||
if (observing) return;
|
||||
observer.observe(document.documentElement, {childList: true});
|
||||
observing = true;
|
||||
}
|
||||
|
||||
function stop() {
|
||||
if (!observing) return;
|
||||
// FIXME: do we need this?
|
||||
observer.takeRecords();
|
||||
observer.disconnect();
|
||||
observing = false;
|
||||
}
|
||||
|
||||
function run(fn, resolve, wait) {
|
||||
if (document.documentElement) {
|
||||
resolve(fn());
|
||||
return true;
|
||||
}
|
||||
if (wait) wait(fn, resolve);
|
||||
}
|
||||
|
||||
function waitForRoot(...args) {
|
||||
new MutationObserver((_, observer) => run(...args) && observer.disconnect())
|
||||
.observe(document, {childList: true});
|
||||
}
|
||||
}
|
||||
};
|
|
@ -1,10 +0,0 @@
|
|||
'use strict';
|
||||
|
||||
function runtimeSend(request) {
|
||||
return new Promise((resolve, reject) => {
|
||||
chrome.runtime.sendMessage(
|
||||
request,
|
||||
({success, result}) => (success ? resolve : reject)(result)
|
||||
);
|
||||
});
|
||||
}
|
609
edit.html
609
edit.html
|
@ -1,248 +1,507 @@
|
|||
<!DOCTYPE html>
|
||||
<html id="stylus">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<style id="firefox-transitions-bug-suppressor">
|
||||
/* restrict to FF */
|
||||
@-moz-document url-prefix("") {
|
||||
/* increased specificity to override sane selectors in user styles */
|
||||
html#stylus.firefox #stylus-edit #header *,
|
||||
html#stylus.firefox #stylus-edit #sections * {
|
||||
transition: none !important;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<link href="global.css" rel="stylesheet">
|
||||
<link href="global-dark.css" rel="stylesheet">
|
||||
<style id="cm-theme"></style>
|
||||
|
||||
<script src="js/dom.js"></script>
|
||||
<script src="js/messaging.js"></script>
|
||||
<script src="js/polyfill.js"></script>
|
||||
<script src="js/toolbox.js"></script>
|
||||
<script src="js/msg.js"></script>
|
||||
<script src="js/prefs.js"></script>
|
||||
<script src="js/dom.js"></script>
|
||||
<script src="js/localization.js"></script>
|
||||
<script src="js/script-loader.js"></script>
|
||||
<script src="js/moz-parser.js"></script>
|
||||
<script src="content/style-injector.js"></script>
|
||||
<script src="content/apply.js"></script>
|
||||
<link rel="stylesheet" href="edit/edit.css">
|
||||
<script src="edit/lint.js"></script>
|
||||
<script src="edit/util.js"></script>
|
||||
<script src="edit/regexp-tester.js"></script>
|
||||
<script src="edit/applies-to-line-widget.js"></script>
|
||||
<script src="edit/source-editor.js"></script>
|
||||
<script src="edit/edit.js"></script>
|
||||
|
||||
<script src="js/sections-util.js"></script>
|
||||
<script src="js/storage-util.js"></script>
|
||||
<script src="edit/codemirror-themes.js"></script> <!-- must precede base.js -->
|
||||
<script src="edit/base.js"></script>
|
||||
|
||||
<script src="vendor/codemirror/lib/codemirror.js"></script>
|
||||
<link rel="stylesheet" href="vendor/codemirror/lib/codemirror.css">
|
||||
<script src="vendor/codemirror/mode/css/css.js"></script>
|
||||
|
||||
<link rel="stylesheet" href="vendor/codemirror/addon/dialog/dialog.css">
|
||||
<link rel="stylesheet" href="vendor/codemirror/addon/search/matchesonscrollbar.css">
|
||||
<script src="vendor/codemirror/addon/scroll/annotatescrollbar.js"></script>
|
||||
<script src="vendor/codemirror/addon/search/matchesonscrollbar.js"></script>
|
||||
<script src="vendor-overwrites/codemirror/addon/search/match-highlighter.js"></script>
|
||||
<script src="vendor/codemirror/mode/stylus/stylus.js"></script>
|
||||
<script src="vendor/codemirror/addon/dialog/dialog.js"></script>
|
||||
<script src="vendor/codemirror/addon/edit/closebrackets.js"></script>
|
||||
<script src="vendor/codemirror/addon/scroll/annotatescrollbar.js"></script>
|
||||
<script src="vendor/codemirror/addon/search/searchcursor.js"></script>
|
||||
<script src="vendor/codemirror/addon/search/search.js"></script>
|
||||
<script src="vendor/codemirror/addon/search/matchesonscrollbar.js"></script>
|
||||
<script src="vendor/codemirror/addon/comment/comment.js"></script>
|
||||
<script src="vendor/codemirror/addon/selection/active-line.js"></script>
|
||||
|
||||
<link rel="stylesheet" href="vendor/codemirror/addon/fold/foldgutter.css" />
|
||||
<script src="vendor/codemirror/addon/edit/matchbrackets.js"></script>
|
||||
<script src="vendor/codemirror/addon/fold/foldcode.js"></script>
|
||||
<script src="vendor/codemirror/addon/fold/foldgutter.js"></script>
|
||||
<script src="vendor/codemirror/addon/fold/brace-fold.js"></script>
|
||||
<script src="vendor/codemirror/addon/fold/indent-fold.js"></script>
|
||||
<script src="vendor/codemirror/addon/fold/comment-fold.js"></script>
|
||||
|
||||
<script src="vendor/codemirror/addon/edit/matchbrackets.js"></script>
|
||||
|
||||
<link rel="stylesheet" href="vendor/codemirror/addon/lint/lint.css" />
|
||||
<link rel="stylesheet" href="vendor/codemirror/addon/hint/show-hint.css" />
|
||||
<script src="vendor/codemirror/addon/lint/lint.js"></script>
|
||||
<script src="vendor/codemirror/addon/hint/show-hint.js"></script>
|
||||
<script src="vendor/codemirror/addon/hint/css-hint.js"></script>
|
||||
|
||||
<script src="vendor/codemirror/addon/mode/loadmode.js"></script>
|
||||
|
||||
<script src="vendor/codemirror/keymap/sublime.js"></script>
|
||||
<script src="vendor/codemirror/keymap/emacs.js"></script>
|
||||
<script src="vendor/codemirror/keymap/sublime.js"></script>
|
||||
<script src="vendor/codemirror/keymap/vim.js"></script>
|
||||
<script src="vendor-overwrites/codemirror-addon/match-highlighter.js"></script>
|
||||
|
||||
<script src="/edit/codemirror-default.js"></script>
|
||||
<link rel="stylesheet" href="/edit/codemirror-default.css">
|
||||
<link id="cm-theme" rel="stylesheet">
|
||||
<script src="js/color/color-converter.js"></script>
|
||||
<script src="js/color/color-mimicry.js"></script>
|
||||
<script src="js/color/color-picker.js"></script>
|
||||
<script src="js/color/color-view.js"></script>
|
||||
<script src="js/worker-util.js"></script>
|
||||
|
||||
<script src="edit/util.js"></script>
|
||||
<script src="edit/codemirror-default.js"></script>
|
||||
<script src="edit/codemirror-factory.js"></script>
|
||||
<script src="edit/moz-section-finder.js"></script>
|
||||
<script src="edit/moz-section-widget.js"></script>
|
||||
<script src="edit/linter-manager.js"></script>
|
||||
<script src="edit/beautify.js"></script>
|
||||
<script src="edit/source-editor.js"></script>
|
||||
<script src="edit/sections-editor-section.js"></script>
|
||||
<script src="edit/sections-editor.js"></script>
|
||||
<script src="edit/usw-integration.js"></script>
|
||||
|
||||
<template data-id="appliesTo">
|
||||
<li>
|
||||
<select name="applies-type" class="applies-type style-contributor">
|
||||
<option value="url" i18n-text="appliesUrlOption"></option>
|
||||
<option value="url-prefix" i18n-text="appliesUrlPrefixOption"></option>
|
||||
<option value="domain" i18n-text="appliesDomainOption"></option>
|
||||
<option value="regexp" i18n-text="appliesRegexpOption"></option>
|
||||
</select>
|
||||
<input name="applies-value" class="applies-value style-contributor">
|
||||
<button class="remove-applies-to" i18n-text="appliesRemove"></button>
|
||||
<button class="add-applies-to" i18n-text="appliesAdd"></button>
|
||||
<li class="applies-to-item">
|
||||
<div class="select-resizer">
|
||||
<select name="applies-type" class="applies-type style-contributor">
|
||||
<option value="url" i18n="appliesUrlOption"></option>
|
||||
<option value="url-prefix" i18n="appliesUrlPrefixOption"></option>
|
||||
<option value="domain" i18n="appliesDomainOption"></option>
|
||||
<option value="regexp" i18n="appliesRegexpOption"></option>
|
||||
</select>
|
||||
<svg class="svg-icon select-arrow"><use xlink:href="#svg-icon-select-arrow"/></svg>
|
||||
</div>
|
||||
<div class="applies-value-wrapper">
|
||||
<input name="applies-value" class="applies-value style-contributor" spellcheck="false">
|
||||
<a class="remove-applies-to" i18n="appliesRemove, title:appliesRemove" tabindex="0">
|
||||
<svg class="svg-icon remove"><use xlink:href="#svg-icon-minus"/></svg>
|
||||
</a>
|
||||
<a class="add-applies-to" i18n="appliesAdd, title:appliesAdd" tabindex="0">
|
||||
<svg class="svg-icon add"><use xlink:href="#svg-icon-plus"/></svg>
|
||||
</a>
|
||||
</div>
|
||||
</li>
|
||||
</template>
|
||||
|
||||
<template data-id="appliesToEverything">
|
||||
<li class="applies-to-everything" i18n-text="appliesToEverything">
|
||||
<button class="add-applies-to" i18n-text="appliesSpecify"></button>
|
||||
<li class="applies-to-everything" i18n="appliesToEverything">
|
||||
<a class="add-applies-to" i18n="appliesAdd, title:appliesAdd" tabindex="0">
|
||||
<svg class="svg-icon add"><use xlink:href="#svg-icon-plus"/></svg>
|
||||
</a>
|
||||
</li>
|
||||
</template>
|
||||
|
||||
<template data-id="section">
|
||||
<div>
|
||||
<label i18n-text="sectionCode"></label>
|
||||
<textarea class="code"></textarea>
|
||||
<br>
|
||||
<div class="section">
|
||||
<!-- not using DIV to make our CSS work for #sections > div:only-of-type .remove-section -->
|
||||
<p class="deleted-section">
|
||||
<button class="restore-section" i18n="sectionRestore"></button>
|
||||
</p>
|
||||
<label i18n="sectionCode" class="code-label"></label>
|
||||
<div class="applies-to">
|
||||
<label i18n-text="appliesLabel">
|
||||
<svg class="svg-icon info applies-to-help"><use xlink:href="#svg-icon-help"/></svg>
|
||||
<label i18n="appliesLabel, title:appliesHelp" data-cmd="note">
|
||||
<a class="svg-inline-wrapper applies-to-help" tabindex="0">
|
||||
<svg class="svg-icon info"><use xlink:href="#svg-icon-help"/></svg>
|
||||
</a>
|
||||
</label>
|
||||
<ul class="applies-to-list"></ul>
|
||||
</div>
|
||||
<button class="remove-section" i18n-text="sectionRemove"></button>
|
||||
<button class="add-section" i18n-text="sectionAdd"></button>
|
||||
<button class="beautify-section" i18n-text="styleBeautify"></button>
|
||||
<button class="test-regexp" i18n-text="styleRegexpTestButton"></button>
|
||||
<div class="edit-actions">
|
||||
<button class="remove-section" i18n="sectionRemove"></button>
|
||||
<button class="add-section" i18n="long-text:sectionAdd, short-text:genericAdd"></button>
|
||||
<button class="clone-section" i18n="genericClone"></button>
|
||||
<button class="move-section-up"></button>
|
||||
<button class="move-section-down"></button>
|
||||
<button class="beautify-section" i18n="styleBeautify"></button>
|
||||
<button class="test-regexp" i18n="genericTest"></button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template data-id="searchReplaceDialog">
|
||||
<div id="search-replace-dialog">
|
||||
<div data-type="main">
|
||||
<div data-type="content"></div>
|
||||
<div data-type="actions">
|
||||
<a data-action="case" i18n="title:searchCaseSensitive" tabindex="0">Aa</a>
|
||||
<a data-action="prev" i18n="title:genericPrevious" data-hotkey-tooltip="findPrev" tabindex="0">
|
||||
<svg class="svg-icon" style="transform: rotate(180deg)"><use xlink:href="#svg-icon-v"/></svg>
|
||||
</a>
|
||||
<a data-action="next" i18n="title:genericNext" data-hotkey-tooltip="findNext" tabindex="0">
|
||||
<svg class="svg-icon"><use xlink:href="#svg-icon-v"/></svg>
|
||||
</a>
|
||||
<a data-action="close" i18n="title:confirmClose" data-hotkey-tooltip="=Esc" tabindex="0">
|
||||
<svg class="svg-icon dismiss"><use xlink:href="#svg-icon-close"/></svg>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div data-type="status">
|
||||
<div class="CodeMirror-search-hint" i18n-text="searchRegexp"></div>
|
||||
<div data-type="tally" i18n="title:searchNumberOfResults"></div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template data-id="clearSearch">
|
||||
<div data-type="hover" i18n="title:confirmDelete">
|
||||
<svg data-action="clear" class="svg-icon"><use xlink:href="#svg-icon-close"></use></svg>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template data-id="find">
|
||||
<span i18n-text="search">: <input type="text" class="CodeMirror-search-field" spellcheck="false">
|
||||
<span class="CodeMirror-search-hint">(<span i18n-text="searchRegexp"></span>)</span>
|
||||
</span>
|
||||
<div data-type="content">
|
||||
<div data-type="input-wrapper">
|
||||
<textarea class="CodeMirror-search-field" rows="1" spellcheck="false" required
|
||||
i18n="placeholder:search"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template data-id="replace">
|
||||
<span i18n-text="replace">: <input type="text" class="CodeMirror-search-field" spellcheck="false">
|
||||
<span class="CodeMirror-search-hint">(<span i18n-text="searchRegexp"></span>)</span>
|
||||
</span>
|
||||
</template>
|
||||
<template data-id="replaceAll">
|
||||
<span i18n-text="replaceAll">: <input type="text" class="CodeMirror-search-field" spellcheck="false">
|
||||
<span class="CodeMirror-search-hint">(<span i18n-text="searchRegexp"></span>)</span>
|
||||
</span>
|
||||
</template>
|
||||
<template data-id="replaceWith">
|
||||
<span i18n-text="replaceWith">: <input type="text" class="CodeMirror-search-field" spellcheck="false">
|
||||
</span>
|
||||
</template>
|
||||
<template data-id="replaceConfirm">
|
||||
<span i18n-text="replace">?
|
||||
<button i18n-text="confirmYes"></button>
|
||||
<button i18n-text="confirmNo"></button>
|
||||
<button i18n-text="confirmStop"></button>
|
||||
</span>
|
||||
<div data-type="content">
|
||||
<div data-type="input-wrapper">
|
||||
<textarea data-type="replace-from"
|
||||
i18n="placeholder:replace"
|
||||
class="CodeMirror-search-field" rows="1" required
|
||||
spellcheck="false"></textarea>
|
||||
</div>
|
||||
<div data-type="input-wrapper">
|
||||
<textarea data-type="replace-to"
|
||||
i18n="placeholder:replaceWith"
|
||||
class="CodeMirror-search-field" rows="1" required
|
||||
spellcheck="false"></textarea>
|
||||
</div>
|
||||
<button data-action="replace" i18n="replace" disabled></button>
|
||||
<button data-action="replaceAll" i18n="replaceAll" disabled></button>
|
||||
<button data-action="undo" i18n="undo" disabled></button>
|
||||
<!--
|
||||
Using a separate set of buttons because
|
||||
1. FF can display tooltips only when specified on the <button>, ignores the nested <title> in <svg>
|
||||
2. the icon doesn't fill the entire button area so tooltips aren't shown when the edges are hovered
|
||||
-->
|
||||
<button class="hidden" data-action="replace" i18n="title:replace" disabled>
|
||||
<svg class="svg-icon" viewBox="0 0 20 20">
|
||||
<polygon points="15.83 4.75 8.76 11.82 5.2 8.26 3.51 9.95 8.76 15.19 17.52 6.43 15.83 4.75"/>
|
||||
</svg>
|
||||
</button>
|
||||
<button class="hidden" data-action="replaceAll" i18n="title:replaceAll" disabled>
|
||||
<svg class="svg-icon" viewBox="0 0 20 20">
|
||||
<polygon points="15.8,1.8 8.8,8.8 5.2,5.3 3.5,6.9 8.8,12.2 17.5,3.4 "/>
|
||||
<polygon points="15.8,7.8 8.8,14.8 5.2,11.3 3.5,12.9 8.8,18.2 17.5,9.4 "/>
|
||||
</svg>
|
||||
</button>
|
||||
<button class="hidden" data-action="undo" i18n="title:undo" disabled>
|
||||
<svg class="svg-icon" viewBox="0 0 20 20">
|
||||
<path d="M11.3,5.5H8.7V1.4L1.9,6.5l6.8,5.1V7.5h2.6c1.8,0,3.2,1.4,3.2,3.2s-1.4,3.2-3.2,3.2H7.8v2h3.5c2.9,0,5.2-2.3,5.2-5.2S14.2,5.5,11.3,5.5z"/>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template data-id="jumpToLine">
|
||||
<span i18n-text="editGotoLine">: <input class="CodeMirror-jump-field" type="text"></span>
|
||||
<span i18n="editGotoLine">: <input class="CodeMirror-jump-field" type="text"></span>
|
||||
</template>
|
||||
|
||||
<template data-id="regexpTestPartial">
|
||||
<a target="_blank" href="https://github.com/stylish-userstyles/stylish/wiki/Applying-styles-to-specific-sites#advanced-matching-with-regular-expressions"><svg class="svg-icon info"><use xlink:href="#svg-icon-help"/></svg></a>
|
||||
</template>
|
||||
<template data-id="resizeGrip">
|
||||
<div class="resize-grip" i18n-title="cm_resizeGripHint"></div>
|
||||
</template>
|
||||
</head>
|
||||
|
||||
<body id="stylus-edit">
|
||||
<template data-id="resizeGrip">
|
||||
<div class="resize-grip" i18n="title:cm_resizeGripHint"></div>
|
||||
</template>
|
||||
|
||||
<template data-id="keymapHelp">
|
||||
<table class="keymap-list">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><input i18n="placeholder:helpKeyMapHotkey" type="search"></th>
|
||||
<th><input i18n="placeholder:helpKeyMapCommand" type="search"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</template>
|
||||
|
||||
<link href="vendor/codemirror/lib/codemirror.css" rel="stylesheet">
|
||||
<link href="vendor/codemirror/addon/dialog/dialog.css" rel="stylesheet">
|
||||
<link href="vendor/codemirror/addon/fold/foldgutter.css" rel="stylesheet">
|
||||
<link href="vendor/codemirror/addon/hint/show-hint.css" rel="stylesheet">
|
||||
<link href="vendor/codemirror/addon/lint/lint.css" rel="stylesheet">
|
||||
<link href="vendor/codemirror/addon/search/matchesonscrollbar.css" rel="stylesheet">
|
||||
<link href="js/color/color-picker.css" rel="stylesheet">
|
||||
<link href="edit/codemirror-default.css" rel="stylesheet">
|
||||
|
||||
<template data-id="body"> <!-- https://crbug.com/1288447 -->
|
||||
<div id="header">
|
||||
<h1 id="heading"> </h1> <!-- nbsp allocates the actual height which prevents page shift -->
|
||||
<h1 id="heading" i18n="data-edit:editStyleHeading, data-add:addStyleTitle">
|
||||
<a class="usercss-only"
|
||||
href="https://github.com/openstyles/stylus/wiki/Usercss"
|
||||
i18n="title:externalUsercssDocument" target="_blank">
|
||||
<svg class="svg-icon info"><use xlink:href="#svg-icon-help"/></svg>
|
||||
</a>
|
||||
</h1>
|
||||
<section id="basic-info">
|
||||
<div id="basic-info-name">
|
||||
<input id="name" class="style-contributor" i18n-placeholder="styleMissingName" spellcheck="false">
|
||||
<input id="name" class="style-contributor" spellcheck="false">
|
||||
<a id="reset-name" i18n="title:customNameResetHint" tabindex="0" hidden>
|
||||
<svg class="svg-icon" viewBox="0 0 20 20">
|
||||
<polygon points="16.2,5.5 14.5,3.8 10,8.3 5.5,3.8 3.8,5.5 8.3,10 3.8,14.5
|
||||
5.5,16.2 10,11.7 14.5,16.2 16.2,14.5 11.7,10 "/>
|
||||
</svg>
|
||||
</a>
|
||||
<a id="url" target="_blank"><svg class="svg-icon"><use xlink:href="#svg-icon-external-link"/></svg></a>
|
||||
</div>
|
||||
<div id="basic-info-enabled">
|
||||
<input type="checkbox" id="enabled" class="style-contributor">
|
||||
<label for="enabled" id="enabled-label" i18n-text="styleEnabledLabel"></label><!--
|
||||
--><svg id="toggle-style-help" class="svg-icon info">
|
||||
<use xlink:href="#svg-icon-help"/>
|
||||
</svg>
|
||||
<label id="enabled-label"
|
||||
i18n="styleEnabledLabel, title:toggleStyle"
|
||||
data-hotkey-tooltip="toggleStyle">
|
||||
<input type="checkbox" id="enabled" class="style-contributor">
|
||||
<svg class="svg-icon checked"><use xlink:href="#svg-icon-checked"/></svg>
|
||||
</label>
|
||||
<label id="preview-label" i18n="previewLabel, title:previewTooltip">
|
||||
<input type="checkbox" id="editor.livePreview">
|
||||
<svg class="svg-icon checked"><use xlink:href="#svg-icon-checked"/></svg>
|
||||
</label>
|
||||
<label id="disableAll-label" i18n="data-on:disableAllStyles, data-off:disableAllStylesOff">
|
||||
<input id="disableAll" type="checkbox">
|
||||
<svg class="svg-icon checked"><use xlink:href="#svg-icon-checked"/></svg>
|
||||
</label>
|
||||
<span id="preview-errors" hidden>!</span>
|
||||
</div>
|
||||
</section>
|
||||
<section id="actions">
|
||||
<div>
|
||||
<button id="save-button" title="Ctrl-S" i18n-text="styleSaveLabel"></button>
|
||||
<button id="beautify" i18n-text="styleBeautify"></button>
|
||||
<a href="manage.html"><button id="cancel-button" i18n-text="styleCancelEditLabel"></button></a>
|
||||
<div class="buttons">
|
||||
<div class="split-btn">
|
||||
<button id="save-button" i18n="styleSaveLabel" data-hotkey-tooltip="save" disabled></button
|
||||
><button class="split-btn-pedal usercss-only" i18n="menu-tpl:saveAsTemplate"></button>
|
||||
</div>
|
||||
<button id="beautify" i18n="styleBeautify"></button>
|
||||
<button id="style-settings-btn" i18n="settings"></button>
|
||||
<button id="cancel-button" i18n="title:styleCancelEditLabel">↩</button>
|
||||
</div>
|
||||
<div>
|
||||
<h2 id="mozilla-format-heading" i18n-text="styleMozillaFormatHeading"><svg id="to-mozilla-help" class="svg-icon info"><use xlink:href="#svg-icon-help"/></svg></h2>
|
||||
<button id="from-mozilla" i18n-text="importLabel"></button>
|
||||
<button id="to-mozilla" i18n-text="exportLabel"></button>
|
||||
<div id="mozilla-format-buttons" class="buttons sectioned-only">
|
||||
<button id="from-mozilla" i18n="importLabel"></button>
|
||||
<button id="to-mozilla" i18n="exportLabel"></button>
|
||||
<a id="to-mozilla-help" class="svg-inline-wrapper" tabindex="0"
|
||||
i18n="title:styleMozillaFormatHeading">
|
||||
<svg class="svg-icon info"><use xlink:href="#svg-icon-help"/></svg>
|
||||
</a>
|
||||
</div>
|
||||
</section>
|
||||
<details id="options">
|
||||
<summary><h2 id="options-heading" i18n-text="optionsHeading"></h2></summary>
|
||||
<div class="option">
|
||||
<input id="editor.lineWrapping" type="checkbox">
|
||||
<label id="lineWrapping-label" for="editor.lineWrapping" i18n-text="cm_lineWrapping"></label>
|
||||
</div>
|
||||
<div class="option">
|
||||
<input id="editor.smartIndent" type="checkbox">
|
||||
<label id="smartIndent-label" for="editor.smartIndent" i18n-text="cm_smartIndent"></label>
|
||||
</div>
|
||||
<div class="option">
|
||||
<input id="editor.indentWithTabs" type="checkbox">
|
||||
<label id="indentWithTabs-label" for="editor.indentWithTabs" i18n-text="cm_indentWithTabs"></label>
|
||||
</div>
|
||||
<div class="option">
|
||||
<input id="editor.autocompleteOnTyping" type="checkbox">
|
||||
<label for="editor.autocompleteOnTyping" i18n-text="cm_autocompleteOnTyping"></label>
|
||||
</div>
|
||||
<div class="option aligned">
|
||||
<label id="tabSize-label" for="editor.tabSize" i18n-text="cm_tabSize"></label>
|
||||
<input id="editor.tabSize" type="number" min="0">
|
||||
</div>
|
||||
<div class="option aligned">
|
||||
<label id="keyMap-label" for="editor.keyMap" i18n-text="cm_keyMap"></label>
|
||||
<select id="editor.keyMap"></select>
|
||||
<svg id="keyMap-help" class="svg-icon info"><use xlink:href="#svg-icon-help"/></svg>
|
||||
</div>
|
||||
<div class="option aligned">
|
||||
<label id="theme-label" for="editor.theme" i18n-text="cm_theme"></label>
|
||||
<select id="editor.theme"></select>
|
||||
</div>
|
||||
<div class="option aligned">
|
||||
<label id="highlight-label" for="editor.matchHighlight" i18n-text="cm_matchHighlight"></label>
|
||||
<select id="editor.matchHighlight">
|
||||
<option i18n-text="cm_matchHighlightToken" value="token">
|
||||
<option i18n-text="cm_matchHighlightSelection" value="selection">
|
||||
<option i18n-text="genericDisabledLabel" value="">
|
||||
</select>
|
||||
</div>
|
||||
<div class="option aligned">
|
||||
<label id="linter-label" for="editor.linter" i18n-text="cm_linter"></label>
|
||||
<select id="editor.linter">
|
||||
<option value="csslint" selected>CSSLint</option>
|
||||
<option value="stylelint">Stylelint</option>
|
||||
<option value="" i18n-text="genericDisabledLabel"></option>
|
||||
</select>
|
||||
<span class="linter-settings" i18n-title="linterConfigTooltip">
|
||||
<svg id="linter-settings" class="svg-icon settings">
|
||||
<use xlink:href="#svg-icon-settings"/>
|
||||
</svg>
|
||||
</span>
|
||||
</div>
|
||||
</details>
|
||||
<section id="lint"><h2 i18n-text="linterIssues">: <span id="issue-count"></span><svg id="lint-help" class="svg-icon info"><use xlink:href="#svg-icon-help"/></svg></h2><div></div></section>
|
||||
<div id="details-wrapper">
|
||||
<details id="options" data-pref="editor.options.expanded" class="ignore-pref-if-compact">
|
||||
<summary><h2 id="options-heading" i18n="editorSettings"></h2></summary>
|
||||
<div id="options-wrapper">
|
||||
<div class="options-column">
|
||||
<div class="option">
|
||||
<label id="lineWrapping-label" i18n="cm_lineWrapping">
|
||||
<input id="editor.lineWrapping" type="checkbox">
|
||||
<svg class="svg-icon checked"><use xlink:href="#svg-icon-checked"/></svg>
|
||||
</label>
|
||||
</div>
|
||||
<div class="option">
|
||||
<label id="smartIndent-label" i18n="cm_smartIndent">
|
||||
<input id="editor.smartIndent" type="checkbox">
|
||||
<svg class="svg-icon checked"><use xlink:href="#svg-icon-checked"/></svg>
|
||||
</label>
|
||||
</div>
|
||||
<div class="option">
|
||||
<label id="indentWithTabs-label" i18n="cm_indentWithTabs">
|
||||
<input id="editor.indentWithTabs" type="checkbox">
|
||||
<svg class="svg-icon checked"><use xlink:href="#svg-icon-checked"/></svg>
|
||||
</label>
|
||||
</div>
|
||||
<div class="option">
|
||||
<label i18n="cm_autoCloseBrackets, title:cm_autoCloseBracketsTooltip">
|
||||
<input id="editor.autoCloseBrackets" type="checkbox">
|
||||
<svg class="svg-icon checked"><use xlink:href="#svg-icon-checked"/></svg>
|
||||
</label>
|
||||
</div>
|
||||
<div class="option">
|
||||
<label i18n="cm_autocompleteOnTyping">
|
||||
<input id="editor.autocompleteOnTyping" type="checkbox">
|
||||
<svg class="svg-icon checked"><use xlink:href="#svg-icon-checked"/></svg>
|
||||
</label>
|
||||
</div>
|
||||
<div class="option">
|
||||
<label i18n="cm_selectByTokens, title:cm_selectByTokensTooltip">
|
||||
<input id="editor.selectByTokens" type="checkbox">
|
||||
<svg class="svg-icon checked"><use xlink:href="#svg-icon-checked"/></svg>
|
||||
</label>
|
||||
</div>
|
||||
<div class="option sectioned-only">
|
||||
<label i18n="cm_arrowKeysTraverse">
|
||||
<input id="editor.arrowKeysTraverse" type="checkbox">
|
||||
<svg class="svg-icon checked"><use xlink:href="#svg-icon-checked"/></svg>
|
||||
</label>
|
||||
</div>
|
||||
<div class="option">
|
||||
<label i18n="cm_colorpicker">
|
||||
<input id="editor.colorpicker" type="checkbox">
|
||||
<svg class="svg-icon checked"><use xlink:href="#svg-icon-checked"/></svg>
|
||||
</label>
|
||||
<a id="colorpicker-settings" class="svg-inline-wrapper" i18n="title:shortcutsNote" tabindex="0">
|
||||
<svg class="svg-icon settings"><use xlink:href="#svg-icon-config"/></svg>
|
||||
</a>
|
||||
</div>
|
||||
<div class="option usercss-only">
|
||||
<label i18n="appliesLineWidgetLabel, title:appliesLineWidgetWarning">
|
||||
<input id="editor.appliesToLineWidget" type="checkbox">
|
||||
<svg class="svg-icon checked"><use xlink:href="#svg-icon-checked"/></svg>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="options-column">
|
||||
<div class="option aligned">
|
||||
<label id="tabSize-label" for="editor.tabSize" i18n="cm_tabSize"></label>
|
||||
<input id="editor.tabSize" type="number" min="0">
|
||||
</div>
|
||||
<div class="option aligned">
|
||||
<label id="keyMap-label" for="editor.keyMap" i18n="cm_keyMap"></label>
|
||||
<div class="select-resizer">
|
||||
<select id="editor.keyMap"></select>
|
||||
<svg class="svg-icon select-arrow"><use xlink:href="#svg-icon-select-arrow"/></svg>
|
||||
</div>
|
||||
<a id="keyMap-help" class="svg-inline-wrapper" tabindex="0">
|
||||
<svg class="svg-icon info"><use xlink:href="#svg-icon-help"/></svg>
|
||||
</a>
|
||||
</div>
|
||||
<div class="option aligned">
|
||||
<label id="theme-label" for="editor.theme" i18n="cm_theme"></label>
|
||||
<div class="select-resizer">
|
||||
<select id="editor.theme"></select>
|
||||
<svg class="svg-icon select-arrow"><use xlink:href="#svg-icon-select-arrow"/></svg>
|
||||
</div>
|
||||
</div>
|
||||
<div class="option aligned">
|
||||
<label id="highlight-label" for="editor.matchHighlight" i18n="cm_matchHighlight"></label>
|
||||
<div class="select-resizer">
|
||||
<select id="editor.matchHighlight">
|
||||
<option i18n="cm_matchHighlightToken" value="token">
|
||||
<option i18n="cm_matchHighlightSelection" value="selection">
|
||||
<option i18n="genericDisabledLabel" value="">
|
||||
</select>
|
||||
<svg class="svg-icon select-arrow"><use xlink:href="#svg-icon-select-arrow"/></svg>
|
||||
</div>
|
||||
</div>
|
||||
<div class="option aligned">
|
||||
<label id="linter-label" for="editor.linter" i18n="cm_linter"></label>
|
||||
<div class="select-resizer">
|
||||
<select id="editor.linter">
|
||||
<option value="csslint" selected>CSSLint</option>
|
||||
<option value="stylelint">Stylelint</option>
|
||||
<option value="" i18n="genericDisabledLabel"></option>
|
||||
</select>
|
||||
<svg class="svg-icon select-arrow"><use xlink:href="#svg-icon-select-arrow"/></svg>
|
||||
</div>
|
||||
<a id="linter-settings" class="svg-inline-wrapper" i18n="title:linterConfigTooltip" tabindex="0">
|
||||
<svg class="svg-icon settings"><use xlink:href="#svg-icon-config"/></svg>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</details>
|
||||
<details id="publish" data-pref="editor.publish.expanded" class="ignore-pref-if-compact">
|
||||
<summary><h2 i18n="publish"></h2></summary>
|
||||
<div>
|
||||
<a id="usw-url" href="https://userstyles.world" target="_blank"> </a>
|
||||
<div id="usw-link-info">
|
||||
<dl><dt i18n="styleName"></dt><dd data-usw="name"></dd></dl>
|
||||
<dl><dt i18n="genericDescription"></dt><dd data-usw="description"></dd></dl>
|
||||
</div>
|
||||
<div>
|
||||
<button id="usw-publish-style"
|
||||
i18n="data-publish:publishStyle, data-push:publishPush"></button>
|
||||
<button id="usw-disconnect" i18n="optionsSyncDisconnect"></button>
|
||||
<span id="usw-progress"></span>
|
||||
</div>
|
||||
</div>
|
||||
</details>
|
||||
<details id="sections-list" data-pref="editor.toc.expanded" class="ignore-pref-if-compact">
|
||||
<summary><h2 i18n="sections"></h2></summary>
|
||||
<ol id="toc"></ol>
|
||||
</details>
|
||||
<details id="lint" data-pref="editor.lint.expanded" class="ignore-pref-if-compact" hidden>
|
||||
<summary>
|
||||
<h2><span i18n="linterIssues"></span><span id="issue-count"></span>
|
||||
<a id="lint-help" class="svg-inline-wrapper intercepts-click" tabindex="0">
|
||||
<svg class="svg-icon info"><use xlink:href="#svg-icon-help"/></svg>
|
||||
</a>
|
||||
</h2>
|
||||
</summary>
|
||||
<div class="lint-report-container"></div>
|
||||
</details>
|
||||
</div>
|
||||
<div id="header-resizer" i18n="title:headerResizerHint"></div>
|
||||
<div id="footer" class="hidden">
|
||||
<a href="https://github.com/openstyles/stylus/wiki/Usercss"
|
||||
i18n="externalUsercssDocument"
|
||||
target="_blank"></a>
|
||||
</div>
|
||||
</div>
|
||||
<section id="sections">
|
||||
<h2><span id="sections-heading" i18n-text="styleSectionsTitle"></span><svg id="sections-help" class="svg-icon info"><use xlink:href="#svg-icon-help"/></svg></h2>
|
||||
</section>
|
||||
<section id="sections"></section>
|
||||
<div id="help-popup">
|
||||
<div class="title"></div><svg id="sections-help" class="svg-icon dismiss"><use xlink:href="#svg-icon-close"/></svg></svg>
|
||||
<div class="title"></div><svg id="sections-help" class="svg-icon dismiss"><use xlink:href="#svg-icon-close"/></svg>
|
||||
<div class="contents"></div>
|
||||
</div>
|
||||
|
||||
<svg xmlns="http://www.w3.org/2000/svg" style="display: none">
|
||||
<symbol id="svg-icon-external-link" height="16" width="16" viewBox="0 0 8 8">
|
||||
|
||||
<symbol id="svg-icon-external-link" viewBox="0 0 8 8">
|
||||
<path d="M0 0v8h8v-2h-1v1h-6v-6h1v-1h-2zm4 0l1.5 1.5-2.5 2.5 1 1 2.5-2.5 1.5 1.5v-4h-4z"></path>
|
||||
</symbol>
|
||||
<symbol id="svg-icon-help" height="16" width="14" viewBox="0 0 14 16" i18n-alt="helpAlt">
|
||||
<path fill-rule="evenodd" d="M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"></path>
|
||||
|
||||
<symbol id="svg-icon-help" viewBox="0 0 14 16" i18n="alt:helpAlt">
|
||||
<circle cx="7" cy="5" r="1"/>
|
||||
<path d="M8,8c0-0.5-0.5-1-1-1H6C5.5,7,5,7.4,5,8h1v3c0,0.5,0.5,1,1,1h1c0.5,0,1-0.4,1-1H8V8z"/>
|
||||
<path d="M7,1c3.9,0,7,3.1,7,7s-3.1,7-7,7s-7-3.1-7-7S3.1,1,7,1z M7,2.3C3.9,2.3,1.3,4.9,1.3,8s2.6,5.7,5.7,5.7s5.7-2.6,5.7-5.7S10.1,2.3,7,2.3C7,2.3,7,2.3,7,2.3z"/>
|
||||
</symbol>
|
||||
<symbol id="svg-icon-close" height="16" width="12" viewBox="0 0 12 16">
|
||||
|
||||
<symbol id="svg-icon-close" viewBox="0 0 12 16">
|
||||
<path fill-rule="evenodd" d="M7.48 8l3.75 3.75-1.48 1.48L6 9.48l-3.75 3.75-1.48-1.48L4.52 8 .77 4.25l1.48-1.48L6 6.52l3.75-3.75 1.48 1.48z"></path>
|
||||
</symbol>
|
||||
<symbol id="svg-icon-settings" height="12" width="12" viewBox="0 0 16 16">
|
||||
<path d="M16 9.45V6.52l-1.8-.3c-.14-.5-.34-.95-.56-1.35L14.7 3.4l-2.07-2.1-1.5 1.03c-.43-.24-.9-.43-1.37-.56L9.46 0H6.54l-.3 1.8c-.5.13-.94.33-1.36.55L3.4 1.32 1.3 3.4l1.07 1.45c-.24.45-.44.92-.57 1.42L0 6.53v2.95l1.8.3c.14.52.33.95.57 1.37l-1.07 1.5 2.06 2.08 1.5-1.07c.44.24.9.45 1.4.57l.3 1.77H9.5l.32-1.8c.47-.13.95-.32 1.34-.56l1.5 1.06 2.07-2.05-1.03-1.5c.24-.45.44-.9.56-1.36L16 9.44v-.02zm-8 1.6C6.3 11.05 4.93 9.7 4.93 8S6.33 4.9 8 4.9s3.06 1.4 3.06 3.1S9.7 11.04 8 11.04z"/>
|
||||
</symbol>
|
||||
</svg>
|
||||
|
||||
<symbol id="svg-icon-v" viewBox="0 0 16 16">
|
||||
<path d="M8,11.5L2.8,6.3l1.5-1.5L8,8.6l3.7-3.7l1.5,1.5L8,11.5z"/>
|
||||
</symbol>
|
||||
|
||||
<symbol id="svg-icon-config" viewBox="0 0 16 16">
|
||||
<path d="M13.3,12.8l1.5-2.6l-2.2-1.5c0-0.2,0.1-0.5,0.1-0.7c0-0.2,0-0.5-0.1-0.7l2.2-1.5l-1.5-2.6l-2.4,1.2 c-0.4-0.3-0.8-0.5-1.2-0.7L9.5,1h-3L6.3,3.7C5.9,3.8,5.5,4.1,5.1,4.4L2.7,3.2L1.2,5.8l2.2,1.5c0,0.2-0.1,0.5-0.1,0.7 c0,0.2,0,0.5,0.1,0.7l-2.2,1.5l1.5,2.6l2.4-1.2c0.4,0.3,0.8,0.5,1.2,0.7L6.5,15h3l0.2-2.7c0.4-0.2,0.8-0.4,1.2-0.7L13.3,12.8z M8,10.3c-1.3,0-2.3-1-2.3-2.3c0-1.3,1-2.3,2.3-2.3c1.3,0,2.3,1,2.3,2.3C10.3,9.3,9.3,10.3,8,10.3z"/>
|
||||
</symbol>
|
||||
|
||||
<symbol id="svg-icon-select-arrow" viewBox="0 0 1792 1792">
|
||||
<path fill-rule="evenodd" d="M1408 704q0 26-19 45l-448 448q-19 19-45 19t-45-19l-448-448q-19-19-19-45t19-45 45-19h896q26 0 45 19t19 45z"/>
|
||||
</symbol>
|
||||
|
||||
<symbol id="svg-icon-checked" viewBox="0 0 1000 1000">
|
||||
<path fill-rule="evenodd" d="M983.2,184.3L853,69.8c-4-3.5-9.3-5.3-14.5-5c-5.3,0.4-10.3,2.8-13.8,6.8L352.3,609.2L184.4,386.9c-3.2-4.2-8-7-13.2-7.8c-5.3-0.8-10.6,0.6-14.9,3.9L18,487.5c-8.8,6.7-10.6,19.3-3.9,28.1L325,927.2c3.6,4.8,9.3,7.7,15.3,8c0.2,0,0.5,0,0.7,0c5.8,0,11.3-2.5,15.1-6.8L985,212.6C992.3,204.3,991.5,191.6,983.2,184.3z"/>
|
||||
</symbol>
|
||||
|
||||
<symbol id="svg-icon-plus" viewBox="0 0 8 8">
|
||||
<path d="M3 0v3h-3v2h3v3h2v-3h3v-2h-3v-3h-2z"/>
|
||||
</symbol>
|
||||
|
||||
<symbol id="svg-icon-minus" viewBox="0 0 8 8">
|
||||
<path d="M0 3v2h8v-2h-8z"/>
|
||||
</symbol>
|
||||
|
||||
</svg>
|
||||
</template>
|
||||
|
||||
<link href="edit/edit.css" rel="stylesheet">
|
||||
<script src="js/dark-themer.js"></script> <!-- must be last in HEAD to avoid FOUC -->
|
||||
</head>
|
||||
|
||||
<body id="stylus-edit">
|
||||
<script src="edit/edit.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -1,408 +0,0 @@
|
|||
/* global regExpTester debounce messageBox */
|
||||
'use strict';
|
||||
|
||||
function createAppliesToLineWidget(cm) {
|
||||
const APPLIES_TYPE = [
|
||||
[t('appliesUrlOption'), 'url'],
|
||||
[t('appliesUrlPrefixOption'), 'url-prefix'],
|
||||
[t('appliesDomainOption'), 'domain'],
|
||||
[t('appliesRegexpOption'), 'regexp']
|
||||
];
|
||||
const THROTTLE_DELAY = 400;
|
||||
let widgets = [];
|
||||
let fromLine, toLine, gutterStyle;
|
||||
let initialized = false;
|
||||
|
||||
return {toggle};
|
||||
|
||||
function toggle(newState = !initialized) {
|
||||
newState = Boolean(newState);
|
||||
if (newState !== initialized) {
|
||||
if (newState) {
|
||||
init();
|
||||
} else {
|
||||
uninit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function init() {
|
||||
initialized = true;
|
||||
|
||||
gutterStyle = getComputedStyle(cm.getGutterElement());
|
||||
fromLine = null;
|
||||
toLine = null;
|
||||
|
||||
cm.on('change', onChange);
|
||||
cm.on('optionChange', onOptionChange);
|
||||
|
||||
// is it possible to avoid flickering?
|
||||
window.addEventListener('load', updateWidgetStyle);
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
function uninit() {
|
||||
initialized = false;
|
||||
|
||||
widgets.forEach(clearWidget);
|
||||
widgets.length = 0;
|
||||
cm.off('change', onChange);
|
||||
cm.off('optionChange', onOptionChange);
|
||||
window.removeEventListener('load', updateWidgetStyle);
|
||||
}
|
||||
|
||||
function onChange(cm, {from, to, origin}) {
|
||||
if (origin === 'appliesTo') {
|
||||
return;
|
||||
}
|
||||
if (fromLine === null || toLine === null) {
|
||||
fromLine = from.line;
|
||||
toLine = to.line;
|
||||
} else {
|
||||
fromLine = Math.min(fromLine, from.line);
|
||||
toLine = Math.max(toLine, to.line);
|
||||
}
|
||||
debounce(update, THROTTLE_DELAY);
|
||||
}
|
||||
|
||||
function onOptionChange(cm, option) {
|
||||
if (option === 'theme') {
|
||||
updateWidgetStyle();
|
||||
}
|
||||
}
|
||||
|
||||
function update() {
|
||||
cm.operation(doUpdate);
|
||||
}
|
||||
|
||||
function updateWidgetStyle() {
|
||||
gutterStyle = getComputedStyle(cm.getGutterElement());
|
||||
widgets.forEach(setWidgetStyle);
|
||||
}
|
||||
|
||||
function setWidgetStyle(widget) {
|
||||
let borderStyle = '';
|
||||
if (gutterStyle.borderRightWidth !== '0px') {
|
||||
borderStyle = `${gutterStyle.borderRightWidth} ${gutterStyle.borderRightStyle} ${gutterStyle.borderRightColor}`;
|
||||
} else {
|
||||
borderStyle = `1px solid ${gutterStyle.color}`;
|
||||
}
|
||||
widget.node.style.backgroundColor = gutterStyle.backgroundColor;
|
||||
widget.node.style.borderTop = borderStyle;
|
||||
widget.node.style.borderBottom = borderStyle;
|
||||
}
|
||||
|
||||
function doUpdate() {
|
||||
// find which widgets needs to be update
|
||||
// some widgets (lines) might be deleted
|
||||
widgets = widgets.filter(w => w.line.lineNo() !== null);
|
||||
let i = fromLine === null ? 0 : widgets.findIndex(w => w.line.lineNo() > fromLine) - 1;
|
||||
let j = toLine === null ? 0 : widgets.findIndex(w => w.line.lineNo() > toLine);
|
||||
if (i === -2) {
|
||||
i = widgets.length - 1;
|
||||
}
|
||||
if (j < 0) {
|
||||
j = widgets.length;
|
||||
}
|
||||
|
||||
// decide search range
|
||||
const fromIndex = widgets[i] ? cm.indexFromPos({line: widgets[i].line.lineNo(), ch: 0}) : 0;
|
||||
const toIndex = widgets[j] ? cm.indexFromPos({line: widgets[j].line.lineNo(), ch: 0}) : cm.getValue().length;
|
||||
|
||||
// splice
|
||||
i = Math.max(0, i);
|
||||
widgets.splice(i, 0, ...createWidgets(fromIndex, toIndex, widgets.splice(i, j - i)));
|
||||
|
||||
fromLine = null;
|
||||
toLine = null;
|
||||
}
|
||||
|
||||
function *createWidgets(start, end, removed) {
|
||||
let i = 0;
|
||||
for (const section of findAppliesTo(start, end)) {
|
||||
while (removed[i] && removed[i].line.lineNo() < section.pos.line) {
|
||||
clearWidget(removed[i++]);
|
||||
}
|
||||
setupMarkers(section);
|
||||
if (removed[i] && removed[i].line.lineNo() === section.pos.line) {
|
||||
// reuse old widget
|
||||
removed[i].section.applies.forEach(apply => {
|
||||
apply.type.mark.clear();
|
||||
apply.value.mark.clear();
|
||||
});
|
||||
removed[i].section = section;
|
||||
const newNode = buildElement(section);
|
||||
removed[i].node.parentNode.replaceChild(newNode, removed[i].node);
|
||||
removed[i].node = newNode;
|
||||
setWidgetStyle(removed[i]);
|
||||
removed[i].changed();
|
||||
yield removed[i];
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
// new widget
|
||||
const widget = cm.addLineWidget(section.pos.line, buildElement(section), {
|
||||
coverGutter: true,
|
||||
noHScroll: true,
|
||||
above: true
|
||||
});
|
||||
widget.section = section;
|
||||
setWidgetStyle(widget);
|
||||
yield widget;
|
||||
}
|
||||
removed.slice(i).forEach(clearWidget);
|
||||
}
|
||||
|
||||
function clearWidget(widget) {
|
||||
widget.clear();
|
||||
widget.section.applies.forEach(clearApply);
|
||||
}
|
||||
|
||||
function clearApply(apply) {
|
||||
apply.type.mark.clear();
|
||||
apply.value.mark.clear();
|
||||
apply.mark.clear();
|
||||
}
|
||||
|
||||
function setupMarkers({applies}) {
|
||||
applies.forEach(setupApplyMarkers);
|
||||
}
|
||||
|
||||
function setupApplyMarkers(apply) {
|
||||
apply.type.mark = cm.markText(
|
||||
cm.posFromIndex(apply.type.start),
|
||||
cm.posFromIndex(apply.type.end),
|
||||
{clearWhenEmpty: false}
|
||||
);
|
||||
apply.value.mark = cm.markText(
|
||||
cm.posFromIndex(apply.value.start),
|
||||
cm.posFromIndex(apply.value.end),
|
||||
{clearWhenEmpty: false}
|
||||
);
|
||||
apply.mark = cm.markText(
|
||||
cm.posFromIndex(apply.start),
|
||||
cm.posFromIndex(apply.end),
|
||||
{clearWhenEmpty: false}
|
||||
);
|
||||
}
|
||||
|
||||
function buildElement({applies}) {
|
||||
const el = $element({className: 'applies-to', appendChild: [
|
||||
$element({tag: 'label', appendChild: [
|
||||
t('appliesLabel'),
|
||||
// $element({tag: 'svg'})
|
||||
]}),
|
||||
$element({
|
||||
tag: 'ul',
|
||||
className: 'applies-to-list',
|
||||
appendChild: applies.map(makeLi)
|
||||
})
|
||||
]});
|
||||
if (!$('li', el)) {
|
||||
$('ul', el).appendChild($element({
|
||||
tag: 'li',
|
||||
className: 'applies-to-everything',
|
||||
textContent: t('appliesToEverything')
|
||||
}));
|
||||
}
|
||||
return el;
|
||||
|
||||
function makeLi(apply) {
|
||||
const el = $element({tag: 'li', appendChild: makeInput(apply)});
|
||||
el.dataset.type = apply.type.text;
|
||||
el.addEventListener('change', e => {
|
||||
if (e.target.classList.contains('applies-type')) {
|
||||
el.dataset.type = apply.type.text;
|
||||
}
|
||||
});
|
||||
return el;
|
||||
}
|
||||
|
||||
function makeInput(apply) {
|
||||
const typeInput = $element({
|
||||
tag: 'select',
|
||||
className: 'applies-type',
|
||||
appendChild: APPLIES_TYPE.map(([label, value]) => $element({
|
||||
tag: 'option',
|
||||
value: value,
|
||||
textContent: label
|
||||
})),
|
||||
onchange() {
|
||||
applyChange(apply.type, this.value);
|
||||
}
|
||||
});
|
||||
typeInput.value = apply.type.text;
|
||||
const valueInput = $element({
|
||||
tag: 'input',
|
||||
className: 'applies-value',
|
||||
value: apply.value.text,
|
||||
oninput() {
|
||||
debounce(applyChange, THROTTLE_DELAY, apply.value, this.value);
|
||||
},
|
||||
onfocus: updateRegexpTest
|
||||
});
|
||||
const regexpTestButton = $element({
|
||||
tag: 'button',
|
||||
type: 'button',
|
||||
className: 'applies-to-regexp-test',
|
||||
textContent: t('styleRegexpTestButton'),
|
||||
onclick() {
|
||||
regExpTester.toggle();
|
||||
regExpTester.update([apply.value.text]);
|
||||
}
|
||||
});
|
||||
const removeButton = $element({
|
||||
tag: 'button',
|
||||
type: 'button',
|
||||
className: 'applies-to-remove',
|
||||
textContent: t('appliesRemove'),
|
||||
onclick() {
|
||||
const i = applies.indexOf(apply);
|
||||
let repl;
|
||||
let from;
|
||||
let to;
|
||||
if (applies.length < 2) {
|
||||
messageBox({
|
||||
contents: chrome.i18n.getMessage('appliesRemoveError'),
|
||||
buttons: [t('confirmClose')]
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (i === 0) {
|
||||
from = apply.mark.find().from;
|
||||
to = applies[i + 1].mark.find().from;
|
||||
repl = '';
|
||||
} else if (i === applies.length - 1) {
|
||||
from = applies[i - 1].mark.find().to;
|
||||
to = apply.mark.find().to;
|
||||
repl = '';
|
||||
} else {
|
||||
from = applies[i - 1].mark.find().to;
|
||||
to = applies[i + 1].mark.find().from;
|
||||
repl = ', ';
|
||||
}
|
||||
cm.replaceRange(repl, from, to, 'appliesTo');
|
||||
clearApply(apply);
|
||||
this.closest('li').remove();
|
||||
applies.splice(i, 1);
|
||||
}
|
||||
});
|
||||
const addButton = $element({
|
||||
tag: 'button',
|
||||
type: 'button',
|
||||
className: 'applies-to-add',
|
||||
textContent: t('appliesAdd'),
|
||||
onclick() {
|
||||
const i = applies.indexOf(apply);
|
||||
const pos = apply.mark.find().to;
|
||||
const text = `, ${apply.type.text}("")`;
|
||||
cm.replaceRange(text, pos, pos, 'appliesTo');
|
||||
const newApply = createApply(
|
||||
cm.indexFromPos(pos) + 2,
|
||||
apply.type.text,
|
||||
'',
|
||||
true
|
||||
);
|
||||
setupApplyMarkers(newApply);
|
||||
applies.splice(i + 1, 0, newApply);
|
||||
this.closest('li').insertAdjacentElement('afterend', makeLi(newApply));
|
||||
}
|
||||
});
|
||||
return [typeInput, valueInput, regexpTestButton, removeButton, addButton];
|
||||
|
||||
function updateRegexpTest() {
|
||||
if (apply.type.text === 'regexp') {
|
||||
const re = apply.value.text.trim();
|
||||
if (re) {
|
||||
regExpTester.update([re]);
|
||||
} else {
|
||||
regExpTester.update([]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function applyChange(input, newText) {
|
||||
const range = input.mark.find();
|
||||
input.mark.clear();
|
||||
cm.replaceRange(newText, range.from, range.to, 'appliesTo');
|
||||
input.mark = cm.markText(
|
||||
range.from,
|
||||
cm.findPosH(range.from, newText.length, 'char'),
|
||||
{clearWhenEmpty: false}
|
||||
);
|
||||
input.text = newText;
|
||||
|
||||
if (input === apply.type) {
|
||||
const range = apply.mark.find();
|
||||
apply.mark.clear();
|
||||
apply.mark = cm.markText(
|
||||
input.mark.find().from,
|
||||
range.to,
|
||||
{clearWhenEmpty: false}
|
||||
);
|
||||
}
|
||||
|
||||
updateRegexpTest();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function createApply(pos, typeText, valueText, isQuoted = false) {
|
||||
const start = pos;
|
||||
const typeStart = start;
|
||||
const typeEnd = typeStart + typeText.length;
|
||||
const valueStart = typeEnd + 1 + Number(isQuoted);
|
||||
const valueEnd = valueStart + valueText.length;
|
||||
const end = valueEnd + Number(isQuoted) + 1;
|
||||
return {
|
||||
start,
|
||||
type: {
|
||||
text: typeText,
|
||||
start: typeStart,
|
||||
end: typeEnd,
|
||||
},
|
||||
value: {
|
||||
text: valueText,
|
||||
start: valueStart,
|
||||
end: valueEnd,
|
||||
},
|
||||
end
|
||||
};
|
||||
}
|
||||
|
||||
function *findAppliesTo(posStart, posEnd) {
|
||||
const text = cm.getValue();
|
||||
const re = /^[\t ]*@-moz-document\s+/mg;
|
||||
const applyRe = /(url|url-prefix|domain|regexp)\(((['"])(?:\\\\|\\\n|\\\3|[^\n])*?\3|[^)\n]*)\)[\s,]*/iyg;
|
||||
let match;
|
||||
re.lastIndex = posStart;
|
||||
while ((match = re.exec(text))) {
|
||||
if (match.index >= posEnd) {
|
||||
return;
|
||||
}
|
||||
const applies = [];
|
||||
let m;
|
||||
applyRe.lastIndex = re.lastIndex;
|
||||
while ((m = applyRe.exec(text))) {
|
||||
const apply = createApply(
|
||||
m.index,
|
||||
m[1],
|
||||
unquote(m[2]),
|
||||
unquote(m[2]) !== m[2]
|
||||
);
|
||||
applies.push(apply);
|
||||
re.lastIndex = applyRe.lastIndex;
|
||||
}
|
||||
yield {
|
||||
pos: cm.posFromIndex(match.index),
|
||||
applies
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
function unquote(s) {
|
||||
const first = s.charAt(0);
|
||||
return (first === '"' || first === "'") && s.endsWith(first) ? s.slice(1, -1) : s;
|
||||
}
|
||||
}
|
274
edit/autocomplete.js
Normal file
274
edit/autocomplete.js
Normal file
|
@ -0,0 +1,274 @@
|
|||
/* global CodeMirror */
|
||||
/* global cmFactory */
|
||||
/* global debounce */// toolbox.js
|
||||
/* global editor */
|
||||
/* global linterMan */
|
||||
/* global prefs */
|
||||
'use strict';
|
||||
|
||||
/* Registers 'hint' helper and 'autocompleteOnTyping' option in CodeMirror */
|
||||
|
||||
(() => {
|
||||
const USO_VAR = 'uso-variable';
|
||||
const USO_VALID_VAR = 'variable-3 ' + USO_VAR;
|
||||
const USO_INVALID_VAR = 'error ' + USO_VAR;
|
||||
const rxPROP = /^(prop(erty)?|variable-2|string-2)\b/;
|
||||
const rxVAR = /(^|[^-.\w\u0080-\uFFFF])var\(/iyu;
|
||||
const rxCONSUME = /([-\w]*\s*:\s?)?/yu;
|
||||
const cssMime = CodeMirror.mimeModes['text/css'];
|
||||
const docFuncs = addSuffix(cssMime.documentTypes, '(');
|
||||
const {tokenHooks} = cssMime;
|
||||
const originalCommentHook = tokenHooks['/'];
|
||||
const originalHelper = CodeMirror.hint.css || (() => {});
|
||||
let cssMedia, cssProps, cssValues;
|
||||
|
||||
const AOT_ID = 'autocompleteOnTyping';
|
||||
const AOT_PREF_ID = 'editor.' + AOT_ID;
|
||||
const aot = prefs.get(AOT_PREF_ID);
|
||||
CodeMirror.defineOption(AOT_ID, aot, (cm, value) => {
|
||||
cm[value ? 'on' : 'off']('changes', autocompleteOnTyping);
|
||||
cm[value ? 'on' : 'off']('pick', autocompletePicked);
|
||||
});
|
||||
prefs.subscribe(AOT_PREF_ID, (key, val) => cmFactory.globalSetOption(AOT_ID, val), {runNow: aot});
|
||||
|
||||
CodeMirror.registerHelper('hint', 'css', helper);
|
||||
CodeMirror.registerHelper('hint', 'stylus', helper);
|
||||
|
||||
tokenHooks['/'] = tokenizeUsoVariables;
|
||||
|
||||
async function helper(cm) {
|
||||
const pos = cm.getCursor();
|
||||
const {line, ch} = pos;
|
||||
const {styles, text} = cm.getLineHandle(line);
|
||||
const {style, index} = cm.getStyleAtPos({styles, pos: ch}) || {};
|
||||
const isLessLang = cm.doc.mode.helperType === 'less';
|
||||
const isStylusLang = cm.doc.mode.name === 'stylus';
|
||||
const type = style && style.split(' ', 1)[0] || 'prop?';
|
||||
if (!type || type === 'comment' || type === 'string') {
|
||||
return originalHelper(cm);
|
||||
}
|
||||
// not using getTokenAt until the need is unavoidable because it reparses text
|
||||
// and runs a whole lot of complex calc inside which is slow on long lines
|
||||
// especially if autocomplete is auto-shown on each keystroke
|
||||
let prev, end, state;
|
||||
let i = index;
|
||||
while (
|
||||
(prev == null || `${styles[i - 1]}`.startsWith(type)) &&
|
||||
(prev = i > 2 ? styles[i - 2] : 0) &&
|
||||
isSameToken(text, style, prev)
|
||||
) i -= 2;
|
||||
i = index;
|
||||
while (
|
||||
(end == null || `${styles[i + 1]}`.startsWith(type)) &&
|
||||
(end = styles[i]) &&
|
||||
isSameToken(text, style, end)
|
||||
) i += 2;
|
||||
const getTokenState = () => state || (state = cm.getTokenAt(pos, true).state.state);
|
||||
const str = text.slice(prev, end);
|
||||
const left = text.slice(prev, ch).trim();
|
||||
let leftLC = left.toLowerCase();
|
||||
let list;
|
||||
switch (leftLC[0]) {
|
||||
|
||||
case '!':
|
||||
list = '!important'.startsWith(leftLC) ? ['!important'] : [];
|
||||
break;
|
||||
|
||||
case '@':
|
||||
list = [
|
||||
'@-moz-document',
|
||||
'@charset',
|
||||
'@font-face',
|
||||
'@import',
|
||||
'@keyframes',
|
||||
'@media',
|
||||
'@namespace',
|
||||
'@page',
|
||||
'@supports',
|
||||
'@viewport',
|
||||
];
|
||||
if (isLessLang) list = findAllCssVars(cm, left, '\\s*:').concat(list);
|
||||
break;
|
||||
|
||||
case '#': // prevents autocomplete for #hex colors
|
||||
break;
|
||||
|
||||
case '-': // --variable
|
||||
case '(': // var(
|
||||
list = str.startsWith('--') || testAt(rxVAR, ch - 5, text)
|
||||
? findAllCssVars(cm, left)
|
||||
: [];
|
||||
if (str.startsWith('(')) {
|
||||
prev++;
|
||||
leftLC = left.slice(1);
|
||||
} else {
|
||||
leftLC = left;
|
||||
}
|
||||
break;
|
||||
|
||||
case '/': // USO vars
|
||||
if (str.startsWith('/*[[') && str.endsWith(']]*/')) {
|
||||
prev += 4;
|
||||
end -= 4;
|
||||
end -= text.slice(end - 4, end) === '-rgb' ? 4 : 0;
|
||||
list = Object.keys((editor.style.usercssData || {}).vars || {}).sort();
|
||||
leftLC = left.slice(4);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'u': // url(), url-prefix()
|
||||
case 'd': // domain()
|
||||
case 'r': // regexp()
|
||||
if (/^(variable|tag|error)/.test(type) &&
|
||||
docFuncs.some(s => s.startsWith(leftLC)) &&
|
||||
/^(top|documentTypes|atBlock)/.test(getTokenState())) {
|
||||
end++;
|
||||
list = docFuncs;
|
||||
break;
|
||||
}
|
||||
// fallthrough to `default`
|
||||
|
||||
default:
|
||||
// property values
|
||||
if (isStylusLang || getTokenState() === 'prop') {
|
||||
while (i > 0 && !rxPROP.test(styles[i + 1])) i -= 2;
|
||||
const propEnd = styles[i];
|
||||
let prop;
|
||||
if (propEnd > text.lastIndexOf(';', ch - 1)) {
|
||||
while (i > 0 && rxPROP.test(styles[i + 1])) i -= 2;
|
||||
prop = text.slice(styles[i] || 0, propEnd).match(/([-\w]+)?$/u)[1];
|
||||
}
|
||||
if (prop) {
|
||||
if (/[^-\w]/.test(leftLC)) {
|
||||
prev += execAt(/[\s:()]*/y, prev, text)[0].length;
|
||||
leftLC = leftLC.replace(/^[^\w\s]\s*/, '');
|
||||
}
|
||||
if (prop.startsWith('--')) prop = 'color'; // assuming 90% of variables are colors
|
||||
if (!cssProps) await initCssProps();
|
||||
list = [...new Set([...cssValues.all[prop] || [], ...cssValues.global])];
|
||||
end = prev + execAt(/(\s*[-a-z(]+)?/y, prev, text)[0].length;
|
||||
}
|
||||
}
|
||||
// properties and media features
|
||||
if (!list &&
|
||||
/^(prop(erty|\?)|atom|error|tag)/.test(type) &&
|
||||
/^(block|atBlock_parens|maybeprop)/.test(getTokenState())) {
|
||||
if (!cssProps) await initCssProps();
|
||||
if (type === 'prop?') {
|
||||
prev += leftLC.length;
|
||||
leftLC = '';
|
||||
}
|
||||
list = state === 'atBlock_parens' ? cssMedia : cssProps;
|
||||
end -= /\W$/u.test(str); // e.g. don't consume ) when inside ()
|
||||
end += execAt(rxCONSUME, end, text)[0].length;
|
||||
|
||||
}
|
||||
if (!list) {
|
||||
return isStylusLang
|
||||
? CodeMirror.hint.fromList(cm, {words: CodeMirror.hintWords.stylus})
|
||||
: originalHelper(cm);
|
||||
}
|
||||
}
|
||||
return {
|
||||
list: (list || []).filter(s => s.startsWith(leftLC)),
|
||||
from: {line, ch: prev + str.match(/^\s*/)[0].length},
|
||||
to: {line, ch: end},
|
||||
};
|
||||
}
|
||||
|
||||
async function initCssProps() {
|
||||
cssValues = await linterMan.worker.getCssPropsValues();
|
||||
cssProps = addSuffix(cssValues.all);
|
||||
cssMedia = [].concat(...Object.entries(cssMime).map(getMediaKeys).filter(Boolean)).sort();
|
||||
}
|
||||
|
||||
function addSuffix(obj, suffix = ': ') {
|
||||
// Sorting first, otherwise "foo-bar:" would precede "foo:"
|
||||
return Object.keys(obj).sort().map(k => k + suffix);
|
||||
}
|
||||
|
||||
function getMediaKeys([k, v]) {
|
||||
return k === 'mediaFeatures' && addSuffix(v) ||
|
||||
k.startsWith('media') && Object.keys(v);
|
||||
}
|
||||
|
||||
/** makes sure we don't process a different adjacent comment */
|
||||
function isSameToken(text, style, i) {
|
||||
return !style || text[i] !== '/' && text[i + 1] !== '*' ||
|
||||
!style.startsWith(USO_VALID_VAR) && !style.startsWith(USO_INVALID_VAR);
|
||||
}
|
||||
|
||||
function findAllCssVars(cm, leftPart, rightPart = '') {
|
||||
// simplified regex without CSS escapes
|
||||
const [, prefixed, named] = leftPart.match(/^(--|@)?(\S)?/);
|
||||
const rx = new RegExp(
|
||||
'(?:^|[\\s/;{])(' +
|
||||
(prefixed ? leftPart : '--') +
|
||||
(named ? '' : '[a-zA-Z_\u0080-\uFFFF]') +
|
||||
'[-0-9a-zA-Z_\u0080-\uFFFF]*)' +
|
||||
rightPart,
|
||||
'g');
|
||||
const list = new Set();
|
||||
cm.eachLine(({text}) => {
|
||||
for (let m; (m = rx.exec(text));) {
|
||||
list.add(m[1]);
|
||||
}
|
||||
});
|
||||
return [...list].sort();
|
||||
}
|
||||
|
||||
function tokenizeUsoVariables(stream) {
|
||||
const token = originalCommentHook.apply(this, arguments);
|
||||
if (token[1] === 'comment') {
|
||||
const {string, start, pos} = stream;
|
||||
if (testAt(/\/\*\[\[/y, start, string) &&
|
||||
testAt(/]]\*\//y, pos - 4, string)) {
|
||||
const vars = (editor.style.usercssData || {}).vars;
|
||||
token[0] =
|
||||
vars && vars.hasOwnProperty(string.slice(start + 4, pos - 4).replace(/-rgb$/, ''))
|
||||
? USO_VALID_VAR
|
||||
: USO_INVALID_VAR;
|
||||
}
|
||||
}
|
||||
return token;
|
||||
}
|
||||
|
||||
function execAt(rx, index, text) {
|
||||
rx.lastIndex = index;
|
||||
return rx.exec(text);
|
||||
}
|
||||
|
||||
function testAt(rx, index, text) {
|
||||
rx.lastIndex = Math.max(0, index);
|
||||
return rx.test(text);
|
||||
}
|
||||
|
||||
function autocompleteOnTyping(cm, [info], debounced) {
|
||||
const lastLine = info.text[info.text.length - 1];
|
||||
if (cm.state.completionActive ||
|
||||
info.origin && !info.origin.includes('input') ||
|
||||
!lastLine) {
|
||||
return;
|
||||
}
|
||||
if (cm.state.autocompletePicked) {
|
||||
cm.state.autocompletePicked = false;
|
||||
return;
|
||||
}
|
||||
if (!debounced) {
|
||||
debounce(autocompleteOnTyping, 100, cm, [info], true);
|
||||
return;
|
||||
}
|
||||
if (lastLine.match(/[-a-z!]+$/i)) {
|
||||
cm.state.autocompletePicked = false;
|
||||
cm.options.hintOptions.completeSingle = false;
|
||||
cm.execCommand('autocomplete');
|
||||
setTimeout(() => {
|
||||
cm.options.hintOptions.completeSingle = true;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function autocompletePicked(cm) {
|
||||
cm.state.autocompletePicked = true;
|
||||
}
|
||||
})();
|
427
edit/base.js
Normal file
427
edit/base.js
Normal file
|
@ -0,0 +1,427 @@
|
|||
/* global $$ $ $create messageBoxProxy setInputValue setupLivePrefs */// dom.js
|
||||
/* global API */// msg.js
|
||||
/* global CODEMIRROR_THEMES */
|
||||
/* global CodeMirror */
|
||||
/* global MozDocMapper */// sections-util.js
|
||||
/* global chromeSync */// storage-util.js
|
||||
/* global initBeautifyButton */// beautify.js
|
||||
/* global prefs */
|
||||
/* global t */// localization.js
|
||||
/* global FIREFOX getOwnTab sessionStore tryJSONparse tryURL */// toolbox.js
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* @type Editor
|
||||
* @namespace Editor
|
||||
*/
|
||||
const editor = {
|
||||
style: null,
|
||||
dirty: DirtyReporter(),
|
||||
isUsercss: false,
|
||||
isWindowed: false,
|
||||
livePreview: LivePreview(),
|
||||
/** @type {'customName'|'name'} */
|
||||
nameTarget: 'name',
|
||||
previewDelay: 200, // Chrome devtools uses 200
|
||||
saving: false,
|
||||
scrollInfo: null,
|
||||
|
||||
cancel: () => location.assign('/manage.html'),
|
||||
|
||||
updateClass() {
|
||||
$.rootCL.toggle('is-new-style', !editor.style.id);
|
||||
},
|
||||
|
||||
updateTheme(name) {
|
||||
if (!CODEMIRROR_THEMES[name]) {
|
||||
name = 'default';
|
||||
prefs.set('editor.theme', name);
|
||||
}
|
||||
$('#cm-theme').dataset.theme = name;
|
||||
$('#cm-theme').textContent = CODEMIRROR_THEMES[name] || '';
|
||||
},
|
||||
|
||||
updateTitle(isDirty = editor.dirty.isDirty()) {
|
||||
const {customName, name} = editor.style;
|
||||
document.title = `${
|
||||
isDirty ? '* ' : ''
|
||||
}${
|
||||
customName || name || t('styleMissingName')
|
||||
} - Stylus`; // the suffix enables external utilities to process our windows e.g. pin on top
|
||||
},
|
||||
};
|
||||
|
||||
//#region pre-init
|
||||
|
||||
(() => {
|
||||
const mqCompact = matchMedia('(max-width: 850px)');
|
||||
const toggleCompact = mq => $.rootCL.toggle('compact-layout', mq.matches);
|
||||
mqCompact.on('change', toggleCompact);
|
||||
toggleCompact(mqCompact);
|
||||
Object.assign(editor, /** @namespace Editor */ {
|
||||
mqCompact,
|
||||
styleReady: prefs.ready.then(loadStyle),
|
||||
});
|
||||
async function loadStyle() {
|
||||
const params = new URLSearchParams(location.search);
|
||||
let id = Number(params.get('id'));
|
||||
const style = id && await API.styles.get(id) || {
|
||||
id: id = null, // resetting the non-existent id
|
||||
name: params.get('domain') ||
|
||||
tryURL(params.get('url-prefix')).hostname ||
|
||||
'',
|
||||
enabled: true,
|
||||
sections: [
|
||||
MozDocMapper.toSection([...params], {code: ''}),
|
||||
],
|
||||
};
|
||||
// switching the mode here to show the correct page ASAP, usually before DOMContentLoaded
|
||||
const isUC = Boolean(style.usercssData || !id && prefs.get('newStyleAsUsercss'));
|
||||
Object.assign(editor, /** @namespace Editor */ {
|
||||
style,
|
||||
isUsercss: isUC,
|
||||
template: isUC && !id && chromeSync.getLZValue(chromeSync.LZ_KEY.usercssTemplate), // promise
|
||||
});
|
||||
editor.updateClass();
|
||||
editor.updateTheme(prefs.get('editor.theme'));
|
||||
editor.updateTitle(false);
|
||||
$.rootCL.add(isUC ? 'usercss' : 'sectioned');
|
||||
sessionStore.justEditedStyleId = id || '';
|
||||
// no such style so let's clear the invalid URL parameters
|
||||
if (!id) history.replaceState({}, '', location.pathname);
|
||||
}
|
||||
})();
|
||||
|
||||
//#endregion
|
||||
//#region init header
|
||||
|
||||
/* exported EditorHeader */
|
||||
function EditorHeader() {
|
||||
initBeautifyButton($('#beautify'));
|
||||
initKeymapElement();
|
||||
initNameArea();
|
||||
initThemeElement();
|
||||
setupLivePrefs();
|
||||
|
||||
window.on('load', () => {
|
||||
prefs.subscribe('editor.keyMap', showHotkeyInTooltip, {runNow: true});
|
||||
window.on('showHotkeyInTooltip', showHotkeyInTooltip);
|
||||
}, {once: true});
|
||||
|
||||
function findKeyForCommand(command, map) {
|
||||
if (typeof map === 'string') map = CodeMirror.keyMap[map];
|
||||
let key = Object.keys(map).find(k => map[k] === command);
|
||||
if (key) {
|
||||
return key;
|
||||
}
|
||||
for (const ft of Array.isArray(map.fallthrough) ? map.fallthrough : [map.fallthrough]) {
|
||||
key = ft && findKeyForCommand(command, ft);
|
||||
if (key) {
|
||||
return key;
|
||||
}
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
function initNameArea() {
|
||||
const nameEl = $('#name');
|
||||
const resetEl = $('#reset-name');
|
||||
const isCustomName = editor.style.updateUrl || editor.isUsercss;
|
||||
editor.nameTarget = isCustomName ? 'customName' : 'name';
|
||||
nameEl.placeholder = t(editor.isUsercss ? 'usercssEditorNamePlaceholder' : 'styleMissingName');
|
||||
nameEl.title = isCustomName ? t('customNameHint') : '';
|
||||
nameEl.on('input', () => {
|
||||
editor.updateName(true);
|
||||
resetEl.hidden = !editor.style.customName;
|
||||
});
|
||||
resetEl.hidden = !editor.style.customName;
|
||||
resetEl.onclick = () => {
|
||||
editor.style.customName = null; // to delete it from db
|
||||
setInputValue(nameEl, editor.style.name);
|
||||
resetEl.hidden = true;
|
||||
};
|
||||
const enabledEl = $('#enabled');
|
||||
enabledEl.onchange = () => editor.updateEnabledness(enabledEl.checked);
|
||||
}
|
||||
|
||||
function initThemeElement() {
|
||||
$('#editor.theme').append(...[
|
||||
$create('option', {value: 'default'}, t('defaultTheme')),
|
||||
...Object.keys(CODEMIRROR_THEMES).map(s => $create('option', s)),
|
||||
]);
|
||||
// move the theme after built-in CSS so that its same-specificity selectors win
|
||||
document.head.appendChild($('#cm-theme'));
|
||||
}
|
||||
|
||||
function initKeymapElement() {
|
||||
// move 'pc' or 'mac' prefix to the end of the displayed label
|
||||
const maps = Object.keys(CodeMirror.keyMap)
|
||||
.map(name => ({
|
||||
value: name,
|
||||
name: name.replace(/^(pc|mac)(.+)/, (s, arch, baseName) =>
|
||||
baseName.toLowerCase() + '-' + (arch === 'mac' ? 'Mac' : 'PC')),
|
||||
}))
|
||||
.sort((a, b) => a.name < b.name && -1 || a.name > b.name && 1);
|
||||
|
||||
const fragment = document.createDocumentFragment();
|
||||
let bin = fragment;
|
||||
let groupName;
|
||||
// group suffixed maps in <optgroup>
|
||||
maps.forEach(({value, name}, i) => {
|
||||
groupName = !name.includes('-') ? name : groupName;
|
||||
const groupWithNext = maps[i + 1] && maps[i + 1].name.startsWith(groupName);
|
||||
if (groupWithNext) {
|
||||
if (bin === fragment) {
|
||||
bin = fragment.appendChild($create('optgroup', {label: name.split('-')[0]}));
|
||||
}
|
||||
}
|
||||
const el = bin.appendChild($create('option', {value}, name));
|
||||
if (value === prefs.defaults['editor.keyMap']) {
|
||||
el.dataset.default = '';
|
||||
el.title = t('defaultTheme');
|
||||
}
|
||||
if (!groupWithNext) bin = fragment;
|
||||
});
|
||||
const selector = $('#editor.keyMap');
|
||||
selector.textContent = '';
|
||||
selector.appendChild(fragment);
|
||||
selector.value = prefs.get('editor.keyMap');
|
||||
}
|
||||
|
||||
function showHotkeyInTooltip(_, mapName = prefs.get('editor.keyMap')) {
|
||||
const extraKeys = CodeMirror.defaults.extraKeys;
|
||||
for (const el of $$('[data-hotkey-tooltip]')) {
|
||||
if (el._hotkeyTooltipKeyMap !== mapName) {
|
||||
el._hotkeyTooltipKeyMap = mapName;
|
||||
const title = el._hotkeyTooltipTitle = el._hotkeyTooltipTitle || el.title;
|
||||
const cmd = el.dataset.hotkeyTooltip;
|
||||
const key = cmd[0] === '=' ? cmd.slice(1) :
|
||||
findKeyForCommand(cmd, mapName) ||
|
||||
extraKeys && findKeyForCommand(cmd, extraKeys);
|
||||
const newTitle = title + (title && key ? '\n' : '') + (key || '');
|
||||
if (el.title !== newTitle) el.title = newTitle;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//#endregion
|
||||
//#region init windowed mode
|
||||
|
||||
(() => {
|
||||
let ownTabId;
|
||||
if (chrome.windows) {
|
||||
initWindowedMode();
|
||||
const pos = tryJSONparse(sessionStore.windowPos);
|
||||
delete sessionStore.windowPos;
|
||||
// resize the window on 'undo close'
|
||||
if (pos && pos.left != null) {
|
||||
chrome.windows.update(chrome.windows.WINDOW_ID_CURRENT, pos);
|
||||
}
|
||||
}
|
||||
|
||||
getOwnTab().then(tab => {
|
||||
ownTabId = tab.id;
|
||||
if (sessionStore['manageStylesHistory' + ownTabId] === location.href) {
|
||||
editor.cancel = () => history.back();
|
||||
}
|
||||
});
|
||||
|
||||
async function initWindowedMode() {
|
||||
chrome.tabs.onAttached.addListener(onTabAttached);
|
||||
// Chrome 96+ bug: the type is 'app' for a window that was restored via Ctrl-Shift-T
|
||||
const isSimple = ['app', 'popup'].includes((await browser.windows.getCurrent()).type);
|
||||
if (isSimple) require(['/edit/embedded-popup']);
|
||||
editor.isWindowed = isSimple || (
|
||||
history.length === 1 &&
|
||||
await prefs.ready && prefs.get('openEditInWindow') &&
|
||||
(await browser.windows.getAll()).length > 1 &&
|
||||
(await browser.tabs.query({currentWindow: true})).length === 1
|
||||
);
|
||||
}
|
||||
|
||||
async function onTabAttached(tabId, info) {
|
||||
if (tabId !== ownTabId) {
|
||||
return;
|
||||
}
|
||||
if (info.newPosition !== 0) {
|
||||
prefs.set('openEditInWindow', false);
|
||||
return;
|
||||
}
|
||||
const win = await browser.windows.get(info.newWindowId, {populate: true});
|
||||
// If there's only one tab in this window, it's been dragged to new window
|
||||
const openEditInWindow = win.tabs.length === 1;
|
||||
// FF-only because Chrome retardedly resets the size during dragging
|
||||
if (openEditInWindow && FIREFOX) {
|
||||
chrome.windows.update(info.newWindowId, prefs.get('windowPosition'));
|
||||
}
|
||||
prefs.set('openEditInWindow', openEditInWindow);
|
||||
}
|
||||
})();
|
||||
|
||||
//#endregion
|
||||
//#region internals
|
||||
|
||||
/** @returns DirtyReporter */
|
||||
function DirtyReporter() {
|
||||
const data = new Map();
|
||||
const listeners = new Set();
|
||||
const dataListeners = new Set();
|
||||
const notifyChange = wasDirty => {
|
||||
const isDirty = data.size > 0;
|
||||
const flipped = isDirty !== wasDirty;
|
||||
if (flipped) {
|
||||
listeners.forEach(cb => cb(isDirty));
|
||||
}
|
||||
if (flipped || isDirty) {
|
||||
dataListeners.forEach(cb => cb(isDirty));
|
||||
}
|
||||
};
|
||||
/** @namespace DirtyReporter */
|
||||
return {
|
||||
add(obj, value) {
|
||||
const wasDirty = data.size > 0;
|
||||
const saved = data.get(obj);
|
||||
if (!saved) {
|
||||
data.set(obj, {type: 'add', newValue: value});
|
||||
} else if (saved.type === 'remove') {
|
||||
if (saved.savedValue === value) {
|
||||
data.delete(obj);
|
||||
} else {
|
||||
saved.newValue = value;
|
||||
saved.type = 'modify';
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
notifyChange(wasDirty);
|
||||
},
|
||||
clear(...objs) {
|
||||
if (data.size && (
|
||||
objs.length
|
||||
? objs.map(data.delete, data).includes(true)
|
||||
: (data.clear(), true)
|
||||
)) {
|
||||
notifyChange(true);
|
||||
}
|
||||
},
|
||||
has(key) {
|
||||
return data.has(key);
|
||||
},
|
||||
isDirty() {
|
||||
return data.size > 0;
|
||||
},
|
||||
modify(obj, oldValue, newValue) {
|
||||
const wasDirty = data.size > 0;
|
||||
const saved = data.get(obj);
|
||||
if (!saved) {
|
||||
if (oldValue !== newValue) {
|
||||
data.set(obj, {type: 'modify', savedValue: oldValue, newValue});
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
} else if (saved.type === 'modify') {
|
||||
if (saved.savedValue === newValue) {
|
||||
data.delete(obj);
|
||||
} else {
|
||||
saved.newValue = newValue;
|
||||
}
|
||||
} else if (saved.type === 'add') {
|
||||
saved.newValue = newValue;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
notifyChange(wasDirty);
|
||||
},
|
||||
onChange(cb, add = true) {
|
||||
listeners[add ? 'add' : 'delete'](cb);
|
||||
},
|
||||
onDataChange(cb, add = true) {
|
||||
dataListeners[add ? 'add' : 'delete'](cb);
|
||||
},
|
||||
remove(obj, value) {
|
||||
const wasDirty = data.size > 0;
|
||||
const saved = data.get(obj);
|
||||
if (!saved) {
|
||||
data.set(obj, {type: 'remove', savedValue: value});
|
||||
} else if (saved.type === 'add') {
|
||||
data.delete(obj);
|
||||
} else if (saved.type === 'modify') {
|
||||
saved.type = 'remove';
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
notifyChange(wasDirty);
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
function LivePreview() {
|
||||
let el;
|
||||
let data;
|
||||
let port;
|
||||
let preprocess;
|
||||
let enabled = prefs.get('editor.livePreview');
|
||||
|
||||
prefs.subscribe('editor.livePreview', (key, value) => {
|
||||
if (!value) {
|
||||
if (port) {
|
||||
port.disconnect();
|
||||
port = null;
|
||||
}
|
||||
} else if (data && data.id && (data.enabled || editor.dirty.has('enabled'))) {
|
||||
createPreviewer();
|
||||
updatePreviewer(data);
|
||||
}
|
||||
enabled = value;
|
||||
});
|
||||
|
||||
return {
|
||||
|
||||
/**
|
||||
* @param {Function} [fn] - preprocessor
|
||||
*/
|
||||
init(fn) {
|
||||
preprocess = fn;
|
||||
},
|
||||
|
||||
update(newData) {
|
||||
data = newData;
|
||||
if (!port) {
|
||||
if (!data.id || !data.enabled || !enabled) {
|
||||
return;
|
||||
}
|
||||
createPreviewer();
|
||||
}
|
||||
updatePreviewer(data);
|
||||
},
|
||||
};
|
||||
|
||||
function createPreviewer() {
|
||||
port = chrome.runtime.connect({name: 'livePreview'});
|
||||
port.onDisconnect.addListener(err => {
|
||||
throw err;
|
||||
});
|
||||
el = $('#preview-errors');
|
||||
el.onclick = () => messageBoxProxy.alert(el.title, 'pre');
|
||||
}
|
||||
|
||||
async function updatePreviewer(data) {
|
||||
try {
|
||||
port.postMessage(preprocess ? await preprocess(data) : data);
|
||||
el.hidden = true;
|
||||
} catch (err) {
|
||||
if (Array.isArray(err)) {
|
||||
err = err.map(e => e.message || e).join('\n');
|
||||
} else if (err && err.index != null) {
|
||||
// FIXME: this would fail if editors[0].getValue() !== data.sourceCode
|
||||
const pos = editor.getEditors()[0].posFromIndex(err.index);
|
||||
err.message = `${pos.line}:${pos.ch} ${err.message || err}`;
|
||||
}
|
||||
el.title = err.message || `${err}`;
|
||||
el.hidden = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//#endregion
|
174
edit/beautify.js
Normal file
174
edit/beautify.js
Normal file
|
@ -0,0 +1,174 @@
|
|||
/* global $ $create moveFocus */// dom.js
|
||||
/* global CodeMirror */
|
||||
/* global createHotkeyInput helpPopup */// util.js
|
||||
/* global editor */
|
||||
/* global prefs */
|
||||
/* global t */// localization.js
|
||||
'use strict';
|
||||
|
||||
CodeMirror.commands.beautify = cm => {
|
||||
// using per-section mode when code editor or applies-to block is focused
|
||||
const isPerSection = cm.display.wrapper.parentElement.contains(document.activeElement);
|
||||
beautify(isPerSection ? [cm] : editor.getEditors(), false);
|
||||
};
|
||||
|
||||
prefs.subscribe('editor.beautify.hotkey', (key, value) => {
|
||||
const {extraKeys} = CodeMirror.defaults;
|
||||
for (const [key, cmd] of Object.entries(extraKeys)) {
|
||||
if (cmd === 'beautify') {
|
||||
delete extraKeys[key];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (value) {
|
||||
extraKeys[value] = 'beautify';
|
||||
}
|
||||
}, {runNow: true});
|
||||
|
||||
/**
|
||||
* @name beautify
|
||||
* @param {CodeMirror[]} scope
|
||||
* @param {boolean} [ui=true]
|
||||
*/
|
||||
async function beautify(scope, ui = true) {
|
||||
await require(['/vendor-overwrites/beautify/beautify-css-mod']); /* global css_beautify */
|
||||
const tabs = prefs.get('editor.indentWithTabs');
|
||||
const options = Object.assign(prefs.defaults['editor.beautify'], prefs.get('editor.beautify'));
|
||||
options.indent_size = tabs ? 1 : prefs.get('editor.tabSize');
|
||||
options.indent_char = tabs ? '\t' : ' ';
|
||||
if (ui) {
|
||||
createBeautifyUI(scope, options);
|
||||
}
|
||||
for (const cm of scope) {
|
||||
setTimeout(beautifyEditor, 0, cm, options, ui);
|
||||
}
|
||||
}
|
||||
|
||||
function beautifyEditor(cm, options, ui) {
|
||||
const pos = options.translate_positions =
|
||||
[].concat.apply([], cm.doc.sel.ranges.map(r =>
|
||||
[Object.assign({}, r.anchor), Object.assign({}, r.head)]));
|
||||
const text = cm.getValue();
|
||||
const newText = css_beautify(text, options);
|
||||
if (newText !== text) {
|
||||
if (!cm.beautifyChange || !cm.beautifyChange[cm.changeGeneration()]) {
|
||||
// clear the list if last change wasn't a css-beautify
|
||||
cm.beautifyChange = {};
|
||||
}
|
||||
cm.setValue(newText);
|
||||
const selections = [];
|
||||
for (let i = 0; i < pos.length; i += 2) {
|
||||
selections.push({anchor: pos[i], head: pos[i + 1]});
|
||||
}
|
||||
const {scrollX, scrollY} = window;
|
||||
cm.setSelections(selections);
|
||||
window.scrollTo(scrollX, scrollY);
|
||||
cm.beautifyChange[cm.changeGeneration()] = true;
|
||||
if (ui) {
|
||||
$('button[role="close"]', helpPopup.div).disabled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function createBeautifyUI(scope, options) {
|
||||
helpPopup.show(t('styleBeautify'),
|
||||
$create([
|
||||
$create('.beautify-options', [
|
||||
$createOption('.selector1,', 'selector_separator_newline'),
|
||||
$createOption('.selector2', 'newline_before_open_brace'),
|
||||
$createOption('{', 'newline_after_open_brace'),
|
||||
$createOption('border: none;', 'newline_between_properties', true),
|
||||
$createOption('display: block;', 'newline_before_close_brace', true),
|
||||
$createOption('}', 'newline_between_rules'),
|
||||
$createLabeledCheckbox('preserve_newlines', 'styleBeautifyPreserveNewlines'),
|
||||
$createLabeledCheckbox('indent_conditional', 'styleBeautifyIndentConditional'),
|
||||
editor.isUsercss && $createLabeledCheckbox('indent_mozdoc', '', '... @-moz-document'),
|
||||
]),
|
||||
$create('p.beautify-hint', [
|
||||
$create('span', t('styleBeautifyHint') + '\u00A0'),
|
||||
createHotkeyInput('editor.beautify.hotkey', {
|
||||
buttons: false,
|
||||
onDone: () => moveFocus(helpPopup.div, 0),
|
||||
}),
|
||||
]),
|
||||
$create('.buttons', [
|
||||
$create('button', {
|
||||
attributes: {role: 'close'},
|
||||
onclick: helpPopup.close,
|
||||
}, t('confirmClose')),
|
||||
$create('button', {
|
||||
attributes: {role: 'undo'},
|
||||
onclick() {
|
||||
let undoable = false;
|
||||
for (const cm of scope) {
|
||||
const data = cm.beautifyChange;
|
||||
if (!data || !data[cm.changeGeneration()]) continue;
|
||||
delete data[cm.changeGeneration()];
|
||||
const {scrollX, scrollY} = window;
|
||||
cm.undo();
|
||||
cm.scrollIntoView(cm.getCursor());
|
||||
window.scrollTo(scrollX, scrollY);
|
||||
undoable |= data[cm.changeGeneration()];
|
||||
}
|
||||
this.disabled = !undoable;
|
||||
},
|
||||
}, t(scope.length === 1 ? 'undo' : 'undoGlobal')),
|
||||
]),
|
||||
]),
|
||||
{
|
||||
className: 'wide',
|
||||
});
|
||||
|
||||
$('.beautify-options').onchange = ({target}) => {
|
||||
const value = target.type === 'checkbox' ? target.checked : target.selectedIndex > 0;
|
||||
const elLine = target.closest('[newline]');
|
||||
if (elLine) elLine.setAttribute('newline', value);
|
||||
prefs.set('editor.beautify', Object.assign(options, {[target.dataset.option]: value}));
|
||||
beautify(scope, false);
|
||||
};
|
||||
|
||||
function $createOption(label, optionName, indent) {
|
||||
const value = options[optionName];
|
||||
return (
|
||||
$create('div', {attributes: {newline: value}}, [
|
||||
$create('span', indent ? {attributes: {indent: ''}} : {}, label),
|
||||
$create('div.select-resizer', [
|
||||
$create('select', {dataset: {option: optionName}}, [
|
||||
$create('option', {selected: !value}, '\xA0'),
|
||||
$create('option', {selected: value}, '\\n'),
|
||||
]),
|
||||
$create('SVG:svg.svg-icon.select-arrow', {viewBox: '0 0 1792 1792'}, [
|
||||
$create('SVG:path', {
|
||||
'fill-rule': 'evenodd',
|
||||
'd': 'M1408 704q0 26-19 45l-448 448q-19 19-45 ' +
|
||||
'19t-45-19l-448-448q-19-19-19-45t19-45 45-19h896q26 0 45 19t19 45z',
|
||||
}),
|
||||
]),
|
||||
]),
|
||||
])
|
||||
);
|
||||
}
|
||||
|
||||
function $createLabeledCheckbox(optionName, i18nKey, text) {
|
||||
return (
|
||||
$create('label', {style: 'display: block; clear: both;'}, [
|
||||
$create('input', {
|
||||
type: 'checkbox',
|
||||
dataset: {option: optionName},
|
||||
checked: options[optionName] !== false,
|
||||
}),
|
||||
$create('SVG:svg.svg-icon.checked',
|
||||
$create('SVG:use', {'xlink:href': '#svg-icon-checked'})),
|
||||
i18nKey ? t(i18nKey) : text,
|
||||
])
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/* exported initBeautifyButton */
|
||||
function initBeautifyButton(btn, scope) {
|
||||
btn.onclick = btn.oncontextmenu = e => {
|
||||
e.preventDefault();
|
||||
beautify(scope || editor.getEditors(), e.type === 'click');
|
||||
};
|
||||
}
|
|
@ -1,19 +1,33 @@
|
|||
/* Built-in CodeMirror and addon customization */
|
||||
|
||||
.CodeMirror-hints {
|
||||
z-index: 999;
|
||||
}
|
||||
.CodeMirror-hint:hover {
|
||||
color: white;
|
||||
color: var(--bg);
|
||||
background: #08f;
|
||||
}
|
||||
.CodeMirror {
|
||||
border: solid #CCC 1px;
|
||||
border: solid var(--c80) 1px;
|
||||
transition: box-shadow .1s;
|
||||
}
|
||||
.CodeMirror-lint-mark-warning {
|
||||
background: none;
|
||||
.CodeMirror {
|
||||
color: inherit;
|
||||
background-color: inherit;
|
||||
border: solid var(--c80) 1px;
|
||||
transition: box-shadow .1s;
|
||||
}
|
||||
.CodeMirror-gutters {
|
||||
background-color: var(--c95);
|
||||
border-color: var(--c85);
|
||||
}
|
||||
#stylus#stylus .CodeMirror {
|
||||
/* Using a specificity hack to override userstyles */
|
||||
/* Not using the ring-color hack as it became ugly in new Chrome */
|
||||
outline: none !important;
|
||||
}
|
||||
.CodeMirror-dialog {
|
||||
-webkit-animation: highlight 3s ease-out;
|
||||
}
|
||||
.CodeMirror-focused {
|
||||
outline: -webkit-focus-ring-color auto 5px;
|
||||
outline-offset: -2px;
|
||||
animation: highlight 3s cubic-bezier(.18, .02, 0, .94);
|
||||
}
|
||||
.CodeMirror-search-field {
|
||||
width: 10em;
|
||||
|
@ -22,5 +36,113 @@
|
|||
width: 5em;
|
||||
}
|
||||
.CodeMirror-search-hint {
|
||||
color: #888;
|
||||
color: var(--c50);
|
||||
}
|
||||
.CodeMirror-activeline .applies-to:before {
|
||||
background-color: hsla(214, 100%, 90%, 0.15);
|
||||
content: "";
|
||||
top: 1em;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 1em;
|
||||
position: absolute;
|
||||
pointer-events: none;
|
||||
}
|
||||
.CodeMirror-activeline .applies-to ul {
|
||||
z-index: 2;
|
||||
}
|
||||
.CodeMirror-foldgutter-open::after,
|
||||
.CodeMirror-foldgutter-folded::after {
|
||||
top: 5px;
|
||||
width: 0;
|
||||
height: 0;
|
||||
content: "";
|
||||
position: absolute;
|
||||
border-style: solid;
|
||||
opacity: .5;
|
||||
left: 1px;
|
||||
}
|
||||
.CodeMirror-foldgutter-open::after {
|
||||
border-width: 5px 3px 0 3px;
|
||||
border-color: currentColor transparent transparent transparent;
|
||||
}
|
||||
.CodeMirror-foldgutter-folded::after {
|
||||
margin-top: -2px;
|
||||
margin-left: 1px;
|
||||
border-width: 4px 0 4px 5px;
|
||||
border-color: transparent transparent transparent currentColor;
|
||||
}
|
||||
.CodeMirror-linenumber {
|
||||
cursor: pointer; /* for bookmarking */
|
||||
}
|
||||
.cm-matchhighlight,
|
||||
.CodeMirror-selection-highlight-scrollbar {
|
||||
background: hsla(200, 100%, 50%, var(--match-hl-opacity, .1));
|
||||
}
|
||||
|
||||
/* Custom stuff we add to CodeMirror */
|
||||
|
||||
.cm-uso-variable {
|
||||
font-weight: bold;
|
||||
}
|
||||
.gutter-bookmark {
|
||||
background: linear-gradient(0deg, hsla(180, 100%, 30%, .75) 2px, hsla(180, 100%, 30%, .2) 2px);
|
||||
}
|
||||
|
||||
@media screen and (prefers-color-scheme: dark), dark {
|
||||
.CodeMirror {
|
||||
--match-hl-opacity: .18;
|
||||
}
|
||||
.CodeMirror-dialog {
|
||||
background-color: #333;
|
||||
}
|
||||
.CodeMirror-dialog-top {
|
||||
border-color: #555;
|
||||
}
|
||||
.CodeMirror-activeline-background {
|
||||
background: hsl(180, 21%, 18%);
|
||||
}
|
||||
.CodeMirror-selected,
|
||||
.CodeMirror-focused .CodeMirror-selected,
|
||||
.CodeMirror-line::selection,
|
||||
.CodeMirror-line > span::selection,
|
||||
.CodeMirror-line > span > span::selection {
|
||||
background: #444;
|
||||
}
|
||||
.CodeMirror-line::-moz-selection,
|
||||
.CodeMirror-line > span::-moz-selection,
|
||||
.CodeMirror-line > span > span::-moz-selection {
|
||||
/* TODO: remove this when strict_min_version >= 62 */
|
||||
background: #444;
|
||||
}
|
||||
.cm-s-default div.CodeMirror-cursor {
|
||||
border-left: 1px solid #fff;
|
||||
}
|
||||
/* Using Chromium's dark devtools colors */
|
||||
.cm-s-default .cm-atom,
|
||||
.cm-s-default .cm-number { color: #a1f7b5 }
|
||||
.cm-s-default .cm-attribute { color: #6194c6 }
|
||||
.cm-s-default .cm-bracket { color: #997 }
|
||||
.cm-s-default .cm-builtin,
|
||||
.cm-s-default .cm-link { color: #9fb4d6 }
|
||||
.cm-s-default .cm-comment { color: #747474 }
|
||||
.cm-s-default .cm-qualifier { color: #ffa34f }
|
||||
.cm-s-default .cm-def,
|
||||
.cm-s-default .cm-header,
|
||||
.cm-s-default .cm-tag,
|
||||
.cm-s-default .cm-type { color: #5db0d7 }
|
||||
.cm-s-default .cm-hr { color: #999 }
|
||||
.cm-s-default .cm-keyword { color: #9a7fd5 }
|
||||
.cm-s-default .cm-meta { color: #ddfb55 }
|
||||
.cm-s-default .cm-operator { color: #d2c057 }
|
||||
.cm-s-default .cm-string { color: #f28b54 }
|
||||
.cm-s-default .cm-variable { color: #d9d9d9 }
|
||||
.cm-s-default .cm-variable-2 { color: #72b9ff }
|
||||
.cm-s-default .cm-variable-3 { color: #9bbbdc }
|
||||
|
||||
@keyframes highlight {
|
||||
from {
|
||||
background-color: #888;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,17 +1,22 @@
|
|||
/* global CodeMirror prefs */
|
||||
|
||||
/* global $ */// dom.js
|
||||
/* global CodeMirror */
|
||||
/* global UA */// toolbox.js
|
||||
/* global editor */
|
||||
/* global prefs */
|
||||
/* global t */// localization.js
|
||||
'use strict';
|
||||
|
||||
(function () {
|
||||
(() => {
|
||||
// CodeMirror miserably fails on keyMap='' so let's ensure it's not
|
||||
if (!prefs.get('editor.keyMap')) {
|
||||
prefs.reset('editor.keyMap');
|
||||
}
|
||||
|
||||
const defaults = {
|
||||
autoCloseBrackets: prefs.get('editor.autoCloseBrackets'),
|
||||
mode: 'css',
|
||||
lineNumbers: true,
|
||||
lineWrapping: true,
|
||||
lineWrapping: prefs.get('editor.lineWrapping'),
|
||||
foldGutter: true,
|
||||
gutters: [
|
||||
'CodeMirror-linenumbers',
|
||||
|
@ -19,96 +24,125 @@
|
|||
...(prefs.get('editor.linter') ? ['CodeMirror-lint-markers'] : []),
|
||||
],
|
||||
matchBrackets: true,
|
||||
highlightSelectionMatches: {showToken: /[#.\-\w]/, annotateScrollbar: true},
|
||||
hintOptions: {},
|
||||
lintReportDelay: prefs.get('editor.lintReportDelay'),
|
||||
styleActiveLine: true,
|
||||
theme: 'default',
|
||||
styleActiveLine: {nonEmpty: true},
|
||||
theme: prefs.get('editor.theme'),
|
||||
keyMap: prefs.get('editor.keyMap'),
|
||||
extraKeys: {
|
||||
// independent of current keyMap
|
||||
extraKeys: Object.assign(CodeMirror.defaults.extraKeys || {}, {
|
||||
// independent of current keyMap; some are implemented only for the edit page
|
||||
'Alt-Enter': 'toggleStyle',
|
||||
'Alt-PageDown': 'nextEditor',
|
||||
'Alt-PageUp': 'prevEditor'
|
||||
}
|
||||
'Alt-PageUp': 'prevEditor',
|
||||
'Ctrl-Pause': 'toggleEditorFocus',
|
||||
}),
|
||||
maxHighlightLength: 100e3,
|
||||
};
|
||||
|
||||
Object.assign(CodeMirror.defaults, defaults, prefs.get('editor.options'));
|
||||
|
||||
CodeMirror.commands.blockComment = cm => {
|
||||
cm.blockComment(cm.getCursor('from'), cm.getCursor('to'), {fullLines: false});
|
||||
};
|
||||
|
||||
// 'basic' keymap only has basic keys by design, so we skip it
|
||||
|
||||
const extraKeysCommands = {};
|
||||
Object.keys(CodeMirror.defaults.extraKeys).forEach(key => {
|
||||
extraKeysCommands[CodeMirror.defaults.extraKeys[key]] = true;
|
||||
});
|
||||
if (!extraKeysCommands.jumpToLine) {
|
||||
CodeMirror.keyMap.sublime['Ctrl-G'] = 'jumpToLine';
|
||||
CodeMirror.keyMap.emacsy['Ctrl-G'] = 'jumpToLine';
|
||||
CodeMirror.keyMap.pcDefault['Ctrl-J'] = 'jumpToLine';
|
||||
CodeMirror.keyMap.macDefault['Cmd-J'] = 'jumpToLine';
|
||||
}
|
||||
if (!extraKeysCommands.autocomplete) {
|
||||
// will be used by 'sublime' on PC via fallthrough
|
||||
CodeMirror.keyMap.pcDefault['Ctrl-Space'] = 'autocomplete';
|
||||
// OSX uses Ctrl-Space and Cmd-Space for something else
|
||||
CodeMirror.keyMap.macDefault['Alt-Space'] = 'autocomplete';
|
||||
// copied from 'emacs' keymap
|
||||
CodeMirror.keyMap.emacsy['Alt-/'] = 'autocomplete';
|
||||
// 'vim' and 'emacs' define their own autocomplete hotkeys
|
||||
}
|
||||
if (!extraKeysCommands.blockComment) {
|
||||
CodeMirror.keyMap.sublime['Shift-Ctrl-/'] = 'blockComment';
|
||||
}
|
||||
|
||||
if (navigator.appVersion.includes('Windows')) {
|
||||
// 'pcDefault' keymap on Windows should have F3/Shift-F3
|
||||
if (!extraKeysCommands.findNext) {
|
||||
CodeMirror.keyMap.pcDefault['F3'] = 'findNext';
|
||||
// Adding hotkeys to some keymaps except 'basic' which is primitive by design
|
||||
{
|
||||
const KM = CodeMirror.keyMap;
|
||||
const extras = Object.values(CodeMirror.defaults.extraKeys);
|
||||
if (!extras.includes('jumpToLine')) {
|
||||
KM.sublime['Ctrl-G'] = 'jumpToLine';
|
||||
KM.emacsy['Ctrl-G'] = 'jumpToLine';
|
||||
KM.pcDefault['Ctrl-J'] = 'jumpToLine';
|
||||
KM.macDefault['Cmd-J'] = 'jumpToLine';
|
||||
}
|
||||
if (!extraKeysCommands.findPrev) {
|
||||
CodeMirror.keyMap.pcDefault['Shift-F3'] = 'findPrev';
|
||||
if (!extras.includes('autocomplete')) {
|
||||
// will be used by 'sublime' on PC via fallthrough
|
||||
KM.pcDefault['Ctrl-Space'] = 'autocomplete';
|
||||
// OSX uses Ctrl-Space and Cmd-Space for something else
|
||||
KM.macDefault['Alt-Space'] = 'autocomplete';
|
||||
// copied from 'emacs' keymap
|
||||
KM.emacsy['Alt-/'] = 'autocomplete';
|
||||
// 'vim' and 'emacs' define their own autocomplete hotkeys
|
||||
}
|
||||
|
||||
// try to remap non-interceptable Ctrl-(Shift-)N/T/W hotkeys
|
||||
['N', 'T', 'W'].forEach(char => {
|
||||
[
|
||||
{from: 'Ctrl-', to: ['Alt-', 'Ctrl-Alt-']},
|
||||
// Note: modifier order in CodeMirror is S-C-A
|
||||
{from: 'Shift-Ctrl-', to: ['Ctrl-Alt-', 'Shift-Ctrl-Alt-']}
|
||||
].forEach(remap => {
|
||||
const oldKey = remap.from + char;
|
||||
Object.keys(CodeMirror.keyMap).forEach(keyMapName => {
|
||||
const keyMap = CodeMirror.keyMap[keyMapName];
|
||||
const command = keyMap[oldKey];
|
||||
if (!command) {
|
||||
return;
|
||||
}
|
||||
remap.to.some(newMod => {
|
||||
const newKey = newMod + char;
|
||||
if (!(newKey in keyMap)) {
|
||||
delete keyMap[oldKey];
|
||||
keyMap[newKey] = command;
|
||||
return true;
|
||||
if (!extras.includes('blockComment')) {
|
||||
KM.sublime['Shift-Ctrl-/'] = 'commentSelection';
|
||||
}
|
||||
if (UA.windows) {
|
||||
// 'pcDefault' keymap on Windows should have F3/Shift-F3/Ctrl-R
|
||||
if (!extras.includes('findNext')) KM.pcDefault['F3'] = 'findNext';
|
||||
if (!extras.includes('findPrev')) KM.pcDefault['Shift-F3'] = 'findPrev';
|
||||
if (!extras.includes('replace')) KM.pcDefault['Ctrl-R'] = 'replace';
|
||||
// try to remap non-interceptable (Shift-)Ctrl-N/T/W hotkeys
|
||||
// Note: modifier order in CodeMirror is S-C-A
|
||||
for (const char of ['N', 'T', 'W']) {
|
||||
for (const remap of [
|
||||
{from: 'Ctrl-', to: ['Alt-', 'Ctrl-Alt-']},
|
||||
{from: 'Shift-Ctrl-', to: ['Ctrl-Alt-', 'Shift-Ctrl-Alt-']},
|
||||
]) {
|
||||
const oldKey = remap.from + char;
|
||||
for (const km of Object.values(KM)) {
|
||||
const command = km[oldKey];
|
||||
if (!command) continue;
|
||||
for (const newMod of remap.to) {
|
||||
const newKey = newMod + char;
|
||||
if (newKey in km) continue;
|
||||
km[newKey] = command;
|
||||
delete km[oldKey];
|
||||
break;
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CodeMirror.modeURL = '/vendor/codemirror/mode/%N/%N.js';
|
||||
Object.assign(CodeMirror.prototype, {
|
||||
/**
|
||||
* @param {'less' | 'stylus' | ?} [pp] - any value besides `less` or `stylus` sets `css` mode
|
||||
* @param {boolean} [force]
|
||||
*/
|
||||
setPreprocessor(pp, force) {
|
||||
const name = pp === 'less' ? 'text/x-less' : pp === 'stylus' ? pp : 'css';
|
||||
const m = this.doc.mode;
|
||||
if (force || (m.helperType ? m.helperType !== pp : m.name !== name)) {
|
||||
this.setOption('mode', name);
|
||||
this.doc.mode.lineComment = ''; // stylelint chokes on line comments a lot
|
||||
}
|
||||
},
|
||||
/** Superfast GC-friendly check that runs until the first non-space line */
|
||||
isBlank() {
|
||||
let filled;
|
||||
this.eachLine(({text}) => (filled = text && /\S/.test(text)));
|
||||
return !filled;
|
||||
},
|
||||
/**
|
||||
* Sets cursor and centers it in view if `pos` was out of view
|
||||
* @param {CodeMirror.Pos} pos
|
||||
* @param {CodeMirror.Pos} [end] - will set a selection from `pos` to `end`
|
||||
*/
|
||||
jumpToPos(pos, end = pos) {
|
||||
const {curOp} = this;
|
||||
if (!curOp) this.startOperation();
|
||||
const y = this.cursorCoords(pos, 'window').top;
|
||||
const rect = this.display.wrapper.getBoundingClientRect();
|
||||
// case 1) outside of CM viewport or too close to edge so tell CM to render a new viewport
|
||||
if (y < rect.top + 50 || y > rect.bottom - 100) {
|
||||
this.scrollIntoView(pos, rect.height / 2);
|
||||
// case 2) inside CM viewport but outside of window viewport so just scroll the window
|
||||
} else if (y < 0 || y > innerHeight) {
|
||||
editor.scrollToEditor(this);
|
||||
}
|
||||
// Using prototype since our bookmark patch sets cm.setSelection to jumpToPos
|
||||
CodeMirror.prototype.setSelection.call(this, pos, end);
|
||||
if (!curOp) this.endOperation();
|
||||
},
|
||||
});
|
||||
|
||||
const MODE = {
|
||||
stylus: 'stylus',
|
||||
uso: 'css'
|
||||
};
|
||||
|
||||
CodeMirror.defineExtension('setPreprocessor', function (preprocessor) {
|
||||
this.setOption('mode', MODE[preprocessor] || 'css');
|
||||
CodeMirror.autoLoadMode(this, MODE[preprocessor] || 'css');
|
||||
Object.assign(CodeMirror.commands, {
|
||||
jumpToLine(cm) {
|
||||
const cur = cm.getCursor();
|
||||
const oldDialog = $('.CodeMirror-dialog', cm.display.wrapper);
|
||||
if (oldDialog) cm.focus(); // close the currently opened minidialog
|
||||
cm.openDialog(t.template.jumpToLine.cloneNode(true), str => {
|
||||
const [line, ch] = str.match(/^\s*(\d+)(?:\s*:\s*(\d+))?\s*$|$/);
|
||||
if (line) cm.setCursor(line - 1, ch ? ch - 1 : cur.ch);
|
||||
}, {value: cur.line + 1});
|
||||
},
|
||||
});
|
||||
})();
|
||||
|
|
313
edit/codemirror-factory.js
Normal file
313
edit/codemirror-factory.js
Normal file
|
@ -0,0 +1,313 @@
|
|||
/* global CodeMirror */
|
||||
/* global editor */
|
||||
/* global prefs */
|
||||
/* global rerouteHotkeys */// util.js
|
||||
'use strict';
|
||||
|
||||
/*
|
||||
All cm instances created by this module are collected so we can broadcast prefs
|
||||
settings to them. You should `cmFactory.destroy(cm)` to unregister the listener
|
||||
when the instance is not used anymore.
|
||||
*/
|
||||
|
||||
(() => {
|
||||
//#region Factory
|
||||
|
||||
const cms = new Set();
|
||||
let lazyOpt;
|
||||
|
||||
const cmFactory = window.cmFactory = {
|
||||
|
||||
create(place, options) {
|
||||
const cm = CodeMirror(place, options);
|
||||
cm.lastActive = 0;
|
||||
cms.add(cm);
|
||||
return cm;
|
||||
},
|
||||
|
||||
destroy(cm) {
|
||||
cms.delete(cm);
|
||||
},
|
||||
|
||||
globalSetOption(key, value) {
|
||||
CodeMirror.defaults[key] = value;
|
||||
if (cms.size > 4 && lazyOpt.names.includes(key)) {
|
||||
lazyOpt.set(key, value);
|
||||
} else {
|
||||
cms.forEach(cm => cm.setOption(key, value));
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
// focus and blur
|
||||
|
||||
const onCmFocus = cm => {
|
||||
rerouteHotkeys.toggle(false);
|
||||
cm.display.wrapper.classList.add('CodeMirror-active');
|
||||
cm.lastActive = Date.now();
|
||||
};
|
||||
const onCmBlur = cm => {
|
||||
setTimeout(() => {
|
||||
/* Delaying to next tick to avoid double-processing of the currently processed keyboard event
|
||||
* when it bubbles up from CodeMirror to `document` where the rerouter listens */
|
||||
rerouteHotkeys.toggle(true);
|
||||
const {wrapper} = cm.display;
|
||||
wrapper.classList.toggle('CodeMirror-active', wrapper.contains(document.activeElement));
|
||||
});
|
||||
};
|
||||
CodeMirror.defineInitHook(cm => {
|
||||
cm.on('focus', onCmFocus);
|
||||
cm.on('blur', onCmBlur);
|
||||
});
|
||||
|
||||
// propagated preferences
|
||||
|
||||
const prefToCmOpt = k =>
|
||||
k.startsWith('editor.') &&
|
||||
k.slice('editor.'.length);
|
||||
const prefKeys = prefs.knownKeys.filter(k =>
|
||||
k !== 'editor.colorpicker' && // handled in colorpicker-helper.js
|
||||
k !== 'editor.arrowKeysTraverse' && // handled in sections-editor.js
|
||||
prefToCmOpt(k) in CodeMirror.defaults);
|
||||
const {insertTab, insertSoftTab} = CodeMirror.commands;
|
||||
|
||||
for (const [key, fn] of Object.entries({
|
||||
'editor.tabSize'(cm, value) {
|
||||
cm.setOption('indentUnit', Number(value));
|
||||
},
|
||||
'editor.indentWithTabs'(cm, value) {
|
||||
CodeMirror.commands.insertTab = value ? insertTab : insertSoftTab;
|
||||
},
|
||||
'editor.matchHighlight'(cm, value) {
|
||||
const showToken = value === 'token' && /[#.\-\w]/;
|
||||
const opt = (showToken || value === 'selection') && {
|
||||
showToken,
|
||||
annotateScrollbar: true,
|
||||
delay: 0,
|
||||
onUpdate: updateMatchHighlightCount,
|
||||
};
|
||||
cm.setOption('highlightSelectionMatches', opt || null);
|
||||
},
|
||||
'editor.selectByTokens'(cm, value) {
|
||||
cm.setOption('configureMouse', value ? configureMouseFn : null);
|
||||
},
|
||||
})) {
|
||||
CodeMirror.defineOption(prefToCmOpt(key), prefs.get(key), fn);
|
||||
prefKeys.push(key);
|
||||
}
|
||||
|
||||
prefs.subscribe(prefKeys, (key, val) => {
|
||||
if (key === 'editor.theme') editor.updateTheme(val);
|
||||
cmFactory.globalSetOption(prefToCmOpt(key), val);
|
||||
});
|
||||
|
||||
// lazy propagation
|
||||
|
||||
lazyOpt = {
|
||||
names: ['theme', 'lineWrapping'],
|
||||
set(key, value) {
|
||||
const {observer, queue} = lazyOpt;
|
||||
for (const cm of cms) {
|
||||
let opts = queue.get(cm);
|
||||
if (!opts) queue.set(cm, opts = {});
|
||||
opts[key] = value;
|
||||
observer.observe(cm.display.wrapper);
|
||||
}
|
||||
},
|
||||
setNow({cm, data}) {
|
||||
cm.operation(() => data.forEach(kv => cm.setOption(...kv)));
|
||||
},
|
||||
onView(entries) {
|
||||
const {queue, observer} = lazyOpt;
|
||||
const delayed = [];
|
||||
for (const e of entries) {
|
||||
const r = e.isIntersecting && e.intersectionRect;
|
||||
if (!r) continue;
|
||||
const cm = e.target.CodeMirror;
|
||||
const data = Object.entries(queue.get(cm) || {});
|
||||
queue.delete(cm);
|
||||
observer.unobserve(e.target);
|
||||
if (!data.every(([key, val]) => cm.getOption(key) === val)) {
|
||||
if (r.bottom > 0 && r.top < window.innerHeight) {
|
||||
lazyOpt.setNow({cm, data});
|
||||
} else {
|
||||
delayed.push({cm, data});
|
||||
}
|
||||
}
|
||||
}
|
||||
if (delayed.length) {
|
||||
setTimeout(() => delayed.forEach(lazyOpt.setNow));
|
||||
}
|
||||
},
|
||||
get observer() {
|
||||
if (!lazyOpt._observer) {
|
||||
// must exceed refreshOnView's 100%
|
||||
lazyOpt._observer = new IntersectionObserver(lazyOpt.onView, {rootMargin: '150%'});
|
||||
lazyOpt.queue = new WeakMap();
|
||||
}
|
||||
return lazyOpt._observer;
|
||||
},
|
||||
};
|
||||
|
||||
//#endregion
|
||||
//#region Commands
|
||||
|
||||
Object.assign(CodeMirror.commands, {
|
||||
commentSelection(cm) {
|
||||
cm.blockComment(cm.getCursor('from'), cm.getCursor('to'), {fullLines: false});
|
||||
},
|
||||
toggleEditorFocus(cm) {
|
||||
if (!cm) return;
|
||||
if (cm.hasFocus()) {
|
||||
setTimeout(() => cm.display.input.blur());
|
||||
} else {
|
||||
cm.focus();
|
||||
}
|
||||
},
|
||||
});
|
||||
for (const cmd of [
|
||||
'nextEditor',
|
||||
'prevEditor',
|
||||
'save',
|
||||
'toggleStyle',
|
||||
]) {
|
||||
CodeMirror.commands[cmd] = (...args) => editor[cmd](...args);
|
||||
}
|
||||
|
||||
//#endregion
|
||||
//#region CM option handlers
|
||||
|
||||
function updateMatchHighlightCount(cm, state) {
|
||||
cm.display.wrapper.dataset.matchHighlightCount = state.matchesonscroll.matches.length;
|
||||
}
|
||||
|
||||
function configureMouseFn(cm, repeat) {
|
||||
return repeat === 'double' ?
|
||||
{unit: selectTokenOnDoubleclick} :
|
||||
{};
|
||||
}
|
||||
|
||||
function selectTokenOnDoubleclick(cm, pos) {
|
||||
let {ch} = pos;
|
||||
const {line, sticky} = pos;
|
||||
const {text, styles} = cm.getLineHandle(line);
|
||||
|
||||
const execAt = (rx, i) => (rx.lastIndex = i) && null || rx.exec(text);
|
||||
const at = (rx, i) => (rx.lastIndex = i) && null || rx.test(text);
|
||||
const atWord = ch => at(/\w/y, ch);
|
||||
const atSpace = ch => at(/\s/y, ch);
|
||||
|
||||
const atTokenEnd = styles.indexOf(ch, 1);
|
||||
ch += atTokenEnd < 0 ? 0 : sticky === 'before' && atWord(ch - 1) ? 0 : atSpace(ch + 1) ? 0 : 1;
|
||||
ch = Math.min(text.length, ch);
|
||||
const type = cm.getTokenTypeAt({line, ch: ch + (sticky === 'after' ? 1 : 0)});
|
||||
if (atTokenEnd > 0) ch--;
|
||||
|
||||
const isCss = type && !/^(comment|string)/.test(type);
|
||||
const isNumber = type === 'number';
|
||||
const isSpace = atSpace(ch);
|
||||
let wordChars =
|
||||
isNumber ? /[-+\w.%]/y :
|
||||
isCss ? /[-\w@]/y :
|
||||
isSpace ? /\s/y :
|
||||
atWord(ch) ? /\w/y : /[^\w\s]/y;
|
||||
|
||||
let a = ch;
|
||||
while (a && at(wordChars, a)) a--;
|
||||
a += !a && at(wordChars, a) || isCss && at(/[.!#@]/y, a) ? 0 : at(wordChars, a + 1);
|
||||
|
||||
let b, found;
|
||||
|
||||
if (isNumber) {
|
||||
b = a + execAt(/[+-]?[\d.]+(e\d+)?|$/yi, a)[0].length;
|
||||
found = b >= ch;
|
||||
if (!found) {
|
||||
a = b;
|
||||
ch = a;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
wordChars = isCss ? /[-\w]*/y : new RegExp(wordChars.source + '*', 'uy');
|
||||
b = ch + execAt(wordChars, ch)[0].length;
|
||||
}
|
||||
|
||||
return {
|
||||
from: {line, ch: a},
|
||||
to: {line, ch: b},
|
||||
};
|
||||
}
|
||||
|
||||
//#endregion
|
||||
//#region Bookmarks
|
||||
|
||||
const BM_CLS = 'gutter-bookmark';
|
||||
const BM_BRAND = 'sublimeBookmark';
|
||||
const BM_CLICKER = 'CodeMirror-linenumbers';
|
||||
const BM_DATA = Symbol('data');
|
||||
// TODO: revisit when https://github.com/codemirror/CodeMirror/issues/6716 is fixed
|
||||
const tmProto = CodeMirror.TextMarker.prototype;
|
||||
const tmProtoOvr = {};
|
||||
for (const k of ['clear', 'attachLine', 'detachLine']) {
|
||||
tmProtoOvr[k] = function (line) {
|
||||
const {cm} = this.doc;
|
||||
const withOp = !cm.curOp;
|
||||
if (withOp) cm.startOperation();
|
||||
tmProto[k].apply(this, arguments);
|
||||
cm.curOp.ownsGroup.delayedCallbacks.push(toggleMark.bind(this, this.lines[0], line));
|
||||
if (withOp) cm.endOperation();
|
||||
};
|
||||
}
|
||||
for (const name of ['prevBookmark', 'nextBookmark']) {
|
||||
const cmdFn = CodeMirror.commands[name];
|
||||
CodeMirror.commands[name] = cm => {
|
||||
cm.setSelection = cm.jumpToPos;
|
||||
cmdFn(cm);
|
||||
delete cm.setSelection;
|
||||
};
|
||||
}
|
||||
CodeMirror.defineInitHook(cm => {
|
||||
cm.on('gutterClick', onGutterClick);
|
||||
cm.on('gutterContextMenu', onGutterContextMenu);
|
||||
cm.on('markerAdded', onMarkAdded);
|
||||
});
|
||||
// TODO: reimplement bookmarking so next/prev order is decided solely by the line numbers
|
||||
function onGutterClick(cm, line, name, e) {
|
||||
switch (name === BM_CLICKER && e.button) {
|
||||
case 0: {
|
||||
// main button: toggle
|
||||
const [mark] = cm.findMarks({line, ch: 0}, {line, ch: 1e9}, m => m[BM_BRAND]);
|
||||
cm.setCursor(mark ? mark.find(-1) : {line, ch: 0});
|
||||
cm.execCommand('toggleBookmark');
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
// middle button: select all marks
|
||||
cm.execCommand('selectBookmarks');
|
||||
break;
|
||||
}
|
||||
}
|
||||
function onGutterContextMenu(cm, line, name, e) {
|
||||
if (name === BM_CLICKER) {
|
||||
cm.execCommand(e.ctrlKey ? 'prevBookmark' : 'nextBookmark');
|
||||
e.preventDefault();
|
||||
}
|
||||
}
|
||||
function onMarkAdded(cm, mark) {
|
||||
if (mark[BM_BRAND]) {
|
||||
// CM bug workaround to keep the mark at line start when the above line is removed
|
||||
mark.inclusiveRight = true;
|
||||
Object.assign(mark, tmProtoOvr);
|
||||
toggleMark.call(mark, true, mark[BM_DATA] = mark.lines[0]);
|
||||
}
|
||||
}
|
||||
function toggleMark(state, line = this[BM_DATA]) {
|
||||
this.doc[state ? 'addLineClass' : 'removeLineClass'](line, 'gutter', BM_CLS);
|
||||
if (state) {
|
||||
const bms = this.doc.cm.state.sublimeBookmarks;
|
||||
if (!bms.includes(this)) bms.push(this);
|
||||
}
|
||||
}
|
||||
|
||||
//#endregion
|
||||
})();
|
71
edit/codemirror-themes.js
Normal file
71
edit/codemirror-themes.js
Normal file
File diff suppressed because one or more lines are too long
68
edit/drafts.js
Normal file
68
edit/drafts.js
Normal file
|
@ -0,0 +1,68 @@
|
|||
/* global messageBoxProxy */// dom.js
|
||||
/* global API */// msg.js
|
||||
/* global clamp debounce */// toolbox.js
|
||||
/* global editor */
|
||||
/* global prefs */
|
||||
/* global t */// localization.js
|
||||
'use strict';
|
||||
|
||||
(async function AutosaveDrafts() {
|
||||
const makeId = () => editor.style.id || 'new';
|
||||
let delay;
|
||||
let port;
|
||||
connectPort();
|
||||
|
||||
const draft = await API.drafts.get(makeId());
|
||||
if (draft && draft.isUsercss === editor.isUsercss) {
|
||||
const date = makeRelativeDate(draft.date);
|
||||
if (await messageBoxProxy.confirm(t('draftAction'), 'danger', t('draftTitle', date))) {
|
||||
await editor.replaceStyle(draft.style, draft);
|
||||
} else {
|
||||
API.drafts.delete(makeId());
|
||||
}
|
||||
}
|
||||
|
||||
editor.dirty.onChange(isDirty => isDirty ? connectPort() : port.disconnect());
|
||||
editor.dirty.onDataChange(isDirty => debounce(updateDraft, isDirty ? delay : 0));
|
||||
|
||||
prefs.subscribe('editor.autosaveDraft', (key, val) => {
|
||||
delay = clamp(val * 1000 | 0, 1000, 2 ** 32 - 1);
|
||||
const t = debounce.timers.get(updateDraft);
|
||||
if (t != null) debounce(updateDraft, t ? delay : 0);
|
||||
}, {runNow: true});
|
||||
|
||||
function connectPort() {
|
||||
port = chrome.runtime.connect({name: 'draft:' + makeId()});
|
||||
}
|
||||
|
||||
function makeRelativeDate(date) {
|
||||
let delta = (Date.now() - date) / 1000;
|
||||
if (delta >= 0 && Intl.RelativeTimeFormat) {
|
||||
for (const [span, unit, frac = 1] of [
|
||||
[60, 'second', 0],
|
||||
[60, 'minute', 0],
|
||||
[24, 'hour'],
|
||||
[7, 'day'],
|
||||
[4, 'week'],
|
||||
[12, 'month'],
|
||||
[1e99, 'year'],
|
||||
]) {
|
||||
if (delta < span) {
|
||||
return new Intl.RelativeTimeFormat({style: 'short'}).format(-delta.toFixed(frac), unit);
|
||||
}
|
||||
delta /= span;
|
||||
}
|
||||
}
|
||||
return date.toLocaleString();
|
||||
}
|
||||
|
||||
function updateDraft(isDirty = editor.dirty.isDirty()) {
|
||||
if (!isDirty) return;
|
||||
API.drafts.put({
|
||||
date: Date.now(),
|
||||
isUsercss: editor.isUsercss,
|
||||
style: editor.getValue(true),
|
||||
si: editor.makeScrollInfo(),
|
||||
}, makeId());
|
||||
}
|
||||
})();
|
1018
edit/edit.css
1018
edit/edit.css
File diff suppressed because it is too large
Load Diff
2383
edit/edit.js
2383
edit/edit.js
File diff suppressed because it is too large
Load Diff
176
edit/editor-worker.js
Normal file
176
edit/editor-worker.js
Normal file
|
@ -0,0 +1,176 @@
|
|||
/* global createWorkerApi */// worker-util.js
|
||||
'use strict';
|
||||
|
||||
(() => {
|
||||
let sugarss = false;
|
||||
|
||||
/** @namespace EditorWorker */
|
||||
createWorkerApi({
|
||||
|
||||
async csslint(code, config) {
|
||||
require(['/js/csslint/parserlib', '/js/csslint/csslint']); /* global CSSLint */
|
||||
return CSSLint
|
||||
.verify(code, config).messages
|
||||
.map(m => Object.assign(m, {rule: {id: m.rule.id}}));
|
||||
},
|
||||
|
||||
getCssPropsValues() {
|
||||
require(['/js/csslint/parserlib']); /* global parserlib */
|
||||
const {
|
||||
css: {Colors, GlobalKeywords, Properties},
|
||||
util: {describeProp},
|
||||
} = parserlib;
|
||||
const namedColors = Object.keys(Colors);
|
||||
const rxNonWord = /(?:<.+?>|[^-\w<(]+\d*)+/g;
|
||||
const res = {};
|
||||
// moving vendor-prefixed props to the end
|
||||
const cmp = (a, b) => a[0] === '-' && b[0] !== '-' ? 1 : a < b ? -1 : a > b;
|
||||
for (const [k, v] of Object.entries(Properties)) {
|
||||
res[k] = false;
|
||||
if (typeof v === 'string') {
|
||||
let last = '';
|
||||
const uniq = [];
|
||||
// strip definitions of function arguments
|
||||
const desc = describeProp(v).replace(/([-\w]+)\(.*?\)/g, 'z-$1');
|
||||
const descNoColors = desc.replace(/<named-color>/g, '');
|
||||
// add a prefix to functions to group them at the end
|
||||
const words = descNoColors.split(rxNonWord).sort(cmp);
|
||||
for (let w of words) {
|
||||
if (w.startsWith('z-')) w = w.slice(2) + '(';
|
||||
if (w !== last) uniq.push(last = w);
|
||||
}
|
||||
if (desc !== descNoColors) uniq.push(...namedColors);
|
||||
if (uniq.length) res[k] = uniq;
|
||||
}
|
||||
}
|
||||
return {all: res, global: GlobalKeywords};
|
||||
},
|
||||
|
||||
getRules(linter) {
|
||||
return ruleRetriever[linter](); // eslint-disable-line no-use-before-define
|
||||
},
|
||||
|
||||
metalint(code) {
|
||||
require(['/js/meta-parser']); /* global metaParser */
|
||||
const result = metaParser.lint(code);
|
||||
// extract needed info
|
||||
result.errors = result.errors.map(err => ({
|
||||
code: err.code,
|
||||
args: err.args,
|
||||
message: err.message,
|
||||
index: err.index,
|
||||
}));
|
||||
return result;
|
||||
},
|
||||
|
||||
async stylelint(opts) {
|
||||
require(['/vendor/stylelint-bundle/stylelint-bundle.min']); /* global stylelint */
|
||||
// Stylus-lang allows a trailing ";" but sugarss doesn't, so we monkeypatch it
|
||||
stylelint.SugarSSParser.prototype.checkSemicolon = tt => {
|
||||
while (tt.length && tt[tt.length - 1][0] === ';') tt.pop();
|
||||
};
|
||||
for (const pass of opts.mode === 'stylus' ? [sugarss, !sugarss] : [-1]) {
|
||||
/* We try sugarss (for indented stylus-lang), then css mode, switching them on failure,
|
||||
* so that the succeeding syntax will be used next time first. */
|
||||
opts.config.customSyntax = !pass ? 'sugarss' : '';
|
||||
try {
|
||||
const res = await stylelint.createLinter(opts)._lintSource(opts);
|
||||
if (pass !== -1) sugarss = pass;
|
||||
return collectStylelintResults(res, opts);
|
||||
} catch (e) {
|
||||
const fatal = pass === -1 ||
|
||||
!pass && !/^CssSyntaxError:.+?Unnecessary curly bracket/.test(e) ||
|
||||
pass && !/^CssSyntaxError:.+?Unknown word[\s\S]*?\.decl\s/.test(`${e}${e.stack}`);
|
||||
if (fatal) {
|
||||
return [{
|
||||
from: {line: e.line - 1, ch: e.column - 1},
|
||||
to: {line: e.line - 1, ch: e.column - 1},
|
||||
message: e.reason,
|
||||
severity: 'error',
|
||||
rule: e.name,
|
||||
}];
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
const ruleRetriever = {
|
||||
|
||||
csslint() {
|
||||
require(['/js/csslint/csslint']);
|
||||
return CSSLint.getRuleList().map(rule => {
|
||||
const output = {};
|
||||
for (const [key, value] of Object.entries(rule)) {
|
||||
if (typeof value !== 'function') {
|
||||
output[key] = value;
|
||||
}
|
||||
}
|
||||
return output;
|
||||
});
|
||||
},
|
||||
|
||||
stylelint() {
|
||||
require(['/vendor/stylelint-bundle/stylelint-bundle.min']);
|
||||
const options = {};
|
||||
const rxPossible = /\bpossible:("(?:[^"]*?)"|\[(?:[^\]]*?)\]|\{(?:[^}]*?)\})/g;
|
||||
const rxString = /"([-\w\s]{3,}?)"/g;
|
||||
for (const [id, rule] of Object.entries(stylelint.rules)) {
|
||||
const ruleCode = `${rule()}`;
|
||||
const sets = [];
|
||||
let m, mStr;
|
||||
while ((m = rxPossible.exec(ruleCode))) {
|
||||
const possible = m[1];
|
||||
const set = [];
|
||||
while ((mStr = rxString.exec(possible))) {
|
||||
const s = mStr[1];
|
||||
if (s.includes(' ')) {
|
||||
set.push(...s.split(/\s+/));
|
||||
} else {
|
||||
set.push(s);
|
||||
}
|
||||
}
|
||||
if (possible.includes('ignoreAtRules')) {
|
||||
set.push('ignoreAtRules');
|
||||
}
|
||||
if (possible.includes('ignoreShorthands')) {
|
||||
set.push('ignoreShorthands');
|
||||
}
|
||||
if (set.length) {
|
||||
sets.push(set);
|
||||
}
|
||||
}
|
||||
options[id] = sets;
|
||||
}
|
||||
return options;
|
||||
},
|
||||
};
|
||||
|
||||
function collectStylelintResults({messages}, {mode}) {
|
||||
/* We hide nonfatal "//" warnings since we lint with sugarss without applying @preprocessor.
|
||||
* We can't easily pre-remove "//" comments which may be inside strings, comments, url(), etc.
|
||||
* And even if we did, it'd be wrong to hide potential bugs in stylus-lang like #1460 */
|
||||
const isLess = mode === 'text/x-less';
|
||||
const slashCommentAllowed = isLess || mode === 'stylus';
|
||||
const res = [];
|
||||
for (const m of messages) {
|
||||
if (/deprecation|invalidOption/.test(m.stylelintType)) {
|
||||
continue;
|
||||
}
|
||||
const {rule} = m;
|
||||
const msg = m.text.replace(/^Unexpected\s+/, '').replace(` (${rule})`, '');
|
||||
if (slashCommentAllowed && msg.includes('"//"') ||
|
||||
isLess && /^unknown at-rule "@[-\w]+:"/.test(msg) /* LESS variables */) {
|
||||
continue;
|
||||
}
|
||||
res.push({
|
||||
from: {line: m.line - 1, ch: m.column - 1},
|
||||
to: {line: m.endLine - 1, ch: m.endColumn - 1},
|
||||
message: msg[0].toUpperCase() + msg.slice(1),
|
||||
severity: m.severity,
|
||||
rule,
|
||||
});
|
||||
}
|
||||
return res;
|
||||
}
|
||||
})();
|
109
edit/embedded-popup.js
Normal file
109
edit/embedded-popup.js
Normal file
|
@ -0,0 +1,109 @@
|
|||
/* global $ $create $remove getEventKeyName */// dom.js
|
||||
/* global CodeMirror */
|
||||
/* global prefs */
|
||||
/* global t */// localization.js
|
||||
'use strict';
|
||||
|
||||
(() => {
|
||||
const ID = 'popup-iframe';
|
||||
const SEL = '#' + ID;
|
||||
const URL = chrome.runtime.getManifest().browser_action.default_popup;
|
||||
const POPUP_HOTKEY = 'Shift-Ctrl-Alt-S';
|
||||
/** @type {HTMLIFrameElement} */
|
||||
let frame;
|
||||
let isLoaded;
|
||||
let scrollbarWidth;
|
||||
|
||||
const btn = $create('img', {
|
||||
id: 'popup-button',
|
||||
title: t('optionsCustomizePopup') + '\n' + POPUP_HOTKEY,
|
||||
onclick: embedPopup,
|
||||
});
|
||||
$.root.appendChild(btn);
|
||||
$.rootCL.add('popup-window');
|
||||
window.on('domReady', () => {
|
||||
document.body.appendChild(btn);
|
||||
// Adding a dummy command to show in keymap help popup
|
||||
CodeMirror.defaults.extraKeys[POPUP_HOTKEY] = 'openStylusPopup';
|
||||
}, {once: true});
|
||||
|
||||
prefs.subscribe('iconset', (_, val) => {
|
||||
const prefix = `images/icon/${val ? 'light/' : ''}`;
|
||||
btn.srcset = `${prefix}16.png 1x,${prefix}32.png 2x`;
|
||||
}, {runNow: true});
|
||||
|
||||
window.on('keydown', e => {
|
||||
if (getEventKeyName(e) === POPUP_HOTKEY) {
|
||||
embedPopup();
|
||||
}
|
||||
});
|
||||
|
||||
function embedPopup() {
|
||||
if ($(SEL)) return;
|
||||
isLoaded = false;
|
||||
scrollbarWidth = 0;
|
||||
frame = $create('iframe', {
|
||||
id: ID,
|
||||
src: URL,
|
||||
height: 600,
|
||||
width: prefs.get('popupWidth'),
|
||||
onload: initFrame,
|
||||
});
|
||||
window.on('mousedown', removePopup);
|
||||
document.body.appendChild(frame);
|
||||
}
|
||||
|
||||
function initFrame() {
|
||||
frame = this;
|
||||
frame.focus();
|
||||
const pw = frame.contentWindow;
|
||||
const body = pw.document.body;
|
||||
pw.on('keydown', removePopupOnEsc);
|
||||
pw.close = removePopup;
|
||||
new pw.IntersectionObserver(onIntersect).observe(body.appendChild(
|
||||
$create('div', {style: {height: '1px', marginTop: '-1px'}})
|
||||
));
|
||||
new pw.MutationObserver(onMutation).observe(body, {
|
||||
attributes: true,
|
||||
attributeFilter: ['style'],
|
||||
});
|
||||
}
|
||||
|
||||
function onMutation() {
|
||||
const body = frame.contentDocument.body;
|
||||
const bs = body.style;
|
||||
const w = parseFloat(bs.minWidth || bs.width) + (scrollbarWidth || 0);
|
||||
const h = parseFloat(bs.minHeight || body.offsetHeight);
|
||||
if (frame.width - w) frame.width = w;
|
||||
if (frame.height - h) frame.height = h;
|
||||
}
|
||||
|
||||
function onIntersect([e]) {
|
||||
const pw = frame.contentWindow;
|
||||
const el = pw.document.scrollingElement;
|
||||
const h = e.isIntersecting && !pw.scrollY ? el.offsetHeight : el.scrollHeight;
|
||||
const hasSB = h > el.offsetHeight;
|
||||
const {width} = e.boundingClientRect;
|
||||
frame.height = h;
|
||||
if (!hasSB !== !scrollbarWidth || frame.width - width) {
|
||||
scrollbarWidth = hasSB ? width - el.offsetWidth : 0;
|
||||
frame.width = width + scrollbarWidth;
|
||||
}
|
||||
if (!isLoaded) {
|
||||
isLoaded = true;
|
||||
frame.dataset.loaded = '';
|
||||
}
|
||||
}
|
||||
|
||||
function removePopup() {
|
||||
frame = null;
|
||||
$remove(SEL);
|
||||
window.off('mousedown', removePopup);
|
||||
}
|
||||
|
||||
function removePopupOnEsc(e) {
|
||||
if (getEventKeyName(e) === 'Escape') {
|
||||
removePopup();
|
||||
}
|
||||
}
|
||||
})();
|
247
edit/global-search.css
Normal file
247
edit/global-search.css
Normal file
|
@ -0,0 +1,247 @@
|
|||
#search-replace-dialog {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
right: 64px;
|
||||
min-width: 200px;
|
||||
max-width: calc(100vw - 4rem);
|
||||
box-sizing: border-box;
|
||||
z-index: 10000;
|
||||
background-color: white;
|
||||
box-shadow: 4px 5px 20px -6px rgba(0, 0, 0, .5);
|
||||
border: 1px solid hsla(0, 0%, 50%, .4);
|
||||
transition: opacity .25s;
|
||||
border-top: none;
|
||||
}
|
||||
|
||||
#search-replace-dialog:not(:focus-within):not(:hover) {
|
||||
opacity: .5;
|
||||
}
|
||||
|
||||
#search-replace-dialog > * {
|
||||
padding-right: .75em;
|
||||
display: flex;
|
||||
align-items: stretch;
|
||||
background-color: hsla(0, 0%, 50%, .1);
|
||||
}
|
||||
|
||||
#search-replace-dialog [data-type="content"] {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
#search-replace-dialog [data-type="content"] > :not(:last-child) {
|
||||
margin-right: .5rem;
|
||||
}
|
||||
|
||||
#search-replace-dialog [data-type="content"] button {
|
||||
align-self: center;
|
||||
}
|
||||
|
||||
#search-replace-dialog[data-type="replace"] button svg {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#search-replace-dialog [data-type="input-wrapper"] {
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
#search-replace-dialog textarea {
|
||||
resize: none;
|
||||
width: min-content;
|
||||
min-width: 10em;
|
||||
max-width: none;
|
||||
min-height: 1.3em;
|
||||
max-height: 10vh;
|
||||
line-height: 1.3em;
|
||||
padding: .25rem .25rem .25rem .5rem;
|
||||
margin: 0;
|
||||
border: none;
|
||||
background-color: white;
|
||||
font-weight: bold;
|
||||
white-space: pre; /* issue #1000 */
|
||||
color: currentColor; /* use the current theme's color instead of UserAgent's CSS */
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
#search-replace-dialog textarea:invalid {
|
||||
box-shadow: none; /* Firefox is weird */
|
||||
}
|
||||
|
||||
#search-replace-dialog :disabled {
|
||||
opacity: .5;
|
||||
}
|
||||
|
||||
/*********** actions ****************/
|
||||
|
||||
#search-replace-dialog [data-type="actions"] {
|
||||
flex: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding-left: .5em;
|
||||
opacity: .5;
|
||||
transition: opacity .25s;
|
||||
}
|
||||
|
||||
#search-replace-dialog:focus-within [data-type="actions"],
|
||||
#search-replace-dialog [data-type="actions"]:hover {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
#search-replace-dialog [data-action] {
|
||||
display: block;
|
||||
padding: 2px .5em;
|
||||
}
|
||||
|
||||
#search-replace-dialog [data-type="actions"] a:last-child {
|
||||
margin-right: -.5em;
|
||||
}
|
||||
|
||||
/*********** case-sensitivity ****************/
|
||||
|
||||
#search-replace-dialog [data-action="case"] {
|
||||
text-decoration: none;
|
||||
font-weight: bold;
|
||||
color: currentColor;
|
||||
cursor: pointer;
|
||||
padding: 0 .5em;
|
||||
line-height: 20px;
|
||||
display: block;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
#search-replace-dialog [data-action="case"][data-enabled]:after {
|
||||
content: "";
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
position: absolute;
|
||||
border-color: hsla(180, 100%, 30%, .5);
|
||||
border-style: none none solid none;
|
||||
border-width: 4px;
|
||||
}
|
||||
|
||||
#search-replace-dialog [data-action="case"]:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
/*********** clear input ****************/
|
||||
|
||||
#search-replace-dialog textarea:not(:valid) + [data-type="hover"] {
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
#search-replace-dialog [data-type="hover"] {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 4px;
|
||||
bottom: 0;
|
||||
margin: 0;
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
transition: opacity .5s;
|
||||
}
|
||||
|
||||
#search-replace-dialog:hover [data-type="hover"] {
|
||||
opacity: 1;
|
||||
pointer-events: auto;
|
||||
}
|
||||
|
||||
#search-replace-dialog [data-action="clear"] {
|
||||
padding: 3px;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
box-sizing: border-box;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background-color: hsla(0, 0%, 100%, .75);
|
||||
}
|
||||
|
||||
#search-replace-dialog [data-type="status"] {
|
||||
background-color: hsla(0, 0%, 50%, .2);
|
||||
padding-top: 2px;
|
||||
padding-left: .5rem;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
#search-replace-dialog [data-type="tally"] {
|
||||
opacity: .5;
|
||||
margin-left: 1em;
|
||||
}
|
||||
|
||||
#search-replace-dialog [data-type="tally"]:hover {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
/*********** CM search highlight restyling, which shouldn't need color variables ****************/
|
||||
body.find-open .search-target-editor {
|
||||
box-shadow: 0 0 0 1px hsl(33, 100%, 50%), 0 0 3px hsla(33, 100%, 50%, .4);
|
||||
/* same as our global.css focus rule */
|
||||
}
|
||||
|
||||
body.find-open .cm-searching {
|
||||
background-color: rgba(255, 255, 0, .4);
|
||||
}
|
||||
|
||||
body.find-open .cm-searching.search-target-match {
|
||||
background-color: darkorange;
|
||||
color: black;
|
||||
}
|
||||
|
||||
body.find-open .CodeMirror-search-match {
|
||||
background: gold;
|
||||
border-top: 1px solid orange;
|
||||
border-bottom: 1px solid orange;
|
||||
}
|
||||
|
||||
/* hide default CM search highlight styling */
|
||||
body .cm-searching,
|
||||
body .CodeMirror-search-match {
|
||||
background-color: transparent;
|
||||
border-color: transparent;
|
||||
}
|
||||
|
||||
@media (max-width: 500px) {
|
||||
#search-replace-dialog {
|
||||
left: 0;
|
||||
right: 0;
|
||||
max-width: none;
|
||||
}
|
||||
#search-replace-dialog textarea {
|
||||
min-width: 50px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 800px) {
|
||||
#search-replace-dialog[data-type="replace"] {
|
||||
left: 0;
|
||||
right: 0;
|
||||
max-width: none;
|
||||
}
|
||||
#search-replace-dialog[data-type="replace"] button:not(.hidden) {
|
||||
display: none !important;
|
||||
}
|
||||
#search-replace-dialog[data-type="replace"] button.hidden {
|
||||
display: block !important;
|
||||
font-size: 0;
|
||||
width: 24px;
|
||||
text-align: center;
|
||||
cursor: pointer;
|
||||
}
|
||||
#search-replace-dialog[data-type="replace"] button svg {
|
||||
display: inline;
|
||||
}
|
||||
#search-replace-dialog[data-type="replace"] textarea {
|
||||
min-width: 50px;
|
||||
max-width: calc(50vw - 120px);
|
||||
width: auto;
|
||||
}
|
||||
}
|
934
edit/global-search.js
Normal file
934
edit/global-search.js
Normal file
|
@ -0,0 +1,934 @@
|
|||
/* global $ $$ $create $remove focusAccessibility setInputValue toggleDataset */// dom.js
|
||||
/* global CodeMirror */
|
||||
/* global chromeLocal */// storage-util.js
|
||||
/* global colorMimicry */
|
||||
/* global debounce stringAsRegExp tryRegExp */// toolbox.js
|
||||
/* global editor */
|
||||
/* global t */// localization.js
|
||||
'use strict';
|
||||
|
||||
(() => {
|
||||
require(['/edit/global-search.css']);
|
||||
|
||||
//region Constants and state
|
||||
|
||||
const INCREMENTAL_SEARCH_DELAY = 0;
|
||||
const ANNOTATE_SCROLLBAR_DELAY = 350;
|
||||
const ANNOTATE_SCROLLBAR_OPTIONS = {maxMatches: 10e3};
|
||||
const STORAGE_UPDATE_DELAY = 500;
|
||||
|
||||
const DIALOG_SELECTOR = '#search-replace-dialog';
|
||||
const DIALOG_STYLE_SELECTOR = '#search-replace-dialog-style';
|
||||
const TARGET_CLASS = 'search-target-editor';
|
||||
const MATCH_CLASS = 'search-target-match';
|
||||
const MATCH_TOKEN_NAME = 'searching';
|
||||
const APPLIES_VALUE_CLASS = 'applies-value';
|
||||
|
||||
const RX_MAYBE_REGEXP = /^\s*\/(.+?)\/([simguy]*)\s*$/;
|
||||
|
||||
const state = {
|
||||
firstRun: true,
|
||||
// used for case-sensitive matching directly
|
||||
find: '',
|
||||
// used when /re/ is detected or for case-insensitive matching
|
||||
rx: null,
|
||||
// used by overlay and doSearchInApplies, equals to rx || stringAsRegExp(find)
|
||||
rx2: null,
|
||||
|
||||
icase: true,
|
||||
reverse: false,
|
||||
lastFind: '',
|
||||
|
||||
numFound: 0,
|
||||
numApplies: -1,
|
||||
|
||||
replace: '',
|
||||
lastReplace: null,
|
||||
|
||||
cm: null,
|
||||
input: null,
|
||||
input2: null,
|
||||
dialog: null,
|
||||
tally: null,
|
||||
originalFocus: null,
|
||||
|
||||
undoHistory: [],
|
||||
|
||||
searchInApplies: !editor.isUsercss,
|
||||
};
|
||||
|
||||
//endregion
|
||||
//region Events
|
||||
|
||||
const ACTIONS = {
|
||||
key: {
|
||||
'Enter': event => {
|
||||
switch (document.activeElement) {
|
||||
case state.input:
|
||||
if (state.dialog.dataset.type === 'find') {
|
||||
const found = doSearch({canAdvance: false});
|
||||
if (found) {
|
||||
const target = $('.' + TARGET_CLASS);
|
||||
const cm = target.CodeMirror;
|
||||
/* Since this runs in `keydown` event we have to delay focusing
|
||||
* to prevent CodeMirror from seeing and handling the key */
|
||||
setTimeout(() => (cm || target).focus());
|
||||
if (cm) {
|
||||
const {from, to} = cm.state.search.searchPos;
|
||||
cm.jumpToPos(from, to);
|
||||
}
|
||||
}
|
||||
destroyDialog({restoreFocus: !found});
|
||||
return;
|
||||
}
|
||||
// fallthrough
|
||||
case state.input2:
|
||||
doReplace();
|
||||
return;
|
||||
}
|
||||
return !focusAccessibility.closest(event.target);
|
||||
},
|
||||
'Esc': () => {
|
||||
destroyDialog({restoreFocus: true});
|
||||
},
|
||||
},
|
||||
click: {
|
||||
next: () => doSearch({reverse: false}),
|
||||
prev: () => doSearch({reverse: true}),
|
||||
close: () => destroyDialog({restoreFocus: true}),
|
||||
replace: () => doReplace(),
|
||||
replaceAll: () => doReplaceAll(),
|
||||
undo: () => doUndo(),
|
||||
clear() {
|
||||
setInputValue(this._input, '');
|
||||
},
|
||||
case() {
|
||||
state.icase = !state.icase;
|
||||
state.lastFind = '';
|
||||
toggleDataset(this, 'enabled', !state.icase);
|
||||
doSearch({canAdvance: false});
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const EVENTS = {
|
||||
oninput() {
|
||||
state.find = state.input.value;
|
||||
debounce(doSearch, INCREMENTAL_SEARCH_DELAY, {canAdvance: false});
|
||||
adjustTextareaSize(this);
|
||||
if (!state.find) enableReplaceButtons(false);
|
||||
},
|
||||
onkeydown(event) {
|
||||
const action = ACTIONS.key[CodeMirror.keyName(event)];
|
||||
if (action && action(event) !== false) {
|
||||
event.preventDefault();
|
||||
}
|
||||
},
|
||||
onclick(event) {
|
||||
const el = event.target.closest('[data-action]');
|
||||
const action = el && ACTIONS.click[el.dataset.action];
|
||||
if (action && action.call(el, event) !== false) {
|
||||
event.preventDefault();
|
||||
}
|
||||
},
|
||||
onfocusout() {
|
||||
if (!state.dialog.contains(document.activeElement)) {
|
||||
state.dialog.on('focusin', EVENTS.onfocusin);
|
||||
state.dialog.off('focusout', EVENTS.onfocusout);
|
||||
}
|
||||
},
|
||||
onfocusin() {
|
||||
state.dialog.on('focusout', EVENTS.onfocusout);
|
||||
state.dialog.off('focusin', EVENTS.onfocusin);
|
||||
trimUndoHistory();
|
||||
enableUndoButton(state.undoHistory.length);
|
||||
if (state.find) doSearch({canAdvance: false});
|
||||
},
|
||||
};
|
||||
|
||||
const DIALOG_PROPS = {
|
||||
dialog: {
|
||||
onclick: EVENTS.onclick,
|
||||
onkeydown: EVENTS.onkeydown,
|
||||
},
|
||||
input: {
|
||||
oninput: EVENTS.oninput,
|
||||
},
|
||||
input2: {
|
||||
oninput() {
|
||||
state.replace = this.value;
|
||||
adjustTextareaSize(this);
|
||||
debounce(writeStorage, STORAGE_UPDATE_DELAY);
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
//endregion
|
||||
//region Commands
|
||||
|
||||
const COMMANDS = {
|
||||
find(cm, {reverse = false} = {}) {
|
||||
state.reverse = reverse;
|
||||
focusDialog('find', cm);
|
||||
},
|
||||
findNext: cm => doSearch({reverse: false, cm}),
|
||||
findPrev: cm => doSearch({reverse: true, cm}),
|
||||
replace(cm) {
|
||||
state.reverse = false;
|
||||
focusDialog('replace', cm);
|
||||
},
|
||||
};
|
||||
COMMANDS.replaceAll = COMMANDS.replace;
|
||||
|
||||
//endregion
|
||||
|
||||
Object.assign(CodeMirror.commands, COMMANDS);
|
||||
readStorage();
|
||||
|
||||
//region Find
|
||||
|
||||
function initState({initReplace} = {}) {
|
||||
const text = state.find;
|
||||
const textChanged = text !== state.lastFind;
|
||||
if (textChanged) {
|
||||
state.numFound = 0;
|
||||
state.numApplies = -1;
|
||||
state.lastFind = text;
|
||||
const match = text && text.match(RX_MAYBE_REGEXP);
|
||||
const unicodeFlag = 'unicode' in RegExp.prototype ? 'u' : '';
|
||||
const string2regexpFlags = (state.icase ? 'gi' : 'g') + unicodeFlag;
|
||||
state.rx = match && tryRegExp(match[1], 'g' + match[2].replace(/[guy]/g, '') + unicodeFlag) ||
|
||||
text && (state.icase || text.includes('\n')) && stringAsRegExp(text, string2regexpFlags);
|
||||
state.rx2 = state.rx || text && stringAsRegExp(text, string2regexpFlags);
|
||||
state.cursorOptions = {
|
||||
caseFold: !state.rx && state.icase,
|
||||
multiline: true,
|
||||
};
|
||||
debounce(writeStorage, STORAGE_UPDATE_DELAY);
|
||||
}
|
||||
if (initReplace && state.replace !== state.lastReplace) {
|
||||
state.lastReplace = state.replace;
|
||||
state.replaceValue = state.replace.replace(/(\\r)?\\n/g, '\n').replace(/\\t/g, '\t');
|
||||
state.replaceHasRefs = /\$[$&`'\d]/.test(state.replaceValue);
|
||||
}
|
||||
const cmFocused = document.activeElement && document.activeElement.closest('.CodeMirror');
|
||||
state.activeAppliesTo = $(`.${APPLIES_VALUE_CLASS}:focus, .${APPLIES_VALUE_CLASS}.${TARGET_CLASS}`);
|
||||
state.cmStart = editor.closestVisible(
|
||||
cmFocused && document.activeElement ||
|
||||
state.activeAppliesTo ||
|
||||
state.cm);
|
||||
const cmExtra = $('body > :not(#sections) .CodeMirror');
|
||||
state.editors = cmExtra ? [cmExtra.CodeMirror] : editor.getEditors();
|
||||
}
|
||||
|
||||
|
||||
function doSearch({
|
||||
reverse = state.reverse,
|
||||
canAdvance = true,
|
||||
inApplies = true,
|
||||
cm,
|
||||
} = {}) {
|
||||
if (cm) setActiveEditor(cm);
|
||||
state.reverse = reverse;
|
||||
if (!state.find && !dialogShown()) {
|
||||
focusDialog('find', state.cm);
|
||||
return;
|
||||
}
|
||||
initState();
|
||||
const {cmStart} = state;
|
||||
const {index, found, foundInCode} = state.find && doSearchInEditors({cmStart, canAdvance, inApplies}) || {};
|
||||
if (!foundInCode) clearMarker();
|
||||
if (!found) makeTargetVisible(null);
|
||||
const radiateFrom = foundInCode ? index : state.editors.indexOf(cmStart);
|
||||
setupOverlay(radiateArray(state.editors, radiateFrom));
|
||||
enableReplaceButtons(foundInCode);
|
||||
if (state.find) {
|
||||
const firstSuccessfulSearch = foundInCode && !state.numFound;
|
||||
debounce(showTally, 0, firstSuccessfulSearch ? 1 : undefined);
|
||||
} else {
|
||||
showTally(0, 0);
|
||||
}
|
||||
state.firstRun = false;
|
||||
return found;
|
||||
}
|
||||
|
||||
|
||||
function doSearchInEditors({cmStart, canAdvance, inApplies}) {
|
||||
const query = state.rx || state.find;
|
||||
const reverse = state.reverse;
|
||||
const BOF = {line: 0, ch: 0};
|
||||
const EOF = getEOF(cmStart);
|
||||
|
||||
const start = state.editors.indexOf(cmStart);
|
||||
const total = state.editors.length;
|
||||
let i = 0;
|
||||
let wrapAround = 0;
|
||||
let pos, index, cm;
|
||||
|
||||
if (inApplies && state.activeAppliesTo) {
|
||||
if (doSearchInApplies(state.cmStart, canAdvance)) {
|
||||
return {found: true};
|
||||
}
|
||||
if (reverse) pos = EOF; else i++;
|
||||
} else {
|
||||
pos = getContinuationPos({cm: cmStart, reverse: !canAdvance || reverse});
|
||||
wrapAround = !reverse ?
|
||||
CodeMirror.cmpPos(pos, BOF) > 0 :
|
||||
CodeMirror.cmpPos(pos, EOF) < 0;
|
||||
}
|
||||
|
||||
for (; i < total + wrapAround; i++) {
|
||||
index = (start + i * (reverse ? -1 : 1) + total) % total;
|
||||
cm = state.editors[index];
|
||||
if (i) {
|
||||
pos = !reverse ? BOF : {line: cm.doc.size, ch: 0};
|
||||
}
|
||||
const cursor = cm.getSearchCursor(query, pos, state.cursorOptions);
|
||||
if (cursor.find(reverse)) {
|
||||
makeMatchVisible(cm, cursor);
|
||||
return {found: true, foundInCode: true, index};
|
||||
}
|
||||
const cmForNextApplies = !reverse ? cm : state.editors[index ? index - 1 : total - 1];
|
||||
if (inApplies && doSearchInApplies(cmForNextApplies)) {
|
||||
return {found: true};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function doSearchInApplies(cm, canAdvance) {
|
||||
if (!state.searchInApplies) return;
|
||||
const inputs = editor.getSearchableInputs(cm);
|
||||
if (state.reverse) inputs.reverse();
|
||||
inputs.splice(0, inputs.indexOf(state.activeAppliesTo));
|
||||
for (const input of inputs) {
|
||||
const value = input.value;
|
||||
if (input === state.activeAppliesTo) {
|
||||
state.rx2.lastIndex = input.selectionStart + canAdvance;
|
||||
} else {
|
||||
state.rx2.lastIndex = 0;
|
||||
}
|
||||
const match = state.rx2.exec(value);
|
||||
if (!match) {
|
||||
continue;
|
||||
}
|
||||
const end = match.index + match[0].length;
|
||||
// scroll selected part into view in long inputs,
|
||||
// works only outside of current event handlers chain, hence timeout=0
|
||||
setTimeout(() => {
|
||||
input.setSelectionRange(end, end);
|
||||
input.setSelectionRange(match.index, end);
|
||||
});
|
||||
const canFocus = !state.dialog || !state.dialog.contains(document.activeElement);
|
||||
makeTargetVisible(!canFocus && input);
|
||||
editor.scrollToEditor(cm);
|
||||
if (canFocus) input.focus();
|
||||
state.cm = cm;
|
||||
clearMarker();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
//endregion
|
||||
//region Replace
|
||||
|
||||
function doReplace() {
|
||||
initState({initReplace: true});
|
||||
const cm = state.cmStart;
|
||||
const generation = cm.changeGeneration();
|
||||
const pos = getContinuationPos({cm, reverse: true});
|
||||
const cursor = doReplaceInEditor({cm, pos});
|
||||
if (!cursor) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (cursor.findNext()) {
|
||||
clearMarker();
|
||||
makeMatchVisible(cm, cursor);
|
||||
} else {
|
||||
doSearchInEditors({cmStart: getNextEditor(cm)});
|
||||
}
|
||||
|
||||
getStateSafe(cm).unclosedOp = false;
|
||||
if (cm.curOp) cm.endOperation();
|
||||
|
||||
if (cursor) {
|
||||
state.undoHistory.push([[cm, generation]]);
|
||||
enableUndoButton(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function doReplaceAll() {
|
||||
initState({initReplace: true});
|
||||
clearMarker();
|
||||
const generations = new Map(state.editors.map(cm => [cm, cm.changeGeneration()]));
|
||||
const found = state.editors.filter(cm => doReplaceInEditor({cm, all: true}));
|
||||
if (found.length) {
|
||||
state.lastFind = null;
|
||||
state.undoHistory.push(found.map(cm => [cm, generations.get(cm)]));
|
||||
enableUndoButton(true);
|
||||
doSearch({canAdvance: false});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function doReplaceInEditor({cm, pos, all = false}) {
|
||||
const cursor = cm.getSearchCursor(state.rx || state.find, pos, state.cursorOptions);
|
||||
const replace = state.replaceValue;
|
||||
let found;
|
||||
|
||||
cursor.find();
|
||||
while (cursor.atOccurrence) {
|
||||
found = true;
|
||||
if (!cm.curOp) {
|
||||
cm.startOperation();
|
||||
getStateSafe(cm).unclosedOp = true;
|
||||
}
|
||||
if (state.rx) {
|
||||
const text = cm.getRange(cursor.pos.from, cursor.pos.to);
|
||||
cursor.replace(state.replaceHasRefs ? text.replace(state.rx, replace) : replace);
|
||||
} else {
|
||||
cursor.replace(replace);
|
||||
}
|
||||
if (!all) {
|
||||
makeMatchVisible(cm, cursor);
|
||||
return cursor;
|
||||
}
|
||||
cursor.findNext();
|
||||
}
|
||||
if (all) {
|
||||
getStateSafe(cm).searchPos = null;
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
|
||||
function doUndo() {
|
||||
let undoneSome;
|
||||
saveWindowScrollPos();
|
||||
for (const [cm, generation] of state.undoHistory.pop() || []) {
|
||||
if (document.body.contains(cm.display.wrapper) && !cm.isClean(generation)) {
|
||||
cm.undo();
|
||||
cm.getAllMarks().forEach(marker =>
|
||||
marker !== state.marker &&
|
||||
marker.className === MATCH_CLASS &&
|
||||
marker.clear());
|
||||
undoneSome = true;
|
||||
}
|
||||
}
|
||||
enableUndoButton(state.undoHistory.length);
|
||||
if (state.undoHistory.length) {
|
||||
focusUndoButton();
|
||||
} else {
|
||||
state.input.focus();
|
||||
}
|
||||
if (undoneSome) {
|
||||
state.lastFind = null;
|
||||
restoreWindowScrollPos();
|
||||
doSearch({
|
||||
reverse: false,
|
||||
canAdvance: false,
|
||||
inApplies: false,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
//endregion
|
||||
//region Overlay
|
||||
|
||||
|
||||
function setupOverlay(queue, debounced) {
|
||||
if (!queue.length) {
|
||||
return;
|
||||
}
|
||||
if (queue.length > 1 || !debounced) {
|
||||
debounce(setupOverlay, 0, queue, true);
|
||||
if (!debounced) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
let canContinue = true;
|
||||
while (queue.length && canContinue) {
|
||||
const cm = queue.shift();
|
||||
if (!document.body.contains(cm.display.wrapper)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const cmState = getStateSafe(cm);
|
||||
const query = state.rx2;
|
||||
|
||||
if ((cmState.overlay || {}).query === query) {
|
||||
if (cmState.unclosedOp && cm.curOp) cm.endOperation();
|
||||
cmState.unclosedOp = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (cmState.overlay) {
|
||||
if (!cm.curOp) cm.startOperation();
|
||||
cm.removeOverlay(cmState.overlay);
|
||||
cmState.overlay = null;
|
||||
canContinue = false;
|
||||
}
|
||||
|
||||
const hasMatches = query && cm.getSearchCursor(query, null, state.cursorOptions).find();
|
||||
if (hasMatches) {
|
||||
if (!cm.curOp) cm.startOperation();
|
||||
cmState.overlay = {
|
||||
query,
|
||||
token: tokenize,
|
||||
numFound: 0,
|
||||
tallyShownTime: 0,
|
||||
};
|
||||
cm.addOverlay(cmState.overlay);
|
||||
canContinue = false;
|
||||
}
|
||||
|
||||
if (cmState.annotate) {
|
||||
if (!cm.curOp) cm.startOperation();
|
||||
cmState.annotate.clear();
|
||||
cmState.annotate = null;
|
||||
canContinue = false;
|
||||
}
|
||||
if (cmState.annotateTimer) {
|
||||
clearTimeout(cmState.annotateTimer);
|
||||
cmState.annotateTimer = 0;
|
||||
}
|
||||
if (hasMatches) {
|
||||
cmState.annotateTimer = setTimeout(annotateScrollbar, ANNOTATE_SCROLLBAR_DELAY,
|
||||
cm, query, state.icase);
|
||||
}
|
||||
|
||||
cmState.unclosedOp = false;
|
||||
if (cm.curOp) cm.endOperation();
|
||||
}
|
||||
|
||||
if (!queue.length) debounce.unregister(setupOverlay);
|
||||
}
|
||||
|
||||
|
||||
function tokenize(stream) {
|
||||
this.query.lastIndex = stream.pos;
|
||||
const match = this.query.exec(stream.string);
|
||||
if (match && match.index === stream.pos) {
|
||||
this.numFound++;
|
||||
const t = performance.now();
|
||||
if (t - this.tallyShownTime > 10) {
|
||||
this.tallyShownTime = t;
|
||||
debounce(showTally);
|
||||
}
|
||||
stream.pos += match[0].length || 1;
|
||||
return MATCH_TOKEN_NAME;
|
||||
} else if (match) {
|
||||
stream.pos = match.index;
|
||||
} else {
|
||||
stream.skipToEnd();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function annotateScrollbar(cm, query, icase) {
|
||||
getStateSafe(cm).annotate = cm.showMatchesOnScrollbar(query, icase, ANNOTATE_SCROLLBAR_OPTIONS);
|
||||
debounce(showTally);
|
||||
}
|
||||
|
||||
//endregion
|
||||
//region Dialog
|
||||
|
||||
function focusDialog(type, cm) {
|
||||
setActiveEditor(cm);
|
||||
|
||||
const dialogFocused = state.dialog && state.dialog.contains(document.activeElement);
|
||||
let sel = dialogFocused ? '' : getSelection().toString() || cm && cm.getSelection();
|
||||
sel = !sel.includes('\n') && !sel.includes('\r') && sel;
|
||||
if (sel) state.find = sel;
|
||||
|
||||
if (!dialogShown(type)) {
|
||||
destroyDialog();
|
||||
createDialog(type);
|
||||
} else if (sel) {
|
||||
setInputValue(state.input, sel);
|
||||
}
|
||||
|
||||
state.input.focus();
|
||||
state.input.select();
|
||||
if (state.find) {
|
||||
doSearch({canAdvance: false});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function dialogShown(type) {
|
||||
return document.body.contains(state.input) &&
|
||||
(!type || state.dialog.dataset.type === type);
|
||||
}
|
||||
|
||||
|
||||
function createDialog(type) {
|
||||
state.originalFocus = document.activeElement;
|
||||
state.firstRun = true;
|
||||
|
||||
const dialog = state.dialog = t.template.searchReplaceDialog.cloneNode(true);
|
||||
Object.assign(dialog, DIALOG_PROPS.dialog);
|
||||
dialog.on('focusout', EVENTS.onfocusout);
|
||||
dialog.dataset.type = type;
|
||||
dialog.style.pointerEvents = 'auto';
|
||||
|
||||
const content = $('[data-type="content"]', dialog);
|
||||
content.parentNode.replaceChild(t.template[type].cloneNode(true), content);
|
||||
|
||||
createInput(0, 'input', state.find);
|
||||
createInput(1, 'input2', state.replace);
|
||||
toggleDataset($('[data-action="case"]', dialog), 'enabled', !state.icase);
|
||||
state.tally = $('[data-type="tally"]', dialog);
|
||||
|
||||
const colors = {
|
||||
body: colorMimicry(document.body, {bg: 'backgroundColor'}),
|
||||
input: colorMimicry($('input:not(:disabled)'), {bg: 'backgroundColor'}),
|
||||
icon: colorMimicry($$('svg.info')[1], {fill: 'fill'}),
|
||||
};
|
||||
$.root.appendChild(
|
||||
$(DIALOG_STYLE_SELECTOR) ||
|
||||
$create('style' + DIALOG_STYLE_SELECTOR)
|
||||
).textContent = `
|
||||
#search-replace-dialog {
|
||||
background-color: ${colors.body.bg};
|
||||
}
|
||||
#search-replace-dialog textarea {
|
||||
color: ${colors.body.fore};
|
||||
background-color: ${colors.input.bg};
|
||||
}
|
||||
#search-replace-dialog svg {
|
||||
fill: ${colors.icon.fill};
|
||||
}
|
||||
#search-replace-dialog [data-action="case"] {
|
||||
color: ${colors.icon.fill};
|
||||
}
|
||||
#search-replace-dialog[data-type="replace"] button:hover svg,
|
||||
#search-replace-dialog svg:hover {
|
||||
fill: var(--cmin);
|
||||
}
|
||||
#search-replace-dialog [data-action="case"]:hover {
|
||||
color: var(--cmin);
|
||||
}
|
||||
#search-replace-dialog [data-action="clear"] {
|
||||
background-color: ${colors.input.bg.replace(/[^,]+$/, '') + '.75)'};
|
||||
}
|
||||
`;
|
||||
|
||||
document.body.appendChild(dialog);
|
||||
dispatchEvent(new Event('showHotkeyInTooltip'));
|
||||
|
||||
adjustTextareaSize(state.input);
|
||||
if (type === 'replace') {
|
||||
adjustTextareaSize(state.input2);
|
||||
enableReplaceButtons(state.find !== '');
|
||||
enableUndoButton(state.undoHistory.length);
|
||||
}
|
||||
|
||||
return dialog;
|
||||
}
|
||||
|
||||
|
||||
function createInput(index, name, value) {
|
||||
const input = state[name] = $$('textarea', state.dialog)[index];
|
||||
if (!input) {
|
||||
return;
|
||||
}
|
||||
input.value = value;
|
||||
Object.assign(input, DIALOG_PROPS[name]);
|
||||
|
||||
input.parentElement.appendChild(t.template.clearSearch.cloneNode(true));
|
||||
$('[data-action]', input.parentElement)._input = input;
|
||||
}
|
||||
|
||||
|
||||
function destroyDialog({restoreFocus = false} = {}) {
|
||||
state.input = null;
|
||||
$remove(DIALOG_SELECTOR);
|
||||
debounce.unregister(doSearch);
|
||||
makeTargetVisible(null);
|
||||
if (restoreFocus) {
|
||||
setTimeout(focusNoScroll, 0, state.originalFocus);
|
||||
} else {
|
||||
saveWindowScrollPos();
|
||||
restoreWindowScrollPos({immediately: false});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function adjustTextareaSize(el) {
|
||||
const oldWidth = parseFloat(el.style.width) || el.clientWidth;
|
||||
const widthHistory = el._widthHistory = el._widthHistory || new Map();
|
||||
const knownWidth = widthHistory.get(el.value);
|
||||
let newWidth;
|
||||
if (knownWidth) {
|
||||
newWidth = knownWidth;
|
||||
} else {
|
||||
const hasVerticalScrollbar = el.scrollHeight > el.clientHeight;
|
||||
newWidth = el.scrollWidth + (hasVerticalScrollbar ? el.scrollWidth - el.clientWidth : 0);
|
||||
newWidth += newWidth > oldWidth ? 50 : 0;
|
||||
widthHistory.set(el.value, newWidth);
|
||||
}
|
||||
if (newWidth !== oldWidth) {
|
||||
const dialogRightOffset = parseFloat(getComputedStyle(state.dialog).right);
|
||||
const dialogRight = state.dialog.getBoundingClientRect().right;
|
||||
const textRight = (state.input2 || state.input).getBoundingClientRect().right;
|
||||
newWidth = Math.min(newWidth,
|
||||
(window.innerWidth - dialogRightOffset - (dialogRight - textRight)) / (state.input2 ? 2 : 1) - 20);
|
||||
el.style.width = newWidth + 'px';
|
||||
}
|
||||
const numLines = el.value.split('\n').length;
|
||||
if (numLines !== Number(el.rows)) {
|
||||
el.rows = numLines;
|
||||
}
|
||||
el.style.overflowX = el.scrollWidth > el.clientWidth ? '' : 'hidden';
|
||||
}
|
||||
|
||||
|
||||
function enableReplaceButtons(enabled) {
|
||||
if (state.dialog && state.dialog.dataset.type === 'replace') {
|
||||
for (const el of $$('[data-action^="replace"]', state.dialog)) {
|
||||
el.disabled = !enabled;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function enableUndoButton(enabled) {
|
||||
if (state.dialog && state.dialog.dataset.type === 'replace') {
|
||||
for (const el of $$('[data-action="undo"]', state.dialog)) {
|
||||
el.disabled = !enabled;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function focusUndoButton() {
|
||||
for (const btn of $$('[data-action="undo"]', state.dialog)) {
|
||||
if (getComputedStyle(btn).display !== 'none') {
|
||||
btn.focus();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//endregion
|
||||
//region Utility
|
||||
|
||||
function getStateSafe(cm) {
|
||||
return cm.state.search || (cm.state.search = {});
|
||||
}
|
||||
|
||||
|
||||
// determines search start position:
|
||||
// the cursor if it was moved or the last match
|
||||
function getContinuationPos({cm, reverse}) {
|
||||
const cmSearchState = getStateSafe(cm);
|
||||
const posType = reverse ? 'from' : 'to';
|
||||
const searchPos = (cmSearchState.searchPos || {})[posType];
|
||||
const cursorPos = cm.getCursor(posType);
|
||||
const preferCursor = !searchPos || CodeMirror.cmpPos(cursorPos, cmSearchState.cursorPos[posType]);
|
||||
return preferCursor ? cursorPos : searchPos;
|
||||
}
|
||||
|
||||
|
||||
function getEOF(cm) {
|
||||
const line = cm.doc.size - 1;
|
||||
return {line, ch: cm.getLine(line).length};
|
||||
}
|
||||
|
||||
|
||||
function getNextEditor(cm, step = 1) {
|
||||
const editors = state.editors;
|
||||
return editors[(editors.indexOf(cm) + step + editors.length) % editors.length];
|
||||
}
|
||||
|
||||
|
||||
// sets the editor to start the search in
|
||||
// e.g. when the user switched to another editor and invoked a search command
|
||||
function setActiveEditor(cm) {
|
||||
if (cm.display.wrapper.contains(document.activeElement)) {
|
||||
state.cm = cm;
|
||||
state.originalFocus = cm;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// adds a class on the editor that contains the active match
|
||||
// instead of focusing it (in order to keep the minidialog focused)
|
||||
function makeTargetVisible(element) {
|
||||
const old = $('.' + TARGET_CLASS);
|
||||
if (old !== element) {
|
||||
if (old) {
|
||||
old.classList.remove(TARGET_CLASS);
|
||||
document.body.classList.remove('find-open');
|
||||
}
|
||||
if (element) {
|
||||
element.classList.add(TARGET_CLASS);
|
||||
document.body.classList.add('find-open');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// scrolls the editor to reveal the match
|
||||
function makeMatchVisible(cm, searchCursor) {
|
||||
const canFocus = !state.firstRun && (!state.dialog || !state.dialog.contains(document.activeElement));
|
||||
state.cm = cm;
|
||||
// scroll within the editor
|
||||
const pos = searchCursor.pos;
|
||||
Object.assign(getStateSafe(cm), {
|
||||
cursorPos: {
|
||||
from: cm.getCursor('from'),
|
||||
to: cm.getCursor('to'),
|
||||
},
|
||||
searchPos: pos,
|
||||
unclosedOp: !cm.curOp,
|
||||
});
|
||||
if (!cm.curOp) cm.startOperation();
|
||||
if (!state.firstRun) {
|
||||
cm.jumpToPos(pos.from, pos.to);
|
||||
}
|
||||
// focus or expose as the current search target
|
||||
clearMarker();
|
||||
if (canFocus) {
|
||||
cm.focus();
|
||||
makeTargetVisible(null);
|
||||
} else {
|
||||
makeTargetVisible(cm.display.wrapper);
|
||||
// mark the match
|
||||
state.marker = cm.state.search.marker = cm.markText(pos.from, pos.to, {
|
||||
className: MATCH_CLASS,
|
||||
clearOnEnter: true,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function clearMarker() {
|
||||
if (state.marker) state.marker.clear();
|
||||
}
|
||||
|
||||
|
||||
function showTally(num, numApplies) {
|
||||
if (!state.tally) return;
|
||||
if (num === undefined) {
|
||||
num = 0;
|
||||
for (const cm of state.editors) {
|
||||
const {annotate, overlay} = getStateSafe(cm);
|
||||
num +=
|
||||
((annotate || {}).matches || []).length ||
|
||||
(overlay || {}).numFound ||
|
||||
0;
|
||||
}
|
||||
state.numFound = num;
|
||||
}
|
||||
if (numApplies === undefined && state.searchInApplies && state.numApplies < 0) {
|
||||
numApplies = 0;
|
||||
const elements = state.find ? document.getElementsByClassName(APPLIES_VALUE_CLASS) : [];
|
||||
const {rx} = state;
|
||||
for (const el of elements) {
|
||||
const value = el.value;
|
||||
if (rx) {
|
||||
rx.lastIndex = 0;
|
||||
// preventing an infinite loop if matched an empty string and didn't advance
|
||||
for (let m; (m = rx.exec(value)) && ++numApplies && rx.lastIndex > m.index;) { /* NOP */ }
|
||||
} else {
|
||||
let i = -1;
|
||||
while ((i = value.indexOf(state.find, i + 1)) >= 0) numApplies++;
|
||||
}
|
||||
}
|
||||
state.numApplies = numApplies;
|
||||
} else {
|
||||
numApplies = state.numApplies;
|
||||
}
|
||||
const newText = num + (numApplies > 0 ? '+' + numApplies : '');
|
||||
if (state.tally.textContent !== newText) {
|
||||
state.tally.textContent = newText;
|
||||
const newTitle = t('searchNumberOfResults' + (numApplies ? '2' : ''));
|
||||
if (state.tally.title !== newTitle) state.tally.title = newTitle;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function trimUndoHistory() {
|
||||
const history = state.undoHistory;
|
||||
for (let last; (last = history[history.length - 1]);) {
|
||||
const undoables = last.filter(([cm, generation]) =>
|
||||
document.body.contains(cm.display.wrapper) && !cm.isClean(generation));
|
||||
if (undoables.length) {
|
||||
history[history.length - 1] = undoables;
|
||||
break;
|
||||
}
|
||||
history.length--;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function focusNoScroll(el) {
|
||||
if (el) {
|
||||
saveWindowScrollPos();
|
||||
el.focus({preventScroll: true});
|
||||
restoreWindowScrollPos({immediately: false});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function saveWindowScrollPos() {
|
||||
state.scrollX = window.scrollX;
|
||||
state.scrollY = window.scrollY;
|
||||
}
|
||||
|
||||
|
||||
function restoreWindowScrollPos({immediately = true} = {}) {
|
||||
if (!immediately) {
|
||||
// run in the next microtask cycle
|
||||
Promise.resolve().then(restoreWindowScrollPos);
|
||||
return;
|
||||
}
|
||||
if (window.scrollX !== state.scrollX || window.scrollY !== state.scrollY) {
|
||||
window.scrollTo(state.scrollX, state.scrollY);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// produces [i, i+1, i-1, i+2, i-2, i+3, i-3, ...]
|
||||
function radiateArray(arr, focalIndex) {
|
||||
const focus = arr[focalIndex];
|
||||
if (!focus) return arr;
|
||||
const result = [focus];
|
||||
const len = arr.length;
|
||||
for (let i = 1; i < len; i++) {
|
||||
if (focalIndex + i < len) {
|
||||
result.push(arr[focalIndex + i]);
|
||||
}
|
||||
if (focalIndex - i >= 0) {
|
||||
result.push(arr[focalIndex - i]);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
function readStorage() {
|
||||
chromeLocal.getValue('editor').then((editor = {}) => {
|
||||
state.find = editor.find || '';
|
||||
state.replace = editor.replace || '';
|
||||
state.icase = editor.icase || state.icase;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function writeStorage() {
|
||||
chromeLocal.getValue('editor').then((editor = {}) =>
|
||||
chromeLocal.setValue('editor', Object.assign(editor, {
|
||||
find: state.find,
|
||||
replace: state.replace,
|
||||
icase: state.icase,
|
||||
})));
|
||||
}
|
||||
|
||||
//endregion
|
||||
})();
|
|
@ -1,34 +0,0 @@
|
|||
/* global CodeMirror CSSLint stylelint linterConfig */
|
||||
'use strict';
|
||||
|
||||
CodeMirror.registerHelper('lint', 'csslint', code =>
|
||||
CSSLint.verify(code, deepCopy(linterConfig.getCurrent('csslint')))
|
||||
.messages.map(message => ({
|
||||
from: CodeMirror.Pos(message.line - 1, message.col - 1),
|
||||
to: CodeMirror.Pos(message.line - 1, message.col),
|
||||
message: message.message,
|
||||
rule: message.rule.id,
|
||||
severity : message.type
|
||||
}))
|
||||
);
|
||||
|
||||
CodeMirror.registerHelper('lint', 'stylelint', code =>
|
||||
stylelint.lint({
|
||||
code,
|
||||
config: deepCopy(linterConfig.getCurrent('stylelint')),
|
||||
}).then(({results}) => {
|
||||
if (!results[0]) {
|
||||
return [];
|
||||
}
|
||||
return results[0].warnings.map(warning => ({
|
||||
from: CodeMirror.Pos(warning.line - 1, warning.column - 1),
|
||||
to: CodeMirror.Pos(warning.line - 1, warning.column),
|
||||
message: warning.text
|
||||
.replace('Unexpected ', '')
|
||||
.replace(/^./, firstLetter => firstLetter.toUpperCase())
|
||||
.replace(/\s*\([^(]+\)$/, ''), // strip the rule,
|
||||
rule: warning.text.replace(/^.*?\s*\(([^(]+)\)$/, '$1'),
|
||||
severity : warning.severity
|
||||
}));
|
||||
})
|
||||
);
|
|
@ -1,49 +0,0 @@
|
|||
'use strict';
|
||||
|
||||
/**
|
||||
* CSSLint Config values
|
||||
* 0 = disabled; 1 = warning; 2 = error
|
||||
*/
|
||||
window.linterConfig.defaults.csslint = {
|
||||
// Default warnings
|
||||
'display-property-grouping': 1,
|
||||
'duplicate-properties': 1,
|
||||
'empty-rules': 1,
|
||||
'errors': 1,
|
||||
'known-properties': 1,
|
||||
|
||||
// Default disabled
|
||||
'adjoining-classes': 0,
|
||||
'box-model': 0,
|
||||
'box-sizing': 0,
|
||||
'bulletproof-font-face': 0,
|
||||
'compatible-vendor-prefixes': 0,
|
||||
'duplicate-background-images': 0,
|
||||
'fallback-colors': 0,
|
||||
'floats': 0,
|
||||
'font-faces': 0,
|
||||
'font-sizes': 0,
|
||||
'gradients': 0,
|
||||
'ids': 0,
|
||||
'import': 0,
|
||||
'import-ie-limit': 0,
|
||||
'important': 0,
|
||||
'order-alphabetical': 0,
|
||||
'outline-none': 0,
|
||||
'overqualified-elements': 0,
|
||||
'qualified-headings': 0,
|
||||
'regex-selectors': 0,
|
||||
'rules-count': 0,
|
||||
'selector-max': 0,
|
||||
'selector-max-approaching': 0,
|
||||
'selector-newline': 0,
|
||||
'shorthand': 0,
|
||||
'star-property-hack': 0,
|
||||
'text-indent': 0,
|
||||
'underscore-property-hack': 0,
|
||||
'unique-headings': 0,
|
||||
'universal-selector': 0,
|
||||
'unqualified-attributes': 0,
|
||||
'vendor-prefix': 0,
|
||||
'zero-units': 0
|
||||
};
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user