File tree 3 files changed +82
-7
lines changed
3 files changed +82
-7
lines changed Original file line number Diff line number Diff line change 3
3
padding : 0 ;
4
4
}
5
5
6
+ # popup {
7
+ margin-top : 10px ;
8
+ }
9
+
6
10
h1 , h2 , h3 , h4 , h5 , h6 {
7
11
font-family : inherit;
8
12
font-weight : 500 ;
9
13
line-height : 1.2 ;
10
14
color : inherit;
11
15
}
12
16
13
- button {
14
- display : none;
17
+ .btn {
18
+ display : inline-block;
19
+ margin-bottom : 0 ;
20
+ font-weight : normal;
21
+ text-align : center;
22
+ vertical-align : middle;
23
+ cursor : pointer;
24
+ background-image : none;
25
+ border : 1px solid transparent;
26
+ white-space : nowrap;
27
+ padding : 6px 12px ;
28
+ font-size : 14px ;
29
+ line-height : 1.42857 ;
30
+ border-radius : 4px ;
31
+ -webkit-user-select : none;
32
+ -moz-user-select : none;
33
+ -ms-user-select : none;
34
+ user-select : none;
35
+ padding : 1px 5px ;
36
+ font-size : 12px ;
37
+ line-height : 1.5 ;
38
+ border-radius : 3px ;
39
+ }
40
+
41
+ .btn-default {
42
+ color : # 333 ;
43
+ background-color : # fff ;
44
+ border-color : # ccc ;
45
+ }
46
+
47
+ .btn-default : hover ,
48
+ .btn-default : focus ,
49
+ .btn-default : active ,
50
+ .btn-default .active ,
51
+ .open > .btn-default .dropdown-toggle {
52
+ color : # 333 ;
53
+ background-color : # e6e6e6 ;
54
+ border-color : # adadad ;
55
+ }
56
+
57
+ .btn : hover , .btn : focus {
58
+ color : # 333 ;
59
+ text-decoration : none;
60
+ }
61
+
62
+ .btn .disabled , .btn [disabled ] {
63
+ cursor : not-allowed;
64
+ pointer-events : none;
65
+ opacity : .65 ;
66
+ filter : alpha (opacity=65);
67
+ -webkit-box-shadow : none;
68
+ box-shadow : none;
15
69
}
16
70
17
71
a {
Original file line number Diff line number Diff line change 4
4
< link rel ="stylesheet " href ="popup.css ">
5
5
</ head >
6
6
< body >
7
- < div id ="popup " class ="notify-stream "> </ div >
7
+ < div id ="popup " class ="notify-stream "> 载入中... </ div >
8
8
< script src ="jquery.js "> </ script >
9
9
< script src ="popup.js "> </ script >
10
10
</ body >
Original file line number Diff line number Diff line change @@ -6,15 +6,36 @@ bg.getNotifications(function(data) {
6
6
alert ( '未登录' ) ;
7
7
chrome . tabs . create ( { url : 'https://segmentfault.com/user/login' } ) ;
8
8
}
9
- $ ( '#popup' ) . append ( $html . find ( '.stream-list' ) . html ( ) ) ;
9
+ $ ( '#popup' ) . empty ( ) . append ( $html . find ( '.stream-list' ) . html ( ) ) ;
10
10
} ) ;
11
11
12
12
$ ( '#popup' ) . on ( 'click' , 'a' , function ( ) {
13
13
var $this = $ ( this ) ;
14
14
var href = $this . attr ( 'href' ) ;
15
- if ( href . substring ( 0 , 1 ) === '/' && href . substring ( 0 , 2 ) !== '//' ) {
16
- href = 'https://segmentfault.com' + href ;
17
- }
15
+ href = transUrl ( href ) ;
18
16
chrome . tabs . create ( { url : href } ) ;
19
17
return false ;
20
18
} ) ;
19
+
20
+ $ ( '#popup' ) . on ( 'click' , 'button' , function ( ) {
21
+ var $this = $ ( this ) ;
22
+ var $unViewed = $ ( '#popup' ) . find ( '.stream-list__item:not(".viewed")' ) ;
23
+ $unViewed . each ( function ( index , el ) {
24
+ var $el = $ ( el ) ;
25
+ $el . addClass ( 'viewed' ) ;
26
+ var url = $el . find ( 'a:last' ) . attr ( 'href' ) ;
27
+ url = transUrl ( url ) ;
28
+ $ . ajax ( {
29
+ url : url ,
30
+ method : 'get'
31
+ } ) ;
32
+ } ) ;
33
+ $this . attr ( 'disabled' , true ) ;
34
+ } ) ;
35
+
36
+ function transUrl ( url ) {
37
+ if ( url . substring ( 0 , 1 ) === '/' && url . substring ( 0 , 2 ) !== '//' ) {
38
+ url = 'https://segmentfault.com' + url ;
39
+ }
40
+ return url ;
41
+ }
You can’t perform that action at this time.
0 commit comments