Repository navigation
Expand file tree
/
Copy path5StarOneKey.user.js
More file actions
250 lines (221 loc) · 10.3 KB
/
Copy path5StarOneKey.user.js
File metadata and controls
250 lines (221 loc) · 10.3 KB
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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
// ==UserScript==
// @name 5 Star One Key
// @version 0.35.1a
// @description 扁平式按钮
// @updateURL https://github.com/Shinku1014/MakeOPRGreatAgain/raw/master/5StarOneKey.user.js
// @downloadURL https://github.com/Shinku1014/MakeOPRGreatAgain/raw/master/5StarOneKey.user.js
// @author jqqqqqqqqqq totoro625 ShinkuE
// @match https://wayfarer.nianticlabs.com/review
// @require https://code.jquery.com/jquery-3.2.1.min.js
// @grant unsafeWindow
// ==/UserScript==
var auto_select = true;
var big_stars = true;
var buttons = [
{button:"5.0", total:5, name:5, history:5, unique:5, location:5, safety:5},
{button:"4.8", total:4, name:5, history:5, unique:5, location:5, safety:5},
{button:"4.5", total:4, name:5, history:5, unique:5, location:4, safety:4},
{button:"4.3", total:4, name:5, history:5, unique:4, location:4, safety:4},
{button:"4.2", total:4, name:4, history:5, unique:4, location:4, safety:4},
{button:"4.0", total:4, name:4, history:4, unique:4, location:4, safety:4},
{button:"3.8", total:4, name:4, history:4, unique:4, location:3, safety:4},
{button:"3.7", total:4, name:4, history:4, unique:4, location:3, safety:3},
{button:"3.5", total:3, name:4, history:4, unique:4, location:3, safety:3},
{button:"4.3 位准", total:4, name:4, history:4, unique:4, location:5, safety:5},
{button:"4.0 位准", total:4, name:4, history:3, unique:3, location:5, safety:5},
{button:"3.7 位准", total:3, name:3, history:3, unique:3, location:5, safety:5},
{button:"3.5 劣名", total:4, name:1, history:4, unique:4, location:4, safety:4},
{button:"3.5 疑偏", total:4, name:4, history:4, unique:4, location:2, safety:3},
{button:"3.0 甩锅", total:3, name:3, history:3, unique:3, location:3, safety:3},
];
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////EDIT THIS LINE BELOW!
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
const w = typeof unsafeWindow == "undefined" ? window : unsafeWindow;
var submit_type = null;
var first = true;
function enable_auto_select(){
if (submit_type == 'EDIT') return;
$(".button-star").each(function(){ // Don't use mouse hover to select stars
if(first) {
console.warn("first ignored");
$(this).click(function() {
var answerCtrl2 = angular.element($("div[ng-controller='AnswersController as answerCtrl2']")).scope().answerCtrl2;
answerCtrl2.confirmLowQuality8888 = answerCtrl2.confirmLowQuality;
answerCtrl2.confirmLowQuality = function() {
answerCtrl2.confirmLowQuality8888.apply( answerCtrl2.confirmLowQuality8888, arguments);
setTimeout(function(){ window.location.assign("/review");}, 1000);
};
});
first = false;
}
/*else {
$(this).hover(function(){$(this).click();});
}*/
});
}
var button_list = {
'total': [],
'name': [],
'history': [],
'unique': [],
'location': [],
'safety': []
};
function update_button_list(){
if (submit_type == 'EDIT') return;
$(".button-star").each(function(){ // Don't use mouse hover to select stars
switch($(this).attr("ng-model")) {
case "answerCtrl.formData.quality":
button_list['total'].push($(this));
if (big_stars) {
$(this).css({'margin-bottom': '10px'});
$(this).children('span').css({'font-size': '42px'});
$(this).css({'margin-left': '5px'});
$(this).css({'margin-right': '5px'});
}
break;
case "answerCtrl.formData.description":
button_list['name'].push($(this));
if (big_stars) {
$(this).css({'margin-bottom': '10px'});
$(this).children('span').css({'font-size': '34px'});
$(this).css({'margin-left': '5px'});
$(this).css({'margin-right': '5px'});
}
break;
case "answerCtrl.formData.cultural":
button_list['history'].push($(this));
if (big_stars) {
$(this).css({'margin-bottom': '10px'});
$(this).children('span').css({'font-size': '34px'});
$(this).css({'margin-left': '5px'});
$(this).css({'margin-right': '5px'});
}
break;
case "answerCtrl.formData.uniqueness":
button_list['unique'].push($(this));
if (big_stars) {
$(this).children('span').css({'font-size': '34px'});
$(this).css({'margin-left': '5px'});
$(this).css({'margin-right': '5px'});
}
break;
case "answerCtrl.formData.location":
button_list['location'].push($(this));
if (big_stars) {
$(this).children('span').css({'font-size': '34px'});
$(this).css({'margin-left': '5px'});
$(this).css({'margin-right': '5px'});
}
break;
case "answerCtrl.formData.safety":
button_list['safety'].push($(this));
if (big_stars) {
$(this).children('span').css({'font-size': '34px'});
$(this).css({'margin-left': '5px'});
$(this).css({'margin-right': '5px'});
}
break;
}
});
}
function rate_portal(total, name, history, unique, location, safety) {
button_list['total'][total - 1].click();
button_list['name'][name - 1].click();
button_list['history'][history - 1].click();
button_list['unique'][unique - 1].click();
button_list['location'][location - 1].click();
button_list['safety'][safety - 1].click();
}
function add_button() {
// var button_region = document.getElementById("submitDiv");
var button_region = document.getElementById("descriptionDiv");
button_region.style.display = 'inline';
button_region.style.overflow = 'scroll';
if (submit_type == 'NEW') {
buttons.forEach(function(button_data) {
var button = document.createElement("button");
var textnode = document.createTextNode(button_data["button"]);
button.className = "button submit-button";
// button.style.minwidth = '70px';
button.style.height = '32px';
button.style.background = '#F1F1F1';
button.style.border = '0px';
button.style.borderRadius = '0px';
button.style.color = '#202020';
button.style.fontSize = '16px';
button.style.fontWeight = 500;
button.appendChild(textnode);
// button_region.insertBefore(button);
button_region.appendChild(button);
button.onclick = function()
{
rate_portal(button_data["total"], button_data["name"], button_data["history"], button_data["unique"], button_data["location"], button_data["safety"]);
angular.element(document.getElementById('AnswersController')).scope().answerCtrl.submitForm();setTimeout(function(){ window.location.assign("/review");}, 100);};});
}
w.$scope = element => w.angular.element(element).scope();
}
function move_portal_rate() {
if (submit_type == 'EDIT') return;
// move portal rating to the right side
var scorePanel = w.document.querySelector("div[class='text-center hidden-xs']");
if (scorePanel == null) {
scorePanel = w.document.querySelector("div[class~='pull-right']");
}
let nodesToMove = Array.from(w.document.querySelector("div[class='btn-group']").parentElement.children);
nodesToMove = nodesToMove.splice(2, 6);
nodesToMove.push(w.document.createElement("br"));
for (let j = nodesToMove.length - 1; j >= 0; --j) {
scorePanel.insertBefore(nodesToMove[j], scorePanel.firstChild);
}
$("#AnswersController > form > div:nth-child(1) > div.col-xs-12.col-sm-4.pull-right.text-center.hidden-xs > span:nth-child(1)").css({'font-size': '20px'});
$("#AnswersController > form > div:nth-child(1) > div.col-xs-12.col-sm-4.pull-right.text-center.hidden-xs > span.glyphicon.glyphicon-info-sign.darkgray").css({'font-size': '20px'});
// moving submit button to right side of classification-div
const submitDiv = w.document.querySelectorAll("#submitDiv, #submitDiv + .text-center");
const classificationRow = w.document.querySelector(".classification-row");
const newSubmitDiv = w.document.createElement("div");
newSubmitDiv.className = "col-xs-12 col-sm-6";
submitDiv[0].style.marginTop = 16;
newSubmitDiv.appendChild(submitDiv[0]);
newSubmitDiv.appendChild(submitDiv[1]);
classificationRow.insertAdjacentElement("afterend", newSubmitDiv);
var submit = $(".button.big-submit-button")[0];
submit.classList.remove("big-submit-button");
submit.classList.add("submit-button");
submit.style.paddingLeft = "10px";
submit.style.paddingRight = "10px";
submit.style.margin = "10px";
}
function skip_confirm() {
//if (submit_type == 'EDIT') return;
var answerCtrl = angular.element(document.getElementById('AnswersController')).scope().answerCtrl;
answerCtrl.markDuplicate8888 = answerCtrl.markDuplicate;
answerCtrl.markDuplicate = function() {
answerCtrl.markDuplicate8888.apply( answerCtrl.markDuplicate8888, arguments);
answerCtrl.confirmDuplicate();
setTimeout(function(){ window.location.assign("/review");}, 1000);
};
}
function get_submit_type() {
var subCtrl = angular.element(document.getElementById('NewSubmissionController')).scope().subCtrl;
console.log(subCtrl.reviewType);
return subCtrl.reviewType; // NEW or EDIT
}
function execute_all() {
submit_type = get_submit_type();
if (submit_type == null) {
setTimeout(execute_all, 1000);
return;
}
if(auto_select) {
enable_auto_select();
}
add_button();
update_button_list();
move_portal_rate();
skip_confirm();
}
(function() {
setTimeout(execute_all, 100);
})();