diff --git a/Chrome/background.js b/Chrome/background.js index a5f580b597..8caa683516 100644 --- a/Chrome/background.js +++ b/Chrome/background.js @@ -90,6 +90,13 @@ XHRCache = { chrome.extension.onMessage.addListener( function(request, sender, sendResponse) { switch(request.requestType) { + case 'deleteCookie': + // Get chrome cookie handler + if (!chrome.cookies) { + chrome.cookies = chrome.experimental.cookies; + } + chrome.cookies.remove({'url': 'http://reddit.com', 'name': request.cname}); + break; case 'GM_xmlhttpRequest': if (request.aggressiveCache || XHRCache.forceCache) { var cachedResult = XHRCache.check(request.url); @@ -98,12 +105,11 @@ chrome.extension.onMessage.addListener( return; } } + var xhr = new XMLHttpRequest(); xhr.open(request.method, request.url, true); if (request.method == "POST") { xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); - // xhr.setRequestHeader("Content-length", request.data.length); - // xhr.setRequestHeader("Connection", "close"); } xhr.onreadystatechange = function(a) { if (xhr.readyState == 4) { diff --git a/Chrome/manifest.json b/Chrome/manifest.json index 0e31e2dd3f..65bec649e4 100644 --- a/Chrome/manifest.json +++ b/Chrome/manifest.json @@ -36,6 +36,7 @@ "128": "icon128.png" }, "permissions": [ + "cookies", "tabs", "history", "http://redditenhancementsuite.com/", diff --git a/XPI/lib/main.js b/XPI/lib/main.js index 8ff6d336f4..62e8653c24 100644 --- a/XPI/lib/main.js +++ b/XPI/lib/main.js @@ -7,16 +7,14 @@ var tabs = require("tabs"); var ss = require("simple-storage"); // require chrome allows us to use XPCOM objects... -// var {Cc, Cu, Cr} = require("chrome"); -const {Cc,Ci} = require("chrome"); -// from XPCOM, use the NSIGlobalHistory2 service... -// var historyService = Cc["@mozilla.org/browser/nav-history-service;1"].getService(Ci.nsIGlobalHistory2); -var historyService = Cc["@mozilla.org/browser/global-history;2"].getService(Ci.nsIGlobalHistory2) +const {Cc,Ci,Cu} = require("chrome"); +var historyService = Cc["@mozilla.org/browser/global-history;2"].getService(Ci.nsIGlobalHistory2); +// Cookie manager for new API login +var cookieManager = Cc["@mozilla.org/cookiemanager;1"].getService().QueryInterface(Ci.nsICookieManager2); // this function takes in a string (and optional charset, paseURI) and creates an nsURI object, which is required by historyService.addURI... function makeURI(aURL, aOriginCharset, aBaseURI) { - var ioService = Cc["@mozilla.org/network/io-service;1"] - .getService(Ci.nsIIOService); + var ioService = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService); return ioService.newURI(aURL, aOriginCharset, aBaseURI); } @@ -129,6 +127,9 @@ pageMod.PageMod({ worker.on('message', function(data) { var request = data; switch(request.requestType) { + case 'deleteCookie': + cookieManager.remove('.reddit.com', request.cname, '/', false); + break; case 'GM_xmlhttpRequest': var responseObj = { XHRID: request.XHRID, diff --git a/lib/reddit_enhancement_suite.user.js b/lib/reddit_enhancement_suite.user.js index 765cd51c59..42e9628590 100644 --- a/lib/reddit_enhancement_suite.user.js +++ b/lib/reddit_enhancement_suite.user.js @@ -169,6 +169,10 @@ var BrowserDetect = { if (index == -1) return; return parseFloat(dataString.substring(index+this.versionSearchString.length+1)); }, + isChrome: function() { return typeof(chrome) !== 'undefined'; }, + isFirefox: function() { return typeof(self.on) === 'function'; }, + isOpera: function() { return typeof(opera) !== 'undefined'; }, + isSafari: function() { return typeof(safari) !== 'undefined'; }, dataBrowser: [ { string: navigator.userAgent, @@ -267,7 +271,7 @@ var safeJSON = { // if silent is specified, it will fail silently... parse: function(data, localStorageSource, silent) { try { - if (typeof(safari) != 'undefined') { + if (BrowserDetect.isSafari()) { if (data.substring(0,2) == 's{') { data = data.substring(1,data.length); } @@ -345,7 +349,7 @@ xhrQueue = { count: 0, onloads: [] }; // if this is a jetpack addon, add an event listener like Safari's message handler... -if (typeof(self.on) == 'function') { +if (BrowserDetect.isFirefox()) { self.on('message', function(msgEvent) { switch (msgEvent.name) { case 'GM_xmlhttpRequest': @@ -512,7 +516,7 @@ function operaMessageHandler(msgEvent) { } // listen for messages from chrome background page -if (typeof(chrome) != 'undefined') { +if (BrowserDetect.isChrome()) { chrome.extension.onMessage.addListener( function(request, sender, sendResponse) { switch(request.requestType) { @@ -527,7 +531,7 @@ if (typeof(chrome) != 'undefined') { ); } -if (typeof(safari) != 'undefined') { +if (BrowserDetect.isSafari()) { // Safari has a ridiculous bug that causes it to lose access to safari.self.tab if you click the back button. // this stupid one liner fixes that. window.onunload = function(){}; @@ -536,7 +540,7 @@ if (typeof(safari) != 'undefined') { // we can't do this check for opera here because we need to wait until DOMContentLoaded is triggered, I think. Putting this in RESinit(); // opera compatibility -if (typeof(opera) != 'undefined') { +if (BrowserDetect.isOpera()) { // removing this line for new localStorage methodology (store in extension localstorage) sessionStorage = window.sessionStorage; localStorage = window.localStorage; @@ -546,7 +550,7 @@ if (typeof(opera) != 'undefined') { // Firebug stopped showing console.log for some reason. Need to use unsafeWindow if available. Not sure if this was due to a Firebug version update or what. if (typeof(unsafeWindow) != 'undefined') { - if ((typeof(unsafeWindow.console) != 'undefined') && (typeof(self.on) != 'function')) { + if ((typeof(unsafeWindow.console) != 'undefined') && (!BrowserDetect.isFirefox())) { console = unsafeWindow.console; } else if (typeof(console) == 'undefined') { console = { @@ -629,7 +633,7 @@ if ((typeof GM_deleteValue == 'undefined') || (typeof GM_addStyle == 'undefined' } } - if (typeof(chrome) != 'undefined') { + if (BrowserDetect.isChrome()) { GM_xmlhttpRequest = function(obj) { var crossDomain = (obj.url.indexOf(location.hostname) == -1); @@ -649,7 +653,7 @@ if ((typeof GM_deleteValue == 'undefined') || (typeof GM_addStyle == 'undefined' request.send(obj.data); return request; } } - } else if (typeof(safari) != 'undefined') { + } else if (BrowserDetect.isSafari()) { GM_xmlhttpRequest = function(obj) { obj.requestType = 'GM_xmlhttpRequest'; // Since Safari doesn't provide legitimate callbacks, I have to store the onload function here in the main @@ -674,7 +678,7 @@ if ((typeof GM_deleteValue == 'undefined') || (typeof GM_addStyle == 'undefined' request.send(obj.data); return request; } } - } else if (typeof(opera) != 'undefined') { + } else if (BrowserDetect.isOpera()) { GM_xmlhttpRequest = function(obj) { obj.requestType = 'GM_xmlhttpRequest'; // Turns out, Opera works this way too, but I'll forgive them since their extensions are so young and they're awesome people... @@ -696,7 +700,7 @@ if ((typeof GM_deleteValue == 'undefined') || (typeof GM_addStyle == 'undefined' request.send(obj.data); return request; } } - } else if (typeof(self.on) == 'function') { + } else if (BrowserDetect.isFirefox()) { // we must be in a Firefox / jetpack addon... GM_xmlhttpRequest = function(obj) { obj.requestType = 'GM_xmlhttpRequest'; @@ -1207,7 +1211,7 @@ var RESUtils = { // mark off that we've checked for an update... RESStorage.setItem('RESLastUpdateCheck',now.getTime()); var outdated = false; - if (typeof(chrome) != 'undefined') { + if (BrowserDetect.isChrome()) { // we've got chrome, so we need to hit up the background page to do cross domain XHR var thisJSON = { requestType: 'compareVersion', @@ -1217,7 +1221,7 @@ var RESUtils = { // send message to background.html to open new tabs... outdated = RESUtils.compareVersion(response, forceUpdate); }); - } else if (typeof(safari) != 'undefined') { + } else if (BrowserDetect.isSafari()) { // we've got safari, so we need to hit up the background page to do cross domain XHR thisJSON = { requestType: 'compareVersion', @@ -1225,7 +1229,7 @@ var RESUtils = { forceUpdate: forceUpdate } safari.self.tab.dispatchMessage("compareVersion", thisJSON); - } else if (typeof(opera) != 'undefined') { + } else if (BrowserDetect.isOpera()) { // we've got opera, so we need to hit up the background page to do cross domain XHR thisJSON = { requestType: 'compareVersion', @@ -1693,24 +1697,10 @@ var RESUtils = { $('#sr-autocomplete').val('RESIssues'); $('li a.text-button').click(); $('#submittingToEnhancement').fadeOut(); - var thisBrowser; - if (typeof(self.on) == 'function') { - thisBrowser = 'Firefox'; - } else if (typeof(chrome) != 'undefined') { - thisBrowser = 'Chrome'; - } else if (typeof(safari) != 'undefined') { - thisBrowser = 'Safari'; - } else if (typeof(opera) != 'undefined') { - thisBrowser = 'Opera'; - } else { - thisBrowser = 'Unknown'; - } + var txt = "- RES Version: " + RESVersion + "\n"; - // turns out this is pretty useless info, commenting it out. - // txt += "- Browser: " + navigator.appCodeName + " " + navigator.appName + "\n"; - // txt += "- Browser: " + thisBrowser + "\n"; txt += "- Browser: " + BrowserDetect.browser + "\n"; - if (typeof(navigator) == 'undefined') navigator = window.navigator; + if (typeof(navigator) === 'undefined') navigator = window.navigator; txt+= "- Browser Version: " + BrowserDetect.version + "\n"; txt+= "- Cookies Enabled: " + navigator.cookieEnabled + "\n"; txt+= "- Platform: " + BrowserDetect.OS + "\n"; @@ -1806,8 +1796,24 @@ var RESUtils = { } return true; }, + deleteCookie : function(cookieName) { + var requestJSON = { + requestType: 'deleteCookie', + cname: cookieName + }; + + if (BrowserDetect.isChrome()) { + chrome.extension.sendMessage(requestJSON); + } else if (BrowserDetect.isSafari()) { + document.cookie = cookieName + '=null;expires=' + new Date() +'; path=/;domain=reddit.com'; + } else if (BrowserDetect.isOpera()) { + document.cookie = cookieName + '=null;expires=' + new Date() +'; path=/;domain=reddit.com'; + } else if (BrowserDetect.isFirefox()) { + self.postMessage(requestJSON); + } + }, openLinkInNewTab: function(url, focus) { - if (typeof(chrome) != 'undefined') { + if (BrowserDetect.isChrome()) { var thisJSON = { requestType: 'openLinkInNewTab', linkURL: url, @@ -1815,21 +1821,21 @@ var RESUtils = { }; // send message to background.html to open new tabs... chrome.extension.sendMessage(thisJSON); - } else if (typeof(safari) != 'undefined') { + } else if (BrowserDetect.isSafari()) { thisJSON = { requestType: 'openLinkInNewTab', linkURL: url, button: focus } safari.self.tab.dispatchMessage("openLinkInNewTab", thisJSON); - } else if (typeof(opera) != 'undefined') { + } else if (BrowserDetect.isOpera()) { thisJSON = { requestType: 'openLinkInNewTab', linkURL: url, button: focus } opera.extension.postMessage(JSON.stringify(thisJSON)); - } else if (typeof(self.on) == 'function') { + } else if (BrowserDetect.isFirefox()) { thisJSON = { requestType: 'openLinkInNewTab', linkURL: url, @@ -1955,13 +1961,13 @@ var RESUtils = { requestType: 'XHRCache', operation: operation }; - if (typeof(chrome) != 'undefined') { + if (BrowserDetect.isChrome()) { chrome.extension.sendMessage(thisJSON); - } else if (typeof(safari) != 'undefined') { + } else if (BrowserDetect.isSafari()) { safari.self.tab.dispatchMessage('XHRCache', thisJSON); - } else if (typeof(opera) != 'undefined') { + } else if (BrowserDetect.isOpera()) { opera.extension.postMessage(JSON.stringify(thisJSON)); - } else if (typeof(self.on) == 'function') { + } else if (BrowserDetect.isFirefox()) { self.postMessage(thisJSON); } }, @@ -4228,7 +4234,7 @@ modules['keyboardNav'] = { } var borderType = 'outline'; - if (typeof(opera) != 'undefined') borderType = 'border'; + if (BrowserDetect.isOpera()) borderType = 'border'; RESUtils.addCSS(' \ .keyHighlight { '+borderType+': '+focusBorder+'; background-color: '+focusBGColor+'; } \ .res-nightmode .keyHighlight, .res-nightmode .keyHighlight .usertext-body, .res-nightmode .keyHighlight .usertext-body .md, .res-nightmode .keyHighlight .usertext-body .md p, .res-nightmode .keyHighlight .noncollapsed, .res-nightmode .keyHighlight .noncollapsed .md, .res-nightmode .keyHighlight .noncollapsed .md p { background-color: '+focusBGColorNight+' !important; color: '+focusFGColorNight+' !important;} \ @@ -4837,28 +4843,28 @@ modules['keyboardNav'] = { var thisURL = link.getAttribute('href'); var isLocalToPage = (thisURL.indexOf('reddit') != -1) && (thisURL.indexOf('comments') != -1) && (thisURL.indexOf('#') != -1); if ((!isLocalToPage) && (button == 1)) { - if (typeof(chrome) != 'undefined') { + if (BrowserDetect.isChrome()) { var thisJSON = { requestType: 'keyboardNav', linkURL: thisURL, button: button }; chrome.extension.sendMessage(thisJSON); - } else if (typeof(safari) != 'undefined') { + } else if (BrowserDetect.isSafari()) { var thisJSON = { requestType: 'keyboardNav', linkURL: thisURL, button: button } safari.self.tab.dispatchMessage("keyboardNav", thisJSON); - } else if (typeof(opera) != 'undefined') { + } else if (BrowserDetect.isOpera()) { var thisJSON = { requestType: 'keyboardNav', linkURL: thisURL, button: button } opera.extension.postMessage(JSON.stringify(thisJSON)); - } else if (typeof(self.on) == 'function') { + } else if (BrowserDetect.isFirefox()) { var thisJSON = { requestType: 'keyboardNav', linkURL: thisURL, @@ -5225,28 +5231,28 @@ modules['keyboardNav'] = { var thisHREF = srLink.getAttribute('href'); if (newWindow) { var button = (this.options.followLinkNewTabFocus.value) ? 0 : 1; - if (typeof(chrome) != 'undefined') { + if (BrowserDetect.isChrome()) { var thisJSON = { requestType: 'keyboardNav', linkURL: thisHREF, button: button }; chrome.extension.sendMessage(thisJSON); - } else if (typeof(safari) != 'undefined') { + } else if (BrowserDetect.isSafari()) { var thisJSON = { requestType: 'keyboardNav', linkURL: thisHREF, button: button } safari.self.tab.dispatchMessage("keyboardNav", thisJSON); - } else if (typeof(opera) != 'undefined') { + } else if (BrowserDetect.isOpera()) { var thisJSON = { requestType: 'keyboardNav', linkURL: thisHREF, button: button } opera.extension.postMessage(JSON.stringify(thisJSON)); - } else if (typeof(self.on) == 'function') { + } else if (BrowserDetect.isFirefox()) { var thisJSON = { requestType: 'keyboardNav', linkURL: thisHREF, @@ -5491,28 +5497,28 @@ modules['keyboardNav'] = { // console.log(thisA); if (newWindow) { var button = (this.options.followLinkNewTabFocus.value) ? 0 : 1; - if (typeof(chrome) != 'undefined') { + if (BrowserDetect.isChrome()) { var thisJSON = { requestType: 'keyboardNav', linkURL: thisHREF, button: button }; chrome.extension.sendMessage(thisJSON); - } else if (typeof(safari) != 'undefined') { + } else if (BrowserDetect.isSafari()) { var thisJSON = { requestType: 'keyboardNav', linkURL: thisHREF, button: button } safari.self.tab.dispatchMessage("keyboardNav", thisJSON); - } else if (typeof(opera) != 'undefined') { + } else if (BrowserDetect.isOpera()) { var thisJSON = { requestType: 'keyboardNav', linkURL: thisHREF, button: button } opera.extension.postMessage(JSON.stringify(thisJSON)); - } else if (typeof(self.on) == 'function') { + } else if (BrowserDetect.isFirefox()) { var thisJSON = { requestType: 'keyboardNav', linkURL: thisHREF, @@ -5530,25 +5536,25 @@ modules['keyboardNav'] = { var thisA = this.keyboardLinks[this.activeIndex].querySelector('a.comments'); var thisHREF = thisA.getAttribute('href'); if (newWindow) { - if (typeof(chrome) != 'undefined') { + if (BrowserDetect.isChrome()) { var thisJSON = { requestType: 'keyboardNav', linkURL: thisHREF }; chrome.extension.sendMessage(thisJSON); - } else if (typeof(safari) != 'undefined') { + } else if (BrowserDetect.isSafari()) { var thisJSON = { requestType: 'keyboardNav', linkURL: thisHREF } safari.self.tab.dispatchMessage("keyboardNav", thisJSON); - } else if (typeof(opera) != 'undefined') { + } else if (BrowserDetect.isOpera()) { var thisJSON = { requestType: 'keyboardNav', linkURL: thisHREF } opera.extension.postMessage(JSON.stringify(thisJSON)); - } else if (typeof(self.on) == 'function') { + } else if (BrowserDetect.isFirefox()) { var thisJSON = { requestType: 'keyboardNav', linkURL: thisHREF @@ -5627,19 +5633,19 @@ modules['keyboardNav'] = { inbox: function(newWindow) { var thisHREF = location.protocol + '//'+location.hostname+'/message/inbox/'; if (newWindow) { - if (typeof(chrome) != 'undefined') { + if (BrowserDetect.isChrome()) { var thisJSON = { requestType: 'keyboardNav', linkURL: thisHREF }; chrome.extension.sendMessage(thisJSON); - } else if (typeof(safari) != 'undefined') { + } else if (BrowserDetect.isSafari()) { var thisJSON = { requestType: 'keyboardNav', linkURL: thisHREF } safari.self.tab.dispatchMessage("keyboardNav", thisJSON); - } else if (typeof(opera) != 'undefined') { + } else if (BrowserDetect.isOpera()) { var thisJSON = { requestType: 'keyboardNav', linkURL: thisHREF @@ -6896,7 +6902,7 @@ modules['betteReddit'] = { RESUtils.addCSS('#mail { top: 2px; min-width: 16px !important; width: auto !important; background-repeat: no-repeat !important; line-height: 8px !important; }'); // RESUtils.addCSS('#mail.havemail { top: 2px !important; margin-right: 1px; }'); RESUtils.addCSS('#mail.havemail { top: 2px !important; }'); - if ((typeof(chrome) != 'undefined') || (typeof(safari) != 'undefined')) { + if ((BrowserDetect.isChrome()) || (BrowserDetect.isSafari())) { // I hate that I have this conditional CSS in here but I can't figure out why it's needed for webkit and screws up firefox. RESUtils.addCSS('#mail.havemail { top: 0; }'); } @@ -7625,7 +7631,7 @@ modules['singleClick'] = { if (!(thisLink.match(/^http/i))) { thisLink = 'http://' + document.domain + thisLink; } - if (typeof(chrome) != 'undefined') { + if (BrowserDetect.isChrome()) { var thisJSON = { requestType: 'singleClick', linkURL: thisLink, @@ -7635,7 +7641,7 @@ modules['singleClick'] = { ctrl: e.ctrlKey }; chrome.extension.sendMessage(thisJSON); - } else if (typeof(safari) != 'undefined') { + } else if (BrowserDetect.isSafari()) { var thisJSON = { requestType: 'singleClick', linkURL: thisLink, @@ -7645,7 +7651,7 @@ modules['singleClick'] = { ctrl: e.ctrlKey } safari.self.tab.dispatchMessage("singleClick", thisJSON); - } else if (typeof(opera) != 'undefined') { + } else if (BrowserDetect.isOpera()) { var thisJSON = { requestType: 'singleClick', linkURL: thisLink, @@ -7655,7 +7661,7 @@ modules['singleClick'] = { ctrl: e.ctrlKey } opera.extension.postMessage(JSON.stringify(thisJSON)); - } else if (typeof(self.on) == 'function') { + } else if (BrowserDetect.isFirefox()) { var thisJSON = { requestType: 'singleClick', linkURL: thisLink, @@ -8907,7 +8913,7 @@ modules['showImages'] = { if (this.options.markVisited.value) { // we only need this iFrame hack if we're unable to add to history directly, which Firefox addons and Chrome can do. - if ((typeof(chrome) == 'undefined') && (typeof(self.on) == 'undefined')) { + if (!BrowserDetect.isChrome() && !BrowserDetect.isFirefox()) { this.imageTrackFrame = document.createElement('iframe'); this.imageTrackFrame.addEventListener('load', function() { setTimeout(modules['showImages'].imageTrackShift, 300); @@ -9541,7 +9547,7 @@ modules['showImages'] = { var isNSFW = $(link).closest('.thing').is('.over18'); var sfwMode = modules['showImages'].options['sfwHistory'].value; - if ((typeof(chrome) != 'undefined') || (typeof(self.on) != 'undefined')) { + if ((BrowserDetect.isChrome()) || (BrowserDetect.isFirefox())) { var url = link.historyURL || link.href; if (!isNSFW || sfwMode != 'none') addClass(link, 'visited'); if (!isNSFW || sfwMode == 'add') { @@ -9570,7 +9576,7 @@ modules['showImages'] = { modules['showImages'].handleSidebarHiding(); return; } - if (typeof(chrome) != 'undefined') { + if (BrowserDetect.isChrome()) { if (!chrome.extension.inIncognitoContext) { chrome.extension.sendMessage({ requestType: 'addURLToHistory', @@ -9578,7 +9584,7 @@ modules['showImages'] = { }); } modules['showImages'].imageTrackShift(); - } else if (typeof(self.on) != 'undefined') { + } else if (BrowserDetect.isFirefox()) { // update: using XPCOM we may can add URLs to Firefox history without the iframe hack! var thisJSON = { requestType: 'addURLToHistory', @@ -11731,7 +11737,7 @@ modules['styleTweaks'] = { var match = twitterLink.match(/twitter.com\/[^\/]+\/(?:status|statuses)\/([\d]+)/i); if (match != null) { var jsonURL = 'http://api.twitter.com/1/statuses/show/'+match[1]+'.json'; - if (typeof(chrome) != 'undefined') { + if (BrowserDetect.isChrome()) { // we've got chrome, so we need to hit up the background page to do cross domain XHR var thisJSON = { requestType: 'loadTweet', @@ -11744,7 +11750,7 @@ modules['styleTweaks'] = { thisExpando.style.display = 'block'; addClass(thisExpando,'twitterLoaded'); }); - } else if (typeof(safari) != 'undefined') { + } else if (BrowserDetect.isSafari()) { // we've got safari, so we need to hit up the background page to do cross domain XHR modules['styleTweaks'].tweetExpando = thisExpando; var thisJSON = { @@ -11752,7 +11758,7 @@ modules['styleTweaks'] = { url: jsonURL } safari.self.tab.dispatchMessage("loadTweet", thisJSON); - } else if (typeof(opera) != 'undefined') { + } else if (BrowserDetect.isOpera()) { // we've got opera, so we need to hit up the background page to do cross domain XHR modules['styleTweaks'].tweetExpando = thisExpando; var thisJSON = { @@ -11760,7 +11766,7 @@ modules['styleTweaks'] = { url: jsonURL } opera.extension.postMessage(JSON.stringify(thisJSON)); - } else if (typeof(self.on) == 'function') { + } else if (BrowserDetect.isFirefox()) { // we've got a jetpack extension, hit up the background page... modules['styleTweaks'].tweetExpando = thisExpando; var thisJSON = { @@ -12296,7 +12302,6 @@ modules['accountSwitcher'] = { RESUtils.addCSS('#RESAccountSwitcherDropdown { min-width: 110px; width: auto; display: none; position: absolute; z-index: 999; }'); RESUtils.addCSS('#RESAccountSwitcherDropdown li.accountName { height: auto; line-height: 20px; padding-top: 2px; padding-bottom: 2px; }'); if (this.options.dropDownStyle.value == 'alien') { - // this.alienIMG = ''; RESUtils.addCSS('#RESAccountSwitcherIcon { cursor: pointer; margin-left: 3px; display: inline-block; width: 12px; vertical-align: middle; height: 16px; background-repeat: no-repeat; background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAAPCAYAAAAyPTUwAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyBpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMC1jMDYwIDYxLjEzNDc3NywgMjAxMC8wMi8xMi0xNzozMjowMCAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNSBXaW5kb3dzIiB4bXBNTTpJbnN0YW5jZUlEPSJ4bXAuaWlkOkQ3NTExRkExOEYzNTExRTFBNjgzQzhEOUY2QzU2MUNFIiB4bXBNTTpEb2N1bWVudElEPSJ4bXAuZGlkOkQ3NTExRkEyOEYzNTExRTFBNjgzQzhEOUY2QzU2MUNFIj4gPHhtcE1NOkRlcml2ZWRGcm9tIHN0UmVmOmluc3RhbmNlSUQ9InhtcC5paWQ6RDc1MTFGOUY4RjM1MTFFMUE2ODNDOEQ5RjZDNTYxQ0UiIHN0UmVmOmRvY3VtZW50SUQ9InhtcC5kaWQ6RDc1MTFGQTA4RjM1MTFFMUE2ODNDOEQ5RjZDNTYxQ0UiLz4gPC9yZGY6RGVzY3JpcHRpb24+IDwvcmRmOlJERj4gPC94OnhtcG1ldGE+IDw/eHBhY2tldCBlbmQ9InIiPz6W3fJJAAAB4ElEQVR42mJgwA4YgdgSiJUUFRXDW1tbL7Kzswsw4VDMBcRXgfgeMzPzJx4eHn4gG0MtSICPjY3NF0jLoCtglJWV1eDm5rZmZWX9k5ZbWGFmYqwhwM3B8Pn7T4bzl6/enzNlQsfrV68+srKxPWHMz89/ZmJiIunn58fA9+YKAwMHHwODlA4Dw4fHDAzPbzD8VLRhWLNuPcOzp0//MEhJSaU/f/HyPxhkyf//3xsEYa+s/f8/nOn//19f/n/98fO/jo5ONwMfH5/S27dvwfL/nt/5//8rhP3/z7f//55cgzD//PkPdK4F2N3x8fFLv3///v/d56//l69a83///v3/V65e8//+k+f///79+7+4uPgAUB0zIywUgNZEZmVlzRMTE2P78OEDA9DTDN++ffs3c+bMglOnTk0HqvkDC5p/L168+P7582cmaWlpBhUVFQZ5eXkGoPUMDx8+BMn/QQ5C1vb29r+HDx/+jwwuXLjwv7e39z8wWHkYkAOdk5OT4cePHygx9OXLF7BzgPpQo05NTS2mp6fnO7LJc+bM+a2np1eKNUFISEg0gEIFHIz//v3X1dWdDU1UYMAMYzg7O8eUlpYmXLly5dtfFm6h40cO3DU2NhYBphOea9euHQOpAQgwAKMW+Z5mJFvIAAAAAElFTkSuQmCC); }'); RESUtils.addCSS('#RESAccountSwitcherIconOverlay { cursor: pointer; position: absolute; display: none; width: 11px; height: 22px; background-position: 2px 3px; padding-left: 2px; padding-right: 2px; padding-top: 3px; border: 1px solid #369; border-bottom: 1px solid #5f99cf; background-color: #5f99cf; border-radius: 3px 3px 0 0; z-index: 100; background-repeat: no-repeat; background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAAPCAYAAAAyPTUwAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyBpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMC1jMDYwIDYxLjEzNDc3NywgMjAxMC8wMi8xMi0xNzozMjowMCAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNSBXaW5kb3dzIiB4bXBNTTpJbnN0YW5jZUlEPSJ4bXAuaWlkOkQ3NTExRkExOEYzNTExRTFBNjgzQzhEOUY2QzU2MUNFIiB4bXBNTTpEb2N1bWVudElEPSJ4bXAuZGlkOkQ3NTExRkEyOEYzNTExRTFBNjgzQzhEOUY2QzU2MUNFIj4gPHhtcE1NOkRlcml2ZWRGcm9tIHN0UmVmOmluc3RhbmNlSUQ9InhtcC5paWQ6RDc1MTFGOUY4RjM1MTFFMUE2ODNDOEQ5RjZDNTYxQ0UiIHN0UmVmOmRvY3VtZW50SUQ9InhtcC5kaWQ6RDc1MTFGQTA4RjM1MTFFMUE2ODNDOEQ5RjZDNTYxQ0UiLz4gPC9yZGY6RGVzY3JpcHRpb24+IDwvcmRmOlJERj4gPC94OnhtcG1ldGE+IDw/eHBhY2tldCBlbmQ9InIiPz6W3fJJAAAB4ElEQVR42mJgwA4YgdgSiJUUFRXDW1tbL7Kzswsw4VDMBcRXgfgeMzPzJx4eHn4gG0MtSICPjY3NF0jLoCtglJWV1eDm5rZmZWX9k5ZbWGFmYqwhwM3B8Pn7T4bzl6/enzNlQsfrV68+srKxPWHMz89/ZmJiIunn58fA9+YKAwMHHwODlA4Dw4fHDAzPbzD8VLRhWLNuPcOzp0//MEhJSaU/f/HyPxhkyf//3xsEYa+s/f8/nOn//19f/n/98fO/jo5ONwMfH5/S27dvwfL/nt/5//8rhP3/z7f//55cgzD//PkPdK4F2N3x8fFLv3///v/d56//l69a83///v3/V65e8//+k+f///79+7+4uPgAUB0zIywUgNZEZmVlzRMTE2P78OEDA9DTDN++ffs3c+bMglOnTk0HqvkDC5p/L168+P7582cmaWlpBhUVFQZ5eXkGoPUMDx8+BMn/QQ5C1vb29r+HDx/+jwwuXLjwv7e39z8wWHkYkAOdk5OT4cePHygx9OXLF7BzgPpQo05NTS2mp6fnO7LJc+bM+a2np1eKNUFISEg0gEIFHIz//v3X1dWdDU1UYMAMYzg7O8eUlpYmXLly5dtfFm6h40cO3DU2NhYBphOea9euHQOpAQgwAKMW+Z5mJFvIAAAAAElFTkSuQmCC); }'); } else { @@ -12356,7 +12361,7 @@ modules['accountSwitcher'] = { var accountCount = 0; for (var i=0, len=accounts.length; iImportant Alert for Greasemonkey Users!Hey! It looks like you have upgraded to RES 4.0, but used to use the Greasemonkey version of RES. You\'re going to see double until you uninstall the Greasemonkey script. However, you should first copy your settings by clicking the blue button. After installing, refresh this page! GM->FF Import Tool', 15000); localStorage.removeItem('RES.lsTest'); @@ -17902,11 +17906,11 @@ function RESInit() { if (localStorageFail) { RESFail = "Sorry, but localStorage seems inaccessible. Reddit Enhancement Suite can't work without it. \n\n"; - if (typeof(safari) != 'undefined') { + if (BrowserDetect.isSafari()) { RESFail += 'Since you\'re using Safari, it might be that you\'re in private browsing mode, which unfortunately is incompatible with RES until Safari provides a way to allow extensions localStorage access.'; - } else if (typeof(chrome) != 'undefined') { + } else if (BrowserDetect.isChrome()) { RESFail += 'Since you\'re using Chrome, you might just need to go to your extensions settings and check the "Allow in Incognito" box.'; - } else if (typeof(opera) != 'undefined') { + } else if (BrowserDetect.isOpera()) { RESFail += 'Since you\'re using Opera, you might just need to go to your extensions settings and click the gear icon, then click "privacy" and check the box that says "allow interaction with private tabs".'; } else { RESFail += 'Since it looks like you\'re using Firefox, you probably need to go to about:config and ensure that dom.storage.enabled is set to true, and that dom.storage.default_quota is set to a number above zero (i.e. 5120, the normal default)".'; @@ -17976,7 +17980,7 @@ function RESInit() { RESStorage = {}; function setUpRESStorage (response) { - if (typeof(chrome) != 'undefined') { + if (BrowserDetect.isChrome()) { RESStorage = response; // we'll set up a method for getItem, but it's not adviseable to use since it's asynchronous... RESStorage.getItem = function(key) { @@ -18014,7 +18018,7 @@ function setUpRESStorage (response) { } window.localStorage = RESStorage; //RESInit(); - } else if (typeof(safari) != 'undefined') { + } else if (BrowserDetect.isSafari()) { RESStorage = response; RESStorage.getItem = function(key) { if (typeof(RESStorage[key]) != 'undefined') return RESStorage[key]; @@ -18049,7 +18053,7 @@ function setUpRESStorage (response) { safari.self.tab.dispatchMessage("localStorage", thisJSON); } window.localStorage = RESStorage; - } else if (typeof(opera) != 'undefined') { + } else if (BrowserDetect.isOpera()) { RESStorage = response; RESStorage.getItem = function(key) { if (typeof(RESStorage[key]) != 'undefined') return RESStorage[key]; @@ -18084,7 +18088,7 @@ function setUpRESStorage (response) { opera.extension.postMessage(JSON.stringify(thisJSON)); } window.localStorage = RESStorage; - } else if (typeof(self.on) != 'undefined') { + } else if (BrowserDetect.isFirefox()) { RESStorage = response; RESStorage.getItem = function(key) { if (typeof(RESStorage[key]) != 'undefined') return RESStorage[key]; @@ -18167,7 +18171,7 @@ function setUpRESStorage (response) { return false; } RESRunOnce = true; - if (typeof(chrome) != 'undefined') { + if (BrowserDetect.isChrome()) { // we've got chrome, get a copy of the background page's localStorage first, so don't init until after. var thisJSON = { requestType: 'getLocalStorage' @@ -18188,19 +18192,19 @@ function setUpRESStorage (response) { setUpRESStorage(response); } }); - } else if (typeof(safari) != 'undefined') { + } else if (BrowserDetect.isSafari()) { // we've got safari, get localStorage from background process thisJSON = { requestType: 'getLocalStorage' } safari.self.tab.dispatchMessage("getLocalStorage", thisJSON); - } else if (typeof(self.on) != 'undefined') { + } else if (BrowserDetect.isFirefox()) { // we've got firefox jetpack, get localStorage from background process thisJSON = { requestType: 'getLocalStorage' } self.postMessage(thisJSON); - } else if (typeof(opera) != 'undefined') { + } else if (BrowserDetect.isOpera()) { // I freaking hate having to use different code that won't run in other browsers to log debugs, so I'm overriding console.log with opera.postError here // so I don't have to litter my code with different statements for different browsers when debugging. console.log = opera.postError; @@ -18241,7 +18245,7 @@ function RESInitReadyCheck() { if ((typeof(RESStorage.getItem) != 'function') || (document.body == null)) { setTimeout(RESInitReadyCheck, 50); } else { - if (typeof(self.on) == 'function') { + if (BrowserDetect.isFirefox()) { // firefox addon sdk... we've included jQuery... // also, for efficiency, we're going to try using unsafeWindow for "less secure" (but we're not going 2 ways here, so that's OK) but faster DOM node access... // console.log('faster?'); @@ -18268,7 +18272,7 @@ function RESInitReadyCheck() { console.log('Uh oh, something has gone wrong loading jQuery...'); } } - if (typeof(opera) != 'undefined') { + if (BrowserDetect.isOpera()) { // require.js-like modular injected scripts, code via: // http://my.opera.com/BS-Harou/blog/2012/08/08/modular-injcted-scripts-in-extensions // Note: This code requires Opera 12.50 to run!