-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathshow-popup.js
187 lines (179 loc) · 4.39 KB
/
show-popup.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
isInpopup = null
function oneClickGetPopupHtml(extension) {
if (!extension && "undefined" != typeof _extension) {
extension = _extension
}
// mail = `[email protected]`,
// rateLink = `https://chrome.google.com/webstore/detail/ifcojoeahdoocfalfogjphlejeinnphb/reviews`,
// githubLink = `https://github.com/1click-extensions/1click-webcam-to-gif`;
// console.log(extension);
return (str = `
<style>
.pleaseRate {
text-align: center;
position: fixed;
left: 15%;
top: 100px;
font-size: 40px;
padding: 10px 20px;
background-color: white;
border-radius: 3px;
/* background: linear-gradient(to right, #8bca6b, #0db702);*/
border: 7px solid #fff;
background: linear-gradient(to right, #f5a826, #faca42);
overflow: hidden;
box-shadow: 0 0 0 2px hsl(0, 0%, 80%);
box-sizing:border-box;
z-index:9999;
}
.pleaseRate a,
.pleaseRate a:hover,
.pleaseRate a:visited{
color:#000;
text-decoration:underline;
}
.please-rate-text {
padding-top: 15px;
margin: 0 auto;
width: 566px;
max-width:100%;
font-size:22px;
}
.btn-popup {
text-decoration: none;
color: #fff;
background-color: #26a69a;
text-align: center;
letter-spacing: .5px;
-webkit-transition: background-color .2s ease-out;
transition: background-color .2s ease-out;
cursor: pointer;
font-size: 14px;
outline: 0;
border: none;
border-radius: 2px;
display: inline-block;
height: 36px;
line-height: 36px;
padding: 0 16px;
vertical-align: middle;
-webkit-tap-highlight-color: transparent;
}
a.please-rate-github {
font-family: 'Acme', sans-serif;
position: absolute;
bottom: 42px;
left: -57px;
background: red;
color: #fdffc0;
padding: 3px 10px;
transform: rotate(45deg);
width: 232px;
text-align: center;
font-size: 23px;
}
button.btn-popup.no-thanks {
margin-left: 156px;
font-size: 14px;
height: 21px;
box-sizing: border-box;
padding: 3px 10px;
line-height: normal;
float: right;
opacity:0.7;
background:transparent;
color:#000;
}
.btn-popup a {
color: #fff;
text-decoration: none;
}
.skip-wrp{
padding-top:14px;
}
.addition {
padding-top: 15px;
}
.please-rate-buttons {
padding-top: 50px;
}
.please-rate-rate-link{
padding:20px;font-size:20px;
font-weight:bolder
}
.please-rate-title{
padding 10px 2px;
}
</style>
<div class="pleaseRate">
<div class="please-rate-text">
If you like 1Click Webcam to Gif <a target=_blank href="https://chrome.google.com/webstore/detail/ifcojoeahdoocfalfogjphlejeinnphb/reviews" >please give us 5-stars</a>
<br/>
<div class="addition">To report a bug please <a href="https://github.com/1click-extensions/1click-webcam-to-gif/issues/new">submit issue</a>
</div>
<div class="skip-wrp"><button type="button" class="btn-popup no-thanks ">Skip</button></div>
</div>
</div>
`)
}
function checkIfRankNeededAndAndAddRank(callbackIfNot) {
checkIfRankNeeded(function() {
oneClickPopupHtmlToBody(null)
chrome.runtime.sendMessage({
action: "rankRequested",
})
},callbackIfNot)
}
function checkIfRankNeeded(callback, callbackIfNot) {
chrome.runtime.sendMessage(
{
action: "checkIfNeedRating",
},
function(ratingNeeded) {
if (ratingNeeded) {
callback()
}
else if('function' == typeof callbackIfNot){
callbackIfNot();
}
}
)
}
function removeRateRequest() {
var popup = document.getElementsByClassName("pleaseRate")[0]
if (popup) {
popup.parentElement.removeChild(popup)
}
if('function' == typeof afterRemoveRateRequest){
afterRemoveRateRequest();
}
}
//console.log(typeof openRankPopupWhenPossible );
if (
"undefined" != typeof openRankPopupWhenPossible &&
openRankPopupWhenPossible
) {
//console.log('this');
checkIfRankNeededAndAndAddRank()
}
function oneClickPopupHtmlToBody(extension) {
var html = oneClickGetPopupHtml(extension)
var div = document.createElement("div")
div.innerHTML = html
document.body.appendChild(div)
div.addEventListener("click", function(e) {
e.stopPropagation()
})
document.body.addEventListener("click", removeRateRequest)
document
.getElementsByClassName("no-thanks")[0]
.addEventListener("click", removeRateRequest)
if (isInpopup) {
fixForPopup()
}
}
function fixForPopup() {
var pop = document.getElementsByClassName("pleaseRate")[0]
pop.style.position = "static"
document.body.style["min-width"] = "520px"
}