@@ -8,11 +8,17 @@ export default {
8
8
} ,
9
9
description : {
10
10
en : `Scroll smoothly on all websites with your mouse and keyboard.<br/>
11
- Smooth like when you scroll this extension.<br/><br/>
12
- Support middle click to scroll.` ,
11
+ <ul>
12
+ <li>Suggested if you use mouse (turn off if use touchpad)</li>
13
+ <li>Click to Disable/Enable for current website</li>
14
+ <li>Support middle click to scroll</li>
15
+ </ul><br/>` ,
13
16
vi : `Cuộn chuột siêu mượt cho mọi trang web.<br/>
14
- Mượt như khi cuộn chuột trong extension này vậy.<br/><br/>
15
- Hỗ trợ scroll khi bấm chuột giữa.` ,
17
+ <ul>
18
+ <li>Khuyên dùng với chuột (tắt nếu dùng touchpad)</li>
19
+ <li>Bấm để Tắt/Mở cho trang web hiện tại</li>
20
+ <li>Hỗ trợ bấm chuột giữa để cuộn trang</li>
21
+ </ul><br/>` ,
16
22
video : "https://www.smoothscroll.net/mac/img/vid/Demo-Mac-720p.mp4" ,
17
23
} ,
18
24
badges : [ BADGES . hot ] ,
@@ -28,107 +34,90 @@ export default {
28
34
] ,
29
35
30
36
changeLogs : {
37
+ "2024-07-11" : "click to disable/enable for current site" ,
31
38
"2024-05-26" : "init" ,
32
39
} ,
33
40
34
41
popupScript : {
35
- onEnable : async ( ) => {
36
- const { t } = await import ( "../popup/helpers/lang.js" ) ;
37
- const { runScriptInTab, getAllTabs : getAllAvailableTabs } = await import (
38
- "./helpers/utils.js"
39
- ) ;
40
- const tabs = await getAllAvailableTabs ( ) ;
41
- let count = 0 ;
42
- for ( let tab of tabs ) {
43
- try {
44
- runScriptInTab ( {
45
- target : {
46
- tabId : tab . id ,
47
- allFrames : true ,
48
- } ,
49
- func : enableSmoothScroll ,
50
- world : "ISOLATED" ,
51
- } ) ;
52
- count ++ ;
53
- } catch ( e ) {
54
- console . error ( e ) ;
55
- }
56
- }
57
- if ( count )
58
- Swal . fire ( {
59
- icon : "success" ,
60
- title : t ( {
61
- vi : "Đã bật Cuộn chuột Siêu mượt" ,
62
- en : "Super smooth scroll enabled" ,
63
- } ) ,
64
- html : t ( {
65
- vi :
66
- `Đã tự BẬT cho ${ count } tab đang mở<br/><br/>` +
67
- "Bạn có thể dùng ngay không cần tải lại trang." ,
68
- en :
69
- `Enabled smooth scroll for ${ count } opening tabs<br/><br/>` +
70
- "Dont need to reload websites." ,
71
- } ) ,
72
- } ) ;
73
- } ,
74
- onDisable : async ( ) => {
75
- const { t } = await import ( "../popup/helpers/lang.js" ) ;
76
- const { runScriptInTab, getAllTabs : getAllAvailableTabs } = await import (
77
- "./helpers/utils.js"
78
- ) ;
79
- const tabs = await getAllAvailableTabs ( ) ;
80
- let count = 0 ;
81
- for ( let tab of tabs ) {
82
- try {
83
- runScriptInTab ( {
84
- target : {
85
- tabId : tab . id ,
86
- allFrames : true ,
87
- } ,
88
- func : ( ) => {
89
- window . ufs_smoothScroll_disable ?. ( ) ;
90
- } ,
91
- world : "ISOLATED" ,
92
- } ) ;
93
- count ++ ;
94
- } catch ( e ) {
95
- console . error ( e ) ;
96
- }
97
- }
98
- if ( count )
99
- Swal . fire ( {
100
- icon : "success" ,
101
- title : t ( {
102
- vi : "Đã tắt Cuộn chuột Siêu mượt" ,
103
- en : "Super smooth scroll disabled" ,
104
- } ) ,
105
- html : t ( {
106
- vi :
107
- `Đã tự TẮT cho ${ count } tab đang mở<br/><br/>` +
108
- "Không cần tải lại trang." ,
109
- en :
110
- `Disabled smooth scroll for ${ count } opening tabs<br/><br/>` +
111
- "Dont need to reload websites." ,
112
- } ) ,
113
- } ) ;
114
- } ,
42
+ onEnable : ( ) => setEnableForAllTab ( true ) ,
43
+ onDisable : ( ) => setEnableForAllTab ( false ) ,
115
44
} ,
116
45
117
46
contentScript : {
118
- onDocumentStart_ : ( details ) => {
119
- enableSmoothScroll ( ) ;
47
+ onDocumentStart_ : enableSmoothScroll ,
48
+ onClick_ : ( ) => {
49
+ if ( typeof window . ufs_smoothScroll_disable === "function" ) {
50
+ window . ufs_smoothScroll_disable ( ) ;
51
+ localStorage . setItem ( "ufs_smoothScroll_disable" , 1 ) ;
52
+ if ( window === window . top )
53
+ alert ( "DISABLED smooth scroll for this site: " + location . hostname ) ;
54
+ } else {
55
+ localStorage . setItem ( "ufs_smoothScroll_disable" , 0 ) ;
56
+ enableSmoothScroll ( ) ;
57
+ if ( window === window . top )
58
+ alert ( "ENABLED smooth scroll for this site: " + location . hostname ) ;
59
+ }
120
60
} ,
121
61
} ,
122
62
} ;
123
63
64
+ async function setEnableForAllTab ( enable ) {
65
+ const { t } = await import ( "../popup/helpers/lang.js" ) ;
66
+ const { runScriptInTab, getAllTabs : getAllAvailableTabs } = await import (
67
+ "./helpers/utils.js"
68
+ ) ;
69
+ const tabs = await getAllAvailableTabs ( ) ;
70
+ let count = 0 ;
71
+ for ( let tab of tabs ) {
72
+ try {
73
+ runScriptInTab ( {
74
+ target : {
75
+ tabId : tab . id ,
76
+ allFrames : true ,
77
+ } ,
78
+ func : enable
79
+ ? enableSmoothScroll
80
+ : ( ) => {
81
+ window . ufs_smoothScroll_disable ?. ( ) ;
82
+ } ,
83
+ world : "ISOLATED" ,
84
+ } ) ;
85
+ count ++ ;
86
+ } catch ( e ) {
87
+ console . error ( e ) ;
88
+ }
89
+ }
90
+ let text = enable
91
+ ? { vi : "Bật" , en : "Enabled" }
92
+ : { vi : "Tắt" , en : "Disabled" } ;
93
+
94
+ if ( count )
95
+ Swal . fire ( {
96
+ icon : "success" ,
97
+ title : t ( {
98
+ vi : "Đã " + text . vi + " Cuộn chuột Siêu mượt" ,
99
+ en : "Super smooth scroll " + text . en ,
100
+ } ) ,
101
+ html : t ( {
102
+ vi :
103
+ `Đã tự ${ text . vi } cho ${ count } tab đang mở<br/><br/>` +
104
+ "Bạn có thể dùng ngay không cần tải lại trang." ,
105
+ en :
106
+ `${ text . en } smooth scroll for ${ count } opening tabs<br/><br/>` +
107
+ "Dont need to reload websites." ,
108
+ } ) ,
109
+ } ) ;
110
+ }
111
+
124
112
// TODO:
125
- // + setting page
126
- // + horizontal scroll
127
- // + fix window.scrollTo with behavior: "smooth"
128
- // + check excluded
113
+ // [ ] setting page
114
+ // [ ] horizontal scroll
115
+ // [x] fix window.scrollTo with behavior: "smooth"
116
+ // [x] check excluded
129
117
130
118
// https://chromewebstore.google.com/detail/smoothscroll/nbokbjkabcmbfdlbddjidfmibcpneigj
131
119
export function enableSmoothScroll ( ) {
120
+ if ( localStorage . getItem ( "ufs_smoothScroll_disable" ) == 1 ) return ;
132
121
// =======================================================================
133
122
// ============================ sscr.js ==================================
134
123
// =======================================================================
@@ -979,6 +968,7 @@ export function enableSmoothScroll() {
979
968
window . ufs_smoothScroll_disable = ( ) => {
980
969
cleanup ( ) ;
981
970
cleanupMiddlemouse ( ) ;
971
+ window . ufs_smoothScroll_disable = null ;
982
972
} ;
983
973
984
974
return window . ufs_smoothScroll_disable ;
0 commit comments