Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
V2.1.0 merge
  • Loading branch information
shu8 committed Feb 24, 2018
2 parents 6afe06e + 987f45a commit 09b9671
Show file tree
Hide file tree
Showing 11 changed files with 1,178 additions and 467 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2016 soscripted
Copyright (c) 2018 soscripted

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[![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)

### SOX v2.0.2
### SOX v2.1.0

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.

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

## Installation & Requirements

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!
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!
2. Install the script. Clicking on 'install' below will make your userscript manager prompt you automatically to install it.

- 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>
Expand Down
12 changes: 6 additions & 6 deletions sox.common.info.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@
"Biblical Hermeneutics Meta": "meta.hermeneutics",
"History": "history",
"History Meta": "meta.history",
"LEGO&#174; Answers": "bricks",
"LEGO&#174; Answers Meta": "meta.bricks",
"LEGO® Answers": "bricks",
"LEGO® Answers Meta": "meta.bricks",
"Spanish Language": "spanish",
"Spanish Language Meta": "meta.spanish",
"Computational Science": "scicomp",
Expand Down Expand Up @@ -217,8 +217,8 @@
"Amateur Radio Meta": "meta.ham",
"Italian Language": "italian",
"Italian Language Meta": "meta.italian",
"Stack Overflow em Portugu&#234;s": "pt.stackoverflow",
"Stack Overflow em Portugu&#234;s Meta": "meta.pt.stackoverflow",
"Stack Overflow em Português": "pt.stackoverflow",
"Stack Overflow em Português Meta": "meta.pt.stackoverflow",
"Aviation": "aviation",
"Aviation Meta": "meta.aviation",
"Ebooks": "ebooks",
Expand Down Expand Up @@ -298,8 +298,8 @@
"Computer Graphics Meta": "meta.computergraphics",
"Hardware Recommendations": "hardwarerecs",
"Hardware Recommendations Meta": "meta.hardwarerecs",
"Stack Overflow en espa&#241;ol": "es.stackoverflow",
"Stack Overflow Meta en espa&#241;ol": "meta.es.stackoverflow",
"Stack Overflow en español": "es.stackoverflow",
"Stack Overflow Meta en español": "meta.es.stackoverflow",
"Documentation Beta": "docs-beta",
"3D Printing": "3dprinting",
"3D Printing Meta": "meta.3dprinting",
Expand Down
61 changes: 33 additions & 28 deletions sox.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
debugging: GM_getValue('SOX-debug', false)
};

sox.NEW_TOPBAR = location.href.indexOf('area51') === -1;

sox.debug = function() {
if(!sox.info.debugging) return;
if (!sox.info.debugging) return;
for (var arg = 0; arg < arguments.length; ++arg) {
console.debug('SOX: ', arguments[arg]);
}
Expand Down Expand Up @@ -42,13 +44,18 @@
};

//var Stack = (typeof StackExchange === "undefined" ? window.eval('if (typeof StackExchange != "undefined") StackExchange') : StackExchange) | undefined;
var Chat = (typeof CHAT === "undefined" ? window.eval("typeof CHAT != 'undefined' ? CHAT : undefined") : CHAT);
sox.debug(Chat);
var Stack = (typeof Chat === "undefined" ? (typeof StackExchange === "undefined" ? window.eval('if (typeof StackExchange != "undefined") StackExchange') : StackExchange) : undefined);
sox.debug(Stack);
var Chat, Stack;
if (location.href.indexOf('github.com') === -1) { //need this so it works on FF -- CSP blocks window.eval() it seems
Chat = (typeof CHAT === "undefined" ? window.eval("typeof CHAT != 'undefined' ? CHAT : undefined") : CHAT);
sox.debug(Chat);
Stack = (typeof Chat === "undefined" ? (typeof StackExchange === "undefined" ? window.eval('if (typeof StackExchange != "undefined") StackExchange') : StackExchange) : undefined);
sox.debug(Stack);
}

sox.Stack = Stack;

sox.exists = function(path) {
if(!Stack) return false;
if (!Stack) return false;
var toCheck = path.split('.'),
cont = true,
o = Stack,
Expand Down Expand Up @@ -101,7 +108,7 @@
var keys = GM_listValues();
for (var i = 0; i < keys.length; i++) {
var key = keys[i];
if(hideAccessToken && key == 'SOX-accessToken') {
if (hideAccessToken && key == 'SOX-accessToken') {
sox.loginfo('access token set');
} else {
sox.loginfo(key, GM_getValue(key));
Expand All @@ -120,6 +127,12 @@
success: function(d) {
if (d.backoff) {
sox.error('SOX Error: BACKOFF: ' + d.backoff);
} else if (d.error_id == 502) {
sox.error('THROTTLE VIOLATION', d);
} else if (d.error_id == 403) {
sox.warn('Access token invalid! Opening window to get new one');
window.open('https://stackexchange.com/oauth/dialog?client_id=7138&scope=no_expiry&redirect_uri=http://soscripted.github.io/sox/');
alert('Your access token is no longer valid. A window has been opened to request a new one.');
} else {
callback(d);
}
Expand All @@ -131,22 +144,13 @@
},
observe: function(elements, callback, toObserve) {
sox.debug('observe: ' + elements);
sox.debug(toObserve);
var observer = new MutationObserver(function(mutations, observer) {
for (var i = 0; i < mutations.length; i++) {
for (var a = 0; a < mutations[i].addedNodes.length; a++) {
var $a = $(mutations[i].addedNodes[a]);
if ($a && $a.is((Array.isArray(elements) ? elements.join(',') : elements))) {
callback(mutations[i].addedNodes[a]);
sox.debug('fire (added): ' + elements);
}
}
for (var r = 0; r < mutations[i].removedNodes.length; r++) {
var $r = $(mutations[i].removedNodes[r]);
if ($r && $r.is((Array.isArray(elements) ? elements.join(',') : elements))) {
callback(mutations[i].addedNodes[r]);
sox.debug('fire (removed): ' + elements);
}
//sox.debug($(mutations[i].target));
if ($(mutations[i].target).is(elements)) {
callback(mutations[i].target);
sox.debug('fire: target: ', mutations[i].target);
return;
}
}
});
Expand Down Expand Up @@ -234,7 +238,7 @@
apiParameter: function(siteName) {
if (commonInfo.apiParameters.hasOwnProperty(siteName)) {
return commonInfo.apiParameters[siteName];
} else if(sox.location.on('area51')) {
} else if (sox.location.on('area51')) {
return 'area51';
}
},
Expand All @@ -244,7 +248,7 @@
}
},
get currentApiParameter() {
return this.apiParameter(this.name);
return this.apiParameter(this.name || (location.href.indexOf('stackapps.com/') > -1 ? "Stack Apps" : undefined));
},
get icon() {
return "favicon-" + $(".current-site a:not([href*='meta']) .site-icon").attr('class').split('favicon-')[1];
Expand All @@ -265,11 +269,11 @@
return this.on('/questions/');
},
matchWithPattern: function(pattern, urlToMatchWith) { //commented version @ https://jsfiddle.net/shub01/t90kx2dv/
if(pattern == 'SE1.0') { //SE.com && Area51.SE.com special checking
if(urlToMatchWith) {
if(urlToMatchWith.match(/https?:\/\/stackexchange\.com\/?/) || sox.location.matchWithPattern('*://area51.stackexchange.com/*')) return true;
if (pattern == 'SE1.0') { //SE.com && Area51.SE.com special checking
if (urlToMatchWith) {
if (urlToMatchWith.match(/https?:\/\/stackexchange\.com\/?/) || sox.location.matchWithPattern('*://area51.stackexchange.com/*')) return true;
} else {
if(location.href.match(/https?:\/\/stackexchange\.com\/?/) || sox.location.matchWithPattern('*://area51.stackexchange.com/*')) return true;
if (location.href.match(/https?:\/\/stackexchange\.com\/?/) || sox.location.matchWithPattern('*://area51.stackexchange.com/*')) return true;
}
return false;
}
Expand Down Expand Up @@ -320,7 +324,8 @@
if (sox.site.type == sox.site.types.chat) {
return Chat.RoomUsers.current().name;
} else {
return Stack && this.loggedIn ? decodeURI(Stack.options.user.profileUrl.split('/')[5]) : undefined;
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');
return ($uname.length ? $uname.attr('title') : false);
}
},
get loggedIn() {
Expand Down
Loading

0 comments on commit 09b9671

Please sign in to comment.