-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathwfes-reviewImproveCSS.js
More file actions
201 lines (177 loc) · 9.32 KB
/
wfes-reviewImproveCSS.js
File metadata and controls
201 lines (177 loc) · 9.32 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
// @name Review Improve CSS
// @version 1.2.2
// @description CSS modifcations for Wayfarer >= 5.7
// @author AlterTobi (CSS parts by AlfonsoML)
(function() {
"use strict";
const reorder_thumbs = true;
const myCssId = "rICSS";
const myStyle = `
.wf-review-card__header { padding: 0.5rem; }
.wf-review-card__body { margin-bottom: 0.5rem !important; }
.wf-review-card__footer { padding-bottom: 0.25rem !important; }
.py-2 { padding-top: 0 !important; padding-bottom: 0 !important; margin-bottom: 0.3rem; }
.px-4 { padding-left: 0.5rem !important; padding-right: 0.5rem !important; }
.wfes-mh100p { min-height: 100%; }
.wfes-h490 { min-height: 490px; }
.wfes-h725 { min-height: 725px; }
.wfes-none { display: none; }
.wfes-text-4xl { font-size: 1.9rem !important; line-height: 1.8rem !important; }
.wfes-text-lg { line-height: 1.5rem !important; font-size: 1.1rem !important; }
.wfes-h4 { font-size:1.5rem; line-height:1.2rem; padding-bottom:0.5rem; }
.wfes-card__header { margin-top:-0.5rem; margin-bottom: -1.0rem; }
.wfes-fit-content { max-width: fit-content; }
.wfes-pad05 { padding: 0.5rem !important; }
.wfes-smallgap { gap: 1rem 0 !important; }
.wfes-photo { max-height: 350px !important; width: auto !important; }
.wfes-btnrigth { justify-content: end !important; gap: 0 0.5rem; }
.o1 { order: 1;}
.o2 { order: 2;}
.o3 { order: 3;}
.bg_red { background-color: #f7c3c3;}
.bg_green { background-color: #b1ffb1;}
div.question-title.mb-1 { font-size: 1.25rem !important; line-height: 1.2rem;}
`;
// deaktiviert .wfes-linebreak { line-break: auto !important; }
// CSS by Alfonso-ML, posted on WDD
const alCssID = "wfes-alfonso";
const alStyle = `
.review-new > div:nth-child(1) > * {
flex-basis: 32%;
}
.review-new > div:nth-child(1) {
flex-direction: row !important;
grid-column: span 4;
display: flex;
flex-wrap: wrap;
gap: 0 0.2rem;
justify-content: space-between;
}
`;
const cardSelectors = ["app-photo-b > wf-review-card-b", "app-title-and-description-b > wf-review-card", "app-supporting-info-b > wf-review-card-b"];
const dupeSelector = "#check-duplicates-card";
const titleSelector = "#title-description-card > div.wf-review-card__body > div > a > div";
const descriptionSelector = "#title-description-card > div.wf-review-card__body > div > div";
const ccategorySelector = "app-review-categorization-b > wf-review-card > div.wf-review-card__header > div:nth-child(1) > h4";
const displayNoneSelectors = ["app-review-new-b > div > div:nth-child(1) > h4",
"app-review-new-b > div > div:nth-child(1) > p",
"app-review-new-b > div > div:nth-child(2) > h4",
"app-review-new-b > div > div:nth-child(2) > p"];
// const supportTextSel = "app-supporting-info-b > wf-review-card-b div.supporting-info-statement";
const qCardsSel = "app-question-card > div";
const qCardsBtnSel = "app-question-card button.dont-know-button";
const questionSel = "app-review-new-b > div > div.review-questions";
const mapSel = "app-review-new-b > div > div.review-questions";
const photoSel = "app-photo-b > wf-review-card-b div.wf-image-modal > img";
// const suppImgSel = "app-supporting-info-b > wf-review-card-b div.wf-image-modal.supporting-info-img-container > img";
const suppImgSel = "app-supporting-info-b > wf-review-card-b div.supporting-info-img-container img";
function reviewImproveCSS() {
window.wfes.f.addCSS(myCssId, myStyle);
window.wfes.f.addCSS(alCssID, alStyle);
cardSelectors.forEach(selector => {
window.wfes.f.waitForElem(selector).then((elem)=>{elem.classList.add("wfes-mh100p");})
.catch((e) => {console.warn(GM_info.script.name, ": ", e);});
// remove description texts
const seltext = selector + " > div.wf-review-card__header > div:nth-child(1) > div";
window.wfes.f.waitForElem(seltext).then((elem)=>{elem.classList.add("wfes-none");})
.catch((e) => {console.warn(GM_info.script.name, ": ", e);});
});
window.wfes.f.waitForElem(dupeSelector).then((elem)=>{elem.classList.add("wfes-h725");})
.catch((e) => {console.warn(GM_info.script.name, ": ", e);});
// smaller font site for title and description
window.wfes.f.waitForElem(titleSelector).then((elem)=>{elem.classList.add("wfes-text-4xl");})
.catch((e) => {console.warn(GM_info.script.name, ": ", e);});
window.wfes.f.waitForElem(descriptionSelector).then((elem)=>{elem.classList.add("wfes-text-lg");})
.catch((e) => {console.warn(GM_info.script.name, ": ", e);});
// remove card headers and descriptions
displayNoneSelectors.forEach(selector => {
window.wfes.f.waitForElem(selector).then((elem)=>{elem.classList.add("wfes-none");})
.catch((e) => {console.warn(GM_info.script.name, ": ", e);});
});
// "komische" Zelenumbrüche im Supporttext entfernen
/*
const pagedata = window.wfes.g.reviewPageData();
if (pagedata.statement.length < 256) {
// bei langen text gibt es den Unsinn nicht
window.wfes.f.waitForElem(supportTextSel)
.then((elem)=>{ elem.classList.add("wfes-linebreak");} )
.catch((e) => { console.warn(GM_info.script.name, "- support statement ", e); });
}
*/
// bilder etwas kleiner und zentriert
window.wfes.f.waitForElem(photoSel).then((elem) => {
elem.classList.add("wfes-photo");
elem.parentElement.setAttribute("style", "justify-content: center; display: flex;");
})
.catch((e) => {console.warn(GM_info.script.name, ": ", e);});
window.wfes.f.waitForElem(suppImgSel).then((elem) => {elem.classList.add("wfes-photo");})
.catch((e) => {console.warn(GM_info.script.name, ": ", e);});
// make all H4 smaller, wait for last box first
window.wfes.f.waitForElem(ccategorySelector).then(()=>{
const headerlist = document.querySelectorAll(".wf-review-card__header");
headerlist.forEach(elem =>{elem.classList.add("wfes-card__header");});
})
.catch((e) => {console.warn(GM_info.script.name, ": ", e);});
// question cards mit kleinerem Rand
window.wfes.f.waitForElem(questionSel).then(()=>{
const qCardList = document.querySelectorAll(qCardsSel);
qCardList.forEach(elem =>{
elem.classList.remove("p-4");
elem.classList.add("wfes-pad05");
});
const qCardBtnList = document.querySelectorAll(qCardsBtnSel);
qCardBtnList.forEach(elem =>{
elem.classList.add("wfes-pad05");
});
// buttons umsortieren
let buttonList = document.querySelectorAll("app-question-card > div > div > div.action-buttons-row");
buttonList.forEach(elem => {elem.classList.add("wfes-btnrigth");});
if (reorder_thumbs) {
buttonList = document.querySelectorAll("app-question-card > div > div > div.action-buttons-row > button:nth-child(1)");
buttonList.forEach(elem => {elem.classList.add("o3"); elem.classList.add("bg_green");});
buttonList = document.querySelectorAll("app-question-card > div > div > div.action-buttons-row > button:nth-child(2)");
buttonList.forEach(elem => {elem.classList.add("o2"); elem.classList.add("bg_red");});
buttonList = document.querySelectorAll("app-question-card > div > div > div.action-buttons-row > div");
buttonList.forEach(elem => {elem.classList.add("o1");});
}
})
.catch((e) => {console.warn(GM_info.script.name, ": ", e);});
// reorder main cards
window.wfes.f.waitForElem("app-title-and-description-b")
.then(elem=>{elem.classList.add("o2");})
.catch((e) => { console.warn(GM_info.script.name, "- reorder title ", e); });
window.wfes.f.waitForElem("app-photo-b")
.then(elem=>{elem.classList.add("o1"); elem.style.setProperty("margin-left", "0", "important");})
.catch((e) => { console.warn(GM_info.script.name, "- reorder photo ", e); });
window.wfes.f.waitForElem("app-supporting-info-b")
.then(elem=>{elem.classList.add("o3"); elem.style.setProperty("margin-left", "0", "important");})
.catch((e) => { console.warn(GM_info.script.name, "- reorder supporting info ", e); });
window.wfes.f.waitForElem(mapSel).then(elem => { elem.setAttribute("style", "grid-column: span 4;"); })
.catch((e) => {console.warn(GM_info.script.name, ": ", e);});
window.wfes.f.waitForElem("app-review-new-b > div").then(elem => { elem.classList.add("wfes-smallgap"); })
.catch((e) => {console.warn(GM_info.script.name, ": ", e);});
}
function editImproveCSS() {
// const abuseSelector = "div.report-abuse";
const mapSelector = "app-select-location-edit > wf-review-card > div.wf-review-card__body";
window.wfes.f.addCSS(myCssId, myStyle);
/*
window.wfes.f.waitForElem(abuseSelector).then((elem)=>{
elem.classList.add("wfes-fit-content");
elem.classList.add("wf-button");
});
*/
const edit = window.wfes.g.edit();
if (edit.isEdit && edit.what.location) {
window.wfes.f.waitForElem(mapSelector)
.then((elem)=>{ elem.classList.add("wfes-h490"); })
.catch((e) => { console.warn(GM_info.script.name, ": ", e); });
}
}
function init() {
window.addEventListener("WFESReviewPageNewLoaded", reviewImproveCSS);
window.addEventListener("WFESReviewPageEditLoaded", editImproveCSS);
}
init();
console.log("Script loaded:", GM_info.script.name, "v" + GM_info.script.version);
})();