-
Notifications
You must be signed in to change notification settings - Fork 0
/
mpa.js
195 lines (165 loc) · 6.5 KB
/
mpa.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
188
189
190
191
192
193
194
195
// ==UserScript==
// @name Meneame personal assistant
// @namespace http://dsmatilla.com
// @author @dsmatilla
// @version 1.4.3
// @description Menú con varias funcionalidades para mejorar la experiencia de usuario en meneame.net
// @include https://*.meneame.net/*
// @grant GM_getValue
// @grant GM_setValue
// @downloadURL http://dsmatilla.com/scripts/mpa.js
// @updateURL http://dsmatilla.com/scripts/mpa.js
// @copyright 2013 Este script está protegido por la GFYL 1.00
// The Go Fuck Yourself Public License, version 1.00
//
// Article 1
// You can go fuck yourself.
//
// END OF ALL TERMS AND CONDITIONS
// ==/UserScript==
function mhMenu() { // Build HTML structure
// Set div attributes
var button, div, html, chkd, x, i;
// Menu title to open/close
button = document.createElement("div");
button.setAttribute("id", "mh_button");
button.className = "mh_button";
button.style.display = "block";
button.style.border = "0";
button.style.position = "absolute";
button.style.top = "0";
button.style.right = "300px";
button.style.height = "17px";
button.style.padding = "4px";
html = "<a id='mh_close' style='color: white; text-decoration: none;'>MNM Asistente personal</a>";
button.innerHTML = html;
document.getElementById('header-top').appendChild(button);
document.getElementById("mh_close").addEventListener("click", mhSwitchVisibility, true);
// Menu
div = document.createElement("div");
div.setAttribute("id", "mh_menu");
div.className = "mh_menu";
div.style.display = "block";
div.style.border = "0";
div.style.position = "fixed";
div.style.top = "120px";
div.style.right = "20px";
// Create inner html
html = "";
html += "<fieldset>";
html += "<label>MNM Asistente personal</label>";
html += "<form id='mhForm'>";
// Switch position
if(GM_getValue('mh_switchposition')) { chkd="checked"; } else { chkd=""; }
html += "<br /><input type='checkbox' id='mh_switchposition' " + chkd + "/> Cambiar posición";
// Hide blank
if(GM_getValue('mh_hideblank')) { chkd="checked"; } else { chkd=""; }
html += "<br /><input type='checkbox' id='mh_hideblank' " + chkd + "/> Ocultar blanqueados";
// Fixed top bar
if(GM_getValue('mh_fixedtopbar')) { chkd="checked"; } else { chkd=""; }
html += "<br /><input type='checkbox' id='mh_fixedtopbar' " + chkd + "/> Menú estático";
// Neutral mode
if(GM_getValue('mh_neutralmode')) { chkd="checked"; } else { chkd=""; }
html += "<br /><input type='checkbox' id='mh_neutralmode' " + chkd + "/> Modo neutral";
// Disable rounded avatars
if(GM_getValue('mh_roundedavatars')) { chkd="checked"; } else { chkd=""; }
html += "<br /><input type='checkbox' id='mh_roundedavatars' " + chkd + "/> Quitar avatares redondos";
html += "</form>";
html += "<br /><span style='float:right; font-size: 0.7em;'>Bugs y sugerencias - <a href='http://meneame.net/user/RickDeckard'>@RickDeckard</a></span>";
html += "<br /><span style='float:right; font-size: 0.7em;'><a target='_blank' href='http://twitter.com/dsmatilla'>@dsmatilla</a></span>";
html += "</fieldset>";
// Display div
div.innerHTML = html;
document.body.appendChild(div);
// Add listener to each checkbox in mhForm
x=document.getElementById("mhForm");
for (i=0;i<x.length;i++) {
x.elements[i].addEventListener("click", mhActions, true);
}
}
function mhActions() { // Perform actions
var i, com, x;
// Save form values
x=document.getElementById('mhForm');
for (i=0;i<x.length;i++) {
GM_setValue(x.elements[i].id, x.elements[i].checked);
}
// Menu visibility
document.getElementById('mh_menu').style.display = GM_getValue('mh_menu_display');
// Switch menu position
if(GM_getValue('mh_switchposition')) {
com = document.getElementById("mh_menu");
com.style.left = '';
com.style.right = '20px';
} else {
com = document.getElementById("mh_menu");
com.style.right = '';
com.style.left = '20px';
}
// Hide blank
if(GM_getValue('mh_hideblank')) {
com = document.getElementsByClassName("hidden");
for (i=0; i<com.length; i++) { com[i].style.display = 'none'; }
} else {
com = document.getElementsByClassName("hidden");
for (i=0; i<com.length; i++) { com[i].style.display = 'block'; }
}
// fixed top bar
if(GM_getValue('mh_fixedtopbar')) {
com = document.getElementById("header");
com.style.position = 'fixed';
com.style.zIndex = 10;
com = document.getElementById("container");
com.style.marginTop = '105px';
document.getElementById("notifier").addEventListener("click", mhChangeNotifierPanel, true);
} else {
com = document.getElementById("header");
com.style.position = null;
com.style.zIndex = null;
com = document.getElementById("container");
com.style.marginTop = '0';
document.getElementById("notifier").removeEventListener("click", mhChangeNotifierPanel, true);
}
// Neutral mode
if(GM_getValue('mh_neutralmode')) {
com = document.getElementsByClassName("comment-info");
for (i=0; i<com.length; i++) { com[i].style.display = 'none'; }
com = document.getElementsByClassName("avatar");
for (i=0; i<com.length; i++) { com[i].style.display = 'none'; }
} else {
com = document.getElementsByClassName("comment-info");
for (i=0; i<com.length; i++) { com[i].style.display = null; }
com = document.getElementsByClassName("avatar");
for (i=0; i<com.length; i++) { com[i].style.display = null; }
}
// Disable rounded avatars
if(GM_getValue('mh_roundedavatars')) {
com = document.getElementsByClassName("avatar");
for (i=0; i<com.length; i++) { com[i].style.borderRadius = '0em'; }
for (i=0; i<com.length; i++) { com[i].style.MozBorderRadius = '0em'; }
for (i=0; i<com.length; i++) { com[i].style.WebkitBorderRadius = '0em'; }
} else {
com = document.getElementsByClassName("avatar");
for (i=0; i<com.length; i++) { com[i].style.borderRadius = '50%'; }
for (i=0; i<com.length; i++) { com[i].style.MozBorderRadius = '50%'; }
for (i=0; i<com.length; i++) { com[i].style.WebkitBorderRadius = '50%'; }
}
}
// Misc functions
function mhSwitchVisibility() {
if(document.getElementById("mh_menu").style.display == 'none') {
document.getElementById("mh_menu").style.display = 'block';
GM_setValue("mh_menu_display", 'block');
} else {
document.getElementById('mh_menu').style.display = 'none';
GM_setValue('mh_menu_display', 'none');
}
}
function mhChangeNotifierPanel() {
document.getElementById('notifier_panel').style.zIndex = 12;
document.getElementById('notifier_panel').style.position = 'fixed';
}
// Display menu & others
mhMenu();
// Perform actions
mhActions();