Skip to content

Commit b3890da

Browse files
author
hoang.tran12
committed
refactor
1 parent a615906 commit b3890da

File tree

11 files changed

+73
-53
lines changed

11 files changed

+73
-53
lines changed

pages/viewScriptSource/main.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
import { disableSmoothScrollSaver } from "../../popup/helpers/storage.js";
12
import { run as enableSmoothScroll } from "../../scripts/smoothScroll.js";
23

34
window.onload = async () => {
4-
enableSmoothScroll();
5+
if (!disableSmoothScrollSaver.get()) enableSmoothScroll();
56
try {
67
let id = new URL(location.href).searchParams.get("file");
78
let source = await getScriptSource(id);

popup/helpers/storage.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,6 @@ export const favoriteScriptsSaver = createScriptsSaver(
6060
);
6161

6262
// default is false => enabled; true => disabled
63-
export const smoothScrollSaver = createVariableSaver(
64-
"useful-scripts-smoothScroll"
63+
export const disableSmoothScrollSaver = createVariableSaver(
64+
"useful-scripts-disable-smoothScroll"
6565
);

popup/helpers/theme.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { themeSaver } from "./storage.js";
33
const cssTag = document.querySelector("link[rel='stylesheet/less']");
44

55
const me = {
6+
name: "HoangTran",
67
link: "https://github.com/hoangTran0410",
78
avatar: "https://avatars.githubusercontent.com/u/36368107",
89
};
@@ -22,6 +23,7 @@ export const THEME = {
2223
en: "xtri98",
2324
vi: "xtri98",
2425
author: {
26+
name: "xtri98",
2527
link: "https://github.com/xtri98",
2628
avatar: "https://avatars.githubusercontent.com/u/154915091",
2729
},

popup/index.js

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import {
2727
activeTabIdSaver,
2828
favoriteScriptsSaver,
2929
recentScriptsSaver,
30-
smoothScrollSaver,
30+
disableSmoothScrollSaver,
3131
} from "./helpers/storage.js";
3232
import {
3333
canAutoRun,
@@ -560,10 +560,10 @@ function initSettings() {
560560
const themeRow = document.createElement("div");
561561
themeRow.classList.add("row");
562562
const author = curThem?.author
563-
? `<a target="_blank" href="${curThem.author.link}" title="${t({
564-
vi: "Tác giả",
565-
en: "Author",
566-
})}">
563+
? `<a target="_blank" href="${curThem.author.link}" data-tooltip="${t({
564+
vi: "Tác giả: " + curThem.author.name,
565+
en: "Author: " + curThem.author.name,
566+
})}" data-flow="left">
567567
<img src="${curThem.author.avatar}" class="avatar" />
568568
</a>`
569569
: "";
@@ -606,11 +606,14 @@ function initSettings() {
606606
</div>
607607
`;
608608
const checkbox = smoothScrollRow.querySelector("button");
609-
checkbox.classList.toggle("active", !(smoothScrollSaver.get() ?? false));
609+
checkbox.classList.toggle(
610+
"active",
611+
!(disableSmoothScrollSaver.get() ?? false)
612+
);
610613
checkbox.onclick = () => {
611-
let curVal = smoothScrollSaver.get();
614+
let curVal = disableSmoothScrollSaver.get();
612615
let newVal = !curVal;
613-
smoothScrollSaver.set(newVal);
616+
disableSmoothScrollSaver.set(newVal);
614617

615618
let enabled = !newVal;
616619
trackEvent("CHANGE-SMOOTH-SCROLL-" + (enabled ? "ON" : "OFF"));
@@ -707,7 +710,8 @@ window.addEventListener("scroll", onScrollEnd);
707710
(async function () {
708711
trackEvent("OPEN-POPUP");
709712

710-
if (!smoothScrollSaver.get()) disableSmoothScroll = enableSmoothScroll();
713+
if (!disableSmoothScrollSaver.get())
714+
disableSmoothScroll = enableSmoothScroll();
711715
initTracking();
712716
initSearch();
713717
initTooltip();

popup/styles/default.less

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,10 @@ option {
320320
.more-item {
321321
opacity: 1;
322322
}
323+
324+
.badgeContainer {
325+
transform: translateY(-100%);
326+
}
323327
}
324328

325329
.more-item {
@@ -371,8 +375,8 @@ option {
371375
.badgeContainer {
372376
position: absolute;
373377
top: 0;
374-
right: 5px;
375-
transform: translateY(-40%);
378+
right: 0;
379+
transition: all .2s ease;
376380
border-radius: 3px;
377381
overflow: hidden;
378382
}
@@ -478,7 +482,7 @@ option {
478482
visibility: visible;
479483
top: calc(100% + 5px);
480484
opacity: 1;
481-
transition: all .2s ease .2s;
485+
transition: all .2s ease .5s;
482486
}
483487
}
484488
}

popup/styles/xtri98.less

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,8 @@
155155
.badgeContainer {
156156
position: absolute;
157157
top: 0;
158-
right: 50;
159-
transform: translateX(50%) translateY(-40%);
158+
right: 0;
159+
transform: translateY(-40%);
160160
border-radius: 5px;
161161
overflow: hidden;
162162
}
@@ -166,13 +166,10 @@
166166

167167
display: inline-block;
168168
padding: 0.25em 0.4em;
169-
font-size: 75%;
169+
font-size: 80%;
170170
font-weight: 700;
171-
line-height: 1;
172-
text-align: center;
173171
white-space: nowrap;
174172
vertical-align: baseline;
175-
border-radius: 0.25rem;
176173
}
177174
}
178175
}
@@ -263,7 +260,7 @@
263260
visibility: visible;
264261
top: calc(100% + 5px);
265262
opacity: 1;
266-
transition: all .3s ease .2s;
263+
transition: all .3s ease .5s;
267264
}
268265
}
269266
}

scripts/net-request-rules/dynamicRulesEditor/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
</head>
3636

3737
<body>
38-
<script src="./index.js"></script>
38+
<script type="module" src="./index.js"></script>
3939
</body>
4040

4141
</html>

scripts/net-request-rules/dynamicRulesEditor/index.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
1-
let count = document.createElement("h1");
2-
document.body.appendChild(count);
1+
import { t } from "../../../popup/helpers/lang.js";
2+
3+
let h1 = document.createElement("h1");
4+
h1.style.textAlign = "center";
5+
document.body.appendChild(h1);
36

47
chrome.declarativeNetRequest.getDynamicRules((rules) => {
58
console.log(rules);
6-
count.innerText = "Rules Count: " + rules.length;
9+
h1.innerHTML = t({
10+
en: "..Feature in development.. <br/><br/>Rules Count: " + rules.length,
11+
vi:
12+
"..Chức năng đang được phát triển.. <br/><br/>Rules Count: " +
13+
rules.length,
14+
});
715
});
816

917
let deleteAllBtn = document.createElement("button");
@@ -17,7 +25,7 @@ deleteAllBtn.onclick = () => {
1725
},
1826
() => {
1927
alert("DONE");
20-
count.innerText = "Rules Count: " + 0;
28+
h1.innerText = "Rules Count: " + 0;
2129
}
2230
);
2331
}

scripts/web_timer.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@ export default {
2828
},
2929
onClick: openGraph,
3030
},
31+
{
32+
icon: '<i class="fa-regular fa-clock"></i>',
33+
name: {
34+
en: "For developers - Coding timer",
35+
vi: "Cho developer - Thời gian code",
36+
},
37+
onClick: () => window.open("https://wakatime.com/", "_blank"),
38+
},
3139
],
3240

3341
changeLogs: {
@@ -242,7 +250,7 @@ function run() {
242250
});
243251

244252
const INTERVAL_UPDATE = 1;
245-
const INTERVAL_SAVE = 30;
253+
const INTERVAL_SAVE = 10;
246254
const IDLE_TIME = 60;
247255
const IDLE_TIME_IF_BLUR = 10;
248256
const SHOW_OVERLAY = true;

scripts/web_timer.less

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ svg {
152152
padding: 5px 10px;
153153
transition: all 0.2s ease;
154154
font-family: monospace;
155-
font-size: 1.2em;
155+
font-size: 1em;
156156
user-select: none;
157157

158158
&:hover {
@@ -195,12 +195,7 @@ svg {
195195
&.total {
196196
color: #eee;
197197
background-color: #223;
198-
border-top: 1px solid #a0a0a0;
199-
margin-top: 10px;
200-
// sticky bottom
201-
position: -webkit-sticky;
202-
position: sticky;
203-
bottom: -1px;
198+
border-bottom: 1px solid #a0a0a099;
204199
}
205200

206201
&:hover,

0 commit comments

Comments
 (0)