Skip to content

Commit 09b9671

Browse files
committed
Merge branch 'dev'
V2.1.0 merge
2 parents 6afe06e + 987f45a commit 09b9671

11 files changed

+1178
-467
lines changed

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2016 soscripted
3+
Copyright (c) 2018 soscripted
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[![Join the chat at https://gitter.im/soscripted/sox](https://badges.gitter.im/soscripted/sox.svg)](https://gitter.im/soscripted/sox?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
22

3-
### SOX v2.0.2
3+
### SOX v2.1.0
44

55
Stack Overflow Extras (*SOX*) is a project that stemmed from the [Stack Overflow Optional Features (SOOF)](https://github.com/shu8/Stack-Overflow-Optional-Features) project.
66

@@ -10,7 +10,7 @@ Note: This project has no relation to Stack Overflow or Stack Exchange; it is si
1010

1111
## Installation & Requirements
1212

13-
1. Install [Greasemonkey](http://www.greasespot.net/) (for Firefox), [Tampermonkey](http://tampermonkey.net/) (for Chrome), or [NinjaKit](https://github.com/os0x/NinjaKit) for Safari. These are userscript managers that *must* be installed in order for this to work, as the script relies on certain `GM_*` functions in order to save your settings!
13+
1. Install [Greasemonkey](http://www.greasespot.net/) (for Firefox) or [Tampermonkey](http://tampermonkey.net/) (for Chrome or Safari). These are userscript managers that *must* be installed in order for this to work, as the script relies on certain `GM_*` functions in order to save your settings!
1414
2. Install the script. Clicking on 'install' below will make your userscript manager prompt you automatically to install it.
1515

1616
- Official Version: <kbd>[install](https://github.com/soscripted/sox/raw/v2.0.2/sox.user.js)</kbd>. <kbd>[view source](https://github.com/soscripted/sox/blob/v2.0.2/sox.user.js)</kbd>

sox.common.info.json

+6-6
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,8 @@
127127
"Biblical Hermeneutics Meta": "meta.hermeneutics",
128128
"History": "history",
129129
"History Meta": "meta.history",
130-
"LEGO&#174; Answers": "bricks",
131-
"LEGO&#174; Answers Meta": "meta.bricks",
130+
"LEGO® Answers": "bricks",
131+
"LEGO® Answers Meta": "meta.bricks",
132132
"Spanish Language": "spanish",
133133
"Spanish Language Meta": "meta.spanish",
134134
"Computational Science": "scicomp",
@@ -217,8 +217,8 @@
217217
"Amateur Radio Meta": "meta.ham",
218218
"Italian Language": "italian",
219219
"Italian Language Meta": "meta.italian",
220-
"Stack Overflow em Portugu&#234;s": "pt.stackoverflow",
221-
"Stack Overflow em Portugu&#234;s Meta": "meta.pt.stackoverflow",
220+
"Stack Overflow em Português": "pt.stackoverflow",
221+
"Stack Overflow em Português Meta": "meta.pt.stackoverflow",
222222
"Aviation": "aviation",
223223
"Aviation Meta": "meta.aviation",
224224
"Ebooks": "ebooks",
@@ -298,8 +298,8 @@
298298
"Computer Graphics Meta": "meta.computergraphics",
299299
"Hardware Recommendations": "hardwarerecs",
300300
"Hardware Recommendations Meta": "meta.hardwarerecs",
301-
"Stack Overflow en espa&#241;ol": "es.stackoverflow",
302-
"Stack Overflow Meta en espa&#241;ol": "meta.es.stackoverflow",
301+
"Stack Overflow en español": "es.stackoverflow",
302+
"Stack Overflow Meta en español": "meta.es.stackoverflow",
303303
"Documentation Beta": "docs-beta",
304304
"3D Printing": "3dprinting",
305305
"3D Printing Meta": "meta.3dprinting",

sox.common.js

+33-28
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@
1010
debugging: GM_getValue('SOX-debug', false)
1111
};
1212

13+
sox.NEW_TOPBAR = location.href.indexOf('area51') === -1;
14+
1315
sox.debug = function() {
14-
if(!sox.info.debugging) return;
16+
if (!sox.info.debugging) return;
1517
for (var arg = 0; arg < arguments.length; ++arg) {
1618
console.debug('SOX: ', arguments[arg]);
1719
}
@@ -42,13 +44,18 @@
4244
};
4345

4446
//var Stack = (typeof StackExchange === "undefined" ? window.eval('if (typeof StackExchange != "undefined") StackExchange') : StackExchange) | undefined;
45-
var Chat = (typeof CHAT === "undefined" ? window.eval("typeof CHAT != 'undefined' ? CHAT : undefined") : CHAT);
46-
sox.debug(Chat);
47-
var Stack = (typeof Chat === "undefined" ? (typeof StackExchange === "undefined" ? window.eval('if (typeof StackExchange != "undefined") StackExchange') : StackExchange) : undefined);
48-
sox.debug(Stack);
47+
var Chat, Stack;
48+
if (location.href.indexOf('github.com') === -1) { //need this so it works on FF -- CSP blocks window.eval() it seems
49+
Chat = (typeof CHAT === "undefined" ? window.eval("typeof CHAT != 'undefined' ? CHAT : undefined") : CHAT);
50+
sox.debug(Chat);
51+
Stack = (typeof Chat === "undefined" ? (typeof StackExchange === "undefined" ? window.eval('if (typeof StackExchange != "undefined") StackExchange') : StackExchange) : undefined);
52+
sox.debug(Stack);
53+
}
54+
55+
sox.Stack = Stack;
4956

5057
sox.exists = function(path) {
51-
if(!Stack) return false;
58+
if (!Stack) return false;
5259
var toCheck = path.split('.'),
5360
cont = true,
5461
o = Stack,
@@ -101,7 +108,7 @@
101108
var keys = GM_listValues();
102109
for (var i = 0; i < keys.length; i++) {
103110
var key = keys[i];
104-
if(hideAccessToken && key == 'SOX-accessToken') {
111+
if (hideAccessToken && key == 'SOX-accessToken') {
105112
sox.loginfo('access token set');
106113
} else {
107114
sox.loginfo(key, GM_getValue(key));
@@ -120,6 +127,12 @@
120127
success: function(d) {
121128
if (d.backoff) {
122129
sox.error('SOX Error: BACKOFF: ' + d.backoff);
130+
} else if (d.error_id == 502) {
131+
sox.error('THROTTLE VIOLATION', d);
132+
} else if (d.error_id == 403) {
133+
sox.warn('Access token invalid! Opening window to get new one');
134+
window.open('https://stackexchange.com/oauth/dialog?client_id=7138&scope=no_expiry&redirect_uri=http://soscripted.github.io/sox/');
135+
alert('Your access token is no longer valid. A window has been opened to request a new one.');
123136
} else {
124137
callback(d);
125138
}
@@ -131,22 +144,13 @@
131144
},
132145
observe: function(elements, callback, toObserve) {
133146
sox.debug('observe: ' + elements);
134-
sox.debug(toObserve);
135147
var observer = new MutationObserver(function(mutations, observer) {
136148
for (var i = 0; i < mutations.length; i++) {
137-
for (var a = 0; a < mutations[i].addedNodes.length; a++) {
138-
var $a = $(mutations[i].addedNodes[a]);
139-
if ($a && $a.is((Array.isArray(elements) ? elements.join(',') : elements))) {
140-
callback(mutations[i].addedNodes[a]);
141-
sox.debug('fire (added): ' + elements);
142-
}
143-
}
144-
for (var r = 0; r < mutations[i].removedNodes.length; r++) {
145-
var $r = $(mutations[i].removedNodes[r]);
146-
if ($r && $r.is((Array.isArray(elements) ? elements.join(',') : elements))) {
147-
callback(mutations[i].addedNodes[r]);
148-
sox.debug('fire (removed): ' + elements);
149-
}
149+
//sox.debug($(mutations[i].target));
150+
if ($(mutations[i].target).is(elements)) {
151+
callback(mutations[i].target);
152+
sox.debug('fire: target: ', mutations[i].target);
153+
return;
150154
}
151155
}
152156
});
@@ -234,7 +238,7 @@
234238
apiParameter: function(siteName) {
235239
if (commonInfo.apiParameters.hasOwnProperty(siteName)) {
236240
return commonInfo.apiParameters[siteName];
237-
} else if(sox.location.on('area51')) {
241+
} else if (sox.location.on('area51')) {
238242
return 'area51';
239243
}
240244
},
@@ -244,7 +248,7 @@
244248
}
245249
},
246250
get currentApiParameter() {
247-
return this.apiParameter(this.name);
251+
return this.apiParameter(this.name || (location.href.indexOf('stackapps.com/') > -1 ? "Stack Apps" : undefined));
248252
},
249253
get icon() {
250254
return "favicon-" + $(".current-site a:not([href*='meta']) .site-icon").attr('class').split('favicon-')[1];
@@ -265,11 +269,11 @@
265269
return this.on('/questions/');
266270
},
267271
matchWithPattern: function(pattern, urlToMatchWith) { //commented version @ https://jsfiddle.net/shub01/t90kx2dv/
268-
if(pattern == 'SE1.0') { //SE.com && Area51.SE.com special checking
269-
if(urlToMatchWith) {
270-
if(urlToMatchWith.match(/https?:\/\/stackexchange\.com\/?/) || sox.location.matchWithPattern('*://area51.stackexchange.com/*')) return true;
272+
if (pattern == 'SE1.0') { //SE.com && Area51.SE.com special checking
273+
if (urlToMatchWith) {
274+
if (urlToMatchWith.match(/https?:\/\/stackexchange\.com\/?/) || sox.location.matchWithPattern('*://area51.stackexchange.com/*')) return true;
271275
} else {
272-
if(location.href.match(/https?:\/\/stackexchange\.com\/?/) || sox.location.matchWithPattern('*://area51.stackexchange.com/*')) return true;
276+
if (location.href.match(/https?:\/\/stackexchange\.com\/?/) || sox.location.matchWithPattern('*://area51.stackexchange.com/*')) return true;
273277
}
274278
return false;
275279
}
@@ -320,7 +324,8 @@
320324
if (sox.site.type == sox.site.types.chat) {
321325
return Chat.RoomUsers.current().name;
322326
} else {
323-
return Stack && this.loggedIn ? decodeURI(Stack.options.user.profileUrl.split('/')[5]) : undefined;
327+
var $uname = sox.NEW_TOPBAR ? $('body > header > div > div.-actions > a > div.gravatar-wrapper-24') : $('body > div.topbar > div > div.topbar-links > a > div.gravatar-wrapper-24');
328+
return ($uname.length ? $uname.attr('title') : false);
324329
}
325330
},
326331
get loggedIn() {

0 commit comments

Comments
 (0)