-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathhfr_signature_oui_non.user.js
More file actions
211 lines (194 loc) · 11.6 KB
/
Copy pathhfr_signature_oui_non.user.js
File metadata and controls
211 lines (194 loc) · 11.6 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
// ==UserScript==
// @name [HFR] Signature oui non
// @version 1.1.5
// @namespace roger21.free.fr
// @description Permet de forcer ou de désactiver la signature en fonction du topic.
// @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAAAilBMVEX%2F%2F%2F8AAADxjxvylSrzmzf5wYLzmjb%2F9er%2F%2Fv70nj32q1b5woT70qT82rT827b%2F%2B%2FjxkSHykybykyfylCjylCnzmDDzmjX0nTv1o0b1qFH2qVL2qlT3tGn4tmz4uHD4uXL5vHf83Lf83Lj937394MH%2B587%2B69f%2F8%2BX%2F8%2Bf%2F9On%2F9uz%2F%2BPH%2F%2BvT%2F%2FPmRE1AgAAAAwElEQVR42s1SyRbCIAysA7W2tdZ93%2Ff1%2F39PEtqDEt6rXnQOEMhAMkmC4E9QY9j9da1OkP%2BtTiBo1caOjGisDLRDANCk%2FVIHwwkBZGReh9avnGj2%2FWFg%2Feg5hD1bLZTwqdgU%2FlTSdrqZJWN%2FKImPOnGjiBJKhYqMvikxtlhLNTuz%2FgkxjmJRRza5mbcXpbz4zldLJ0lVEBY5nRL4CJx%2FMEfXE4L9j4Qr%2BZakpiandMpX6FO7%2FaPxxUTJI%2FsJ4cd4AoSOBgZnPvgtAAAAAElFTkSuQmCC
// @include https://forum.hardware.fr/forum2.php*
// @include https://forum.hardware.fr/hfr/*/*-sujet_*_*.htm*
// @include https://forum.hardware.fr/message.php*
// @author roger21
// @updateURL https://raw.githubusercontent.com/roger21/hfr/master/hfr_signature_oui_non.user.js
// @installURL https://raw.githubusercontent.com/roger21/hfr/master/hfr_signature_oui_non.user.js
// @downloadURL https://raw.githubusercontent.com/roger21/hfr/master/hfr_signature_oui_non.user.js
// @supportURL https://forum.hardware.fr/hfr/Discussions/Viepratique/sujet_116015_1.htm
// @homepageURL http://roger21.free.fr/hfr/
// @noframes
// @grant GM.deleteValue
// @grant GM_deleteValue
// @grant GM.getValue
// @grant GM_getValue
// @grant GM.setValue
// @grant GM_setValue
// ==/UserScript==
/*
Copyright © 2012, 2014-2015, 2017-2020 roger21@free.fr
This program is free software: you can redistribute it and/or modify it under the
terms of the GNU Affero General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License along
with this program. If not, see <https://www.gnu.org/licenses/agpl.txt>.
*/
// $Rev: 1590 $
// historique :
// 1.1.5 (13/02/2020) :
// - utilisation d'une url en data pour l'icône du script et changement d'hébergeur (free.fr -> github.com)
// 1.1.4 (02/10/2019) :
// - suppression de la directive "@inject-into" (mauvaise solution, changer solution)
// - correction de la gestion de la compatibilité gm4 (pour violentmonkey)
// 1.1.3 (18/09/2019) :
// - ajout de la directive "@inject-into content" pour isoler le script sous violentmonkey
// 1.1.2 (29/11/2018) :
// - ajout de l'avis de licence AGPL v3+
// 1.1.1 (09/09/2018) :
// - correction de l'utilisation de GM.getValue (inutilement complexe ici)
// 1.1.0 (12/08/2018) :
// - nouveau nom : [HFR] signature oui non -> [HFR] Signature oui non
// - gestion de la compatibilité gm4
// - amélioration des @include
// - améliorations diverses du code
// - ajout de la metadata @author (roger21)
// - maj de la metadata @homepageURL
// - reformatage du code (Online JavaScript beautifier : ->
// "2 spaces, unlimited newlines, do not wrap, braces with" et rien coché)
// - check du code dans tm
// 1.0.6 (28/11/2017) :
// - passage au https
// 1.0.5 (07/03/2015) :
// - ajout de la metadata @noframes (interdit l'execution du script dans une frame pour plus de sécurité)
// 1.0.4 (04/04/2014) :
// - modification de la description
// - ajout d'une icone au script
// - suppression d'un warning (bad code is bad)
// 1.0.3 (23/03/2014) :
// - ajout des dates dans l'historique
// 1.0.2 (18/03/2014) :
// - maj des metadata @grant et indentation des metadata
// 1.0.1 (14/09/2012) :
// - ajout des metadata @grant
if(typeof GM === "undefined") {
this.GM = {};
}
if(typeof GM_deleteValue !== "undefined" && typeof GM.deleteValue === "undefined") {
GM.deleteValue = function(...args) {
return new Promise((resolve, reject) => {
try {
resolve(GM_deleteValue.apply(null, args));
} catch (e) {
reject(e);
}
});
};
}
if(typeof GM_getValue !== "undefined" && typeof GM.getValue === "undefined") {
GM.getValue = function(...args) {
return new Promise((resolve, reject) => {
try {
resolve(GM_getValue.apply(null, args));
} catch (e) {
reject(e);
}
});
};
}
if(typeof GM_setValue !== "undefined" && typeof GM.setValue === "undefined") {
GM.setValue = function(...args) {
return new Promise((resolve, reject) => {
try {
resolve(GM_setValue.apply(null, args));
} catch (e) {
reject(e);
}
});
};
}
var blanc = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8%2F9hAAAAAXNSR0IArs4c6QAAAa5JREFUOMutk7%2Fr2lAUxT%2BmmaSCTg4KQczgKP6YhA4ZlYBO8i1CcMns4tZOrY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OLrutNpdbW%2B78UhXTtiwLIx%2BN8jUQAXkop31wVpilgXfF9rgnTWeUr0%2Fg%2Fcf4DKVnL06S3U1YAAAAASUVORK5CYII%3D";
if(document.forms.namedItem("hop") &&
document.forms.namedItem("hop").elements.namedItem("cat") &&
document.forms.namedItem("hop").elements.namedItem("post")) {
var cat = document.forms.namedItem("hop").elements.namedItem("cat").value;
var topic = document.forms.namedItem("hop").elements.namedItem("post").value;
GM.getValue(cat + "." + topic, null).then(function(ouinon) {
if(window.location.pathname !== "/message.php") {
let profil = document.forms.namedItem("hop").elements.namedItem("signature").value;
let toolbar = document.querySelector("table.main tr th div.right");
if(toolbar) {
let bouton = document.createElement("img");
if(ouinon === null) {
bouton.src = blanc;
bouton.setAttribute("calimero", "blanc");
bouton.title = "La signature est affichée selon les préférences du profil.";
} else if(ouinon === "oui") {
bouton.src = vert;
bouton.setAttribute("calimero", "vert");
bouton.title = "La signature est toujours affichée sur ce topic.";
} else if(ouinon === "non") {
bouton.src = rouge;
bouton.setAttribute("calimero", "rouge");
bouton.title = "La signature n'est jamais affichée sur ce topic.";
}
bouton.style.cursor = "pointer";
bouton.style.marginRight = "5px";
bouton.addEventListener("click", function(bouton, profil) {
return function() {
if(bouton.getAttribute("calimero") === "blanc") {
bouton.src = vert;
bouton.setAttribute("calimero", "vert");
bouton.title = "La signature est toujours affichée sur ce topic.";
document.forms.namedItem("hop").elements.namedItem("signature").value = 1;
GM.setValue(cat + "." + topic, "oui");
} else if(bouton.getAttribute("calimero") === "vert") {
bouton.src = rouge;
bouton.setAttribute("calimero", "rouge");
bouton.title = "La signature n'est jamais affichée sur ce topic.";
document.forms.namedItem("hop").elements.namedItem("signature").value = 0;
GM.setValue(cat + "." + topic, "non");
} else if(bouton.getAttribute("calimero") === "rouge") {
bouton.src = blanc;
bouton.setAttribute("calimero", "blanc");
bouton.title = "La signature est affichée selon les préférences du profil.";
document.forms.namedItem("hop").elements.namedItem("signature").value = profil;
GM.deleteValue(cat + "." + topic);
}
}
}(bouton, profil), false);
let mycrub = document.createElement("div");
mycrub.className = "right";
mycrub.appendChild(bouton);
toolbar.insertBefore(mycrub, toolbar.lastChild);
}
}
if(ouinon !== null) {
if(window.location.pathname === "/message.php") {
if(ouinon === "non") {
document.getElementById("signature").checked = false;
let labelo = document.createElement("span");
labelo.appendChild(document.createTextNode(" (désactivé par le script [HFR] Signature oui non)"));
document.getElementById("signature").
parentNode.insertBefore(labelo, document.getElementById("signature")
.nextElementSibling.nextElementSibling);
}
if(ouinon === "oui") {
document.getElementById("signature").checked = true;
let labelo = document.createElement("span");
labelo.appendChild(document.createTextNode(" (forcé par le script [HFR] Signature oui non)"));
document.getElementById("signature").
parentNode.insertBefore(labelo, document.getElementById("signature")
.nextElementSibling.nextElementSibling);
}
} else {
if(ouinon === "non") {
document.forms.namedItem("hop").elements.namedItem("signature").value = 0;
}
if(ouinon === "oui") {
document.forms.namedItem("hop").elements.namedItem("signature").value = 1;
}
}
}
});
}