Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CssLsd
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Florent Berthaut
CssLsd
Commits
370e26b6
Commit
370e26b6
authored
3 years ago
by
BERTHAUT Florent
Browse files
Options
Downloads
Patches
Plain Diff
First working CSS changes
parent
a572ffc3
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
background.js
+1
-2
1 addition, 2 deletions
background.js
main.js
+17
-8
17 additions, 8 deletions
main.js
popup.html
+1
-1
1 addition, 1 deletion
popup.html
with
19 additions
and
11 deletions
background.js
+
1
−
2
View file @
370e26b6
// background.js
let
css
=
""
;
//Initialize the CSS storage on startup
chrome
.
runtime
.
onInstalled
.
addListener
(()
=>
{
chrome
.
storage
.
sync
.
set
({
css
});
});
This diff is collapsed.
Click to expand it.
main.js
+
17
−
8
View file @
370e26b6
...
...
@@ -5,6 +5,8 @@ editor.setTheme("ace/theme/monokai");
editor
.
session
.
setMode
(
"
ace/mode/css
"
);
//When the CSS editor changes, store it in the shared storage
//and call the background parseCSS script
editor
.
getSession
().
on
(
'
change
'
,
function
()
{
chrome
.
tabs
.
query
({
active
:
true
,
currentWindow
:
true
},
function
(
tabs
)
{
...
...
@@ -20,25 +22,32 @@ editor.getSession().on('change', function() {
function
parseCSS
()
{
console
.
log
(
"
Parsing CSS
"
);
//
g
et access to the
main document
//
G
et access to the
css written in the popup
chrome
.
storage
.
sync
.
get
(
"
css
"
,
function
(
cssObj
)
{
//Split the rules
let
rules
=
cssObj
.
css
.
split
(
"
}
"
);
for
(
let
r
of
rules
)
{
console
.
log
(
r
);
//Test if not empty
if
(
r
.
search
(
/
[\w]
+/i
)
>=
0
)
{
//Retrieve the selector
let
sel
=
r
.
split
(
"
{
"
)[
0
];
if
(
sel
.
search
(
/ */i
)
<
0
)
{
console
.
log
(
"
Selector
"
,
sel
);
//Retrieve the corresponding elements
let
els
=
document
.
querySelectorAll
(
sel
);
for
(
let
e
of
els
)
{
console
.
log
(
e
.
innerHTML
);
//Apply the properties to each
//TEMP, just put the background color in blue
e
.
style
[
"
background-color
"
]
=
"
blue
"
;
}
}
}
});
}
...
...
This diff is collapsed.
Click to expand it.
popup.html
+
1
−
1
View file @
370e26b6
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment