Skip to content

Commit 8786445

Browse files
committed
indent背景cssの挿入
1 parent fd028d4 commit 8786445

File tree

1 file changed

+29
-3
lines changed

1 file changed

+29
-3
lines changed

js/scrapboxCssScript.js

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ const insertIndentCSSRule = (scrapboxIndentOptions) => {
6464
});
6565
};
6666

67-
const storageAttachment = () => {
67+
const makerAttachment = () => {
6868
chrome.storage.local.get('scrapboxIndentOption', (result) => {
6969
const scrapboxIndentOptions = result.scrapboxIndentOption;
7070
insertIndentCSSRule(scrapboxIndentOptions);
@@ -74,9 +74,35 @@ const storageAttachment = () => {
7474
// update
7575
chrome.runtime.onMessage.addListener((request) => {
7676
if (request === 'scrapbox_list_maker') {
77-
storageAttachment();
77+
makerAttachment();
7878
}
7979
});
8080

8181
// initialize
82-
storageAttachment();
82+
makerAttachment();
83+
84+
const indentColorCSS = [
85+
`.indent-mark .char-index{
86+
--scrapbox-indent-maker-opacity: 0.2;
87+
--scrapbox-indent-maker-yellow: rgba(255,255,64, var(--scrapbox-indent-maker-opacity));
88+
--scrapbox-indent-maker-green: rgba(127,255,127, var(--scrapbox-indent-maker-opacity));
89+
--scrapbox-indent-maker-red: rgba(255,127,255, var(--scrapbox-indent-maker-opacity));
90+
--scrapbox-indent-maker-blue: rgba(79,236,236, var(--scrapbox-indent-maker-opacity));
91+
}`,
92+
`.indent-mark .char-index:nth-child(4n+1) { background-color: var(--scrapbox-indent-maker-yellow) }`,
93+
`.indent-mark .char-index:nth-child(4n+2) { background-color: var(--scrapbox-indent-maker-green) }`,
94+
`.indent-mark .char-index:nth-child(4n+3) { background-color: var(--scrapbox-indent-maker-red) }`,
95+
`.indent-mark .char-index:nth-child(4n) { background-color: var(--scrapbox-indent-maker-blue) }`,
96+
`.indent-mark .char-index:nth-last-child(2) { background-color: transparent !important; }`,
97+
`.indent-mark .char-index:nth-last-child(1) { background-color: transparent !important; }`,
98+
];
99+
100+
const insertIndentColorCSSRule = () => {
101+
// insert new rules
102+
indentColorCSS.map((css) => {
103+
console.log(css);
104+
document.styleSheets[0].insertRule(css);
105+
});
106+
};
107+
108+
insertIndentColorCSSRule();

0 commit comments

Comments
 (0)