Less hard-coded NSFW boards

Let's let 4chan tell us if a board is NSFW or not.
This commit is contained in:
Zixaphir 2014-01-12 16:38:34 -07:00
parent 966882c11d
commit 5ca10fc248
6 changed files with 36 additions and 51 deletions

View File

@ -10965,15 +10965,6 @@
Favicon = { Favicon = {
init: function() { init: function() {
var href;
Favicon.el = $('link[rel="shortcut icon"]', d.head);
Favicon.el.type = 'image/x-icon';
href = Favicon.el.href;
Favicon.SFW = /ws\.ico$/.test(href);
Favicon["default"] = href;
return Favicon["switch"]();
},
"switch": function() {
var f, funreadDeadY, t, _ref; var f, funreadDeadY, t, _ref;
t = 'data:image/png;base64,'; t = 'data:image/png;base64,';
f = Favicon; f = Favicon;
@ -16533,7 +16524,7 @@
return this.nextElementSibling.innerHTML = funk(FileInfo, data); return this.nextElementSibling.innerHTML = funk(FileInfo, data);
}, },
favicon: function() { favicon: function() {
Favicon["switch"](); Favicon.init();
if (g.VIEW === 'thread' && Conf['Unread Favicon']) { if (g.VIEW === 'thread' && Conf['Unread Favicon']) {
Unread.update(); Unread.update();
} }
@ -17189,8 +17180,13 @@
}); });
}, },
initFeatures: function() { initFeatures: function() {
var err, feature, name, _i, _len, _ref, _ref1, _ref2, _ref3; var err, feature, href, name, _i, _len, _ref, _ref1, _ref2;
g.TYPE = (_ref = g.BOARD.ID) === 'b' || _ref === 'd' || _ref === 'e' || _ref === 'gif' || _ref === 'h' || _ref === 'hc' || _ref === 'hm' || _ref === 'hr' || _ref === 'pol' || _ref === 'r' || _ref === 'r9k' || _ref === 'rs' || _ref === 's' || _ref === 's4s' || _ref === 'soc' || _ref === 't' || _ref === 'u' || _ref === 'y' ? 'nsfw' : 'sfw'; Favicon.el = $('link[rel="shortcut icon"]', d.head);
Favicon.el.type = 'image/x-icon';
href = Favicon.el.href;
Favicon.SFW = /ws\.ico$/.test(href);
Favicon["default"] = href;
g.TYPE = Favicon.SFW ? 'sfw' : 'nsfw';
$.extend(Themes, Conf["userThemes"]); $.extend(Themes, Conf["userThemes"]);
$.extend(Mascots, Conf["userMascots"]); $.extend(Mascots, Conf["userMascots"]);
if (Conf["NSFW/SFW Mascots"]) { if (Conf["NSFW/SFW Mascots"]) {
@ -17201,7 +17197,7 @@
if (Conf["NSFW/SFW Themes"]) { if (Conf["NSFW/SFW Themes"]) {
Conf["theme"] = Conf["theme_" + g.TYPE]; Conf["theme"] = Conf["theme_" + g.TYPE];
} }
if ((_ref1 = g.BOARD.ID) === 'z' || _ref1 === 'fk') { if ((_ref = g.BOARD.ID) === 'z' || _ref === 'fk') {
return Style.init(); return Style.init();
} }
switch (location.hostname) { switch (location.hostname) {
@ -17219,8 +17215,8 @@
return; return;
case 'i.4cdn.org': case 'i.4cdn.org':
$.ready(function() { $.ready(function() {
var URL, pathname, _ref2; var URL, pathname, _ref1;
if (Conf['404 Redirect'] && ((_ref2 = d.title) === '4chan - Temporarily Offline' || _ref2 === '4chan - 404 Not Found')) { if (Conf['404 Redirect'] && ((_ref1 = d.title) === '4chan - Temporarily Offline' || _ref1 === '4chan - 404 Not Found')) {
Redirect.init(); Redirect.init();
pathname = location.pathname.split('/'); pathname = location.pathname.split('/');
URL = Redirect.to('file', { URL = Redirect.to('file', {
@ -17234,9 +17230,9 @@
}); });
return; return;
} }
_ref2 = Main.features; _ref1 = Main.features;
for (_i = 0, _len = _ref2.length; _i < _len; _i++) { for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
_ref3 = _ref2[_i], name = _ref3[0], feature = _ref3[1]; _ref2 = _ref1[_i], name = _ref2[0], feature = _ref2[1];
try { try {
feature.init(); feature.init();
} catch (_error) { } catch (_error) {

View File

@ -10949,15 +10949,6 @@
Favicon = { Favicon = {
init: function() { init: function() {
var href;
Favicon.el = $('link[rel="shortcut icon"]', d.head);
Favicon.el.type = 'image/x-icon';
href = Favicon.el.href;
Favicon.SFW = /ws\.ico$/.test(href);
Favicon["default"] = href;
return Favicon["switch"]();
},
"switch": function() {
var f, funreadDeadY, t, _ref; var f, funreadDeadY, t, _ref;
t = 'data:image/png;base64,'; t = 'data:image/png;base64,';
f = Favicon; f = Favicon;
@ -16527,7 +16518,7 @@
return this.nextElementSibling.innerHTML = funk(FileInfo, data); return this.nextElementSibling.innerHTML = funk(FileInfo, data);
}, },
favicon: function() { favicon: function() {
Favicon["switch"](); Favicon.init();
if (g.VIEW === 'thread' && Conf['Unread Favicon']) { if (g.VIEW === 'thread' && Conf['Unread Favicon']) {
Unread.update(); Unread.update();
} }
@ -17177,8 +17168,13 @@
}); });
}, },
initFeatures: function() { initFeatures: function() {
var err, feature, name, _i, _len, _ref, _ref1, _ref2, _ref3; var err, feature, href, name, _i, _len, _ref, _ref1, _ref2;
g.TYPE = (_ref = g.BOARD.ID) === 'b' || _ref === 'd' || _ref === 'e' || _ref === 'gif' || _ref === 'h' || _ref === 'hc' || _ref === 'hm' || _ref === 'hr' || _ref === 'pol' || _ref === 'r' || _ref === 'r9k' || _ref === 'rs' || _ref === 's' || _ref === 's4s' || _ref === 'soc' || _ref === 't' || _ref === 'u' || _ref === 'y' ? 'nsfw' : 'sfw'; Favicon.el = $('link[rel="shortcut icon"]', d.head);
Favicon.el.type = 'image/x-icon';
href = Favicon.el.href;
Favicon.SFW = /ws\.ico$/.test(href);
Favicon["default"] = href;
g.TYPE = Favicon.SFW ? 'sfw' : 'nsfw';
$.extend(Themes, Conf["userThemes"]); $.extend(Themes, Conf["userThemes"]);
$.extend(Mascots, Conf["userMascots"]); $.extend(Mascots, Conf["userMascots"]);
if (Conf["NSFW/SFW Mascots"]) { if (Conf["NSFW/SFW Mascots"]) {
@ -17189,7 +17185,7 @@
if (Conf["NSFW/SFW Themes"]) { if (Conf["NSFW/SFW Themes"]) {
Conf["theme"] = Conf["theme_" + g.TYPE]; Conf["theme"] = Conf["theme_" + g.TYPE];
} }
if ((_ref1 = g.BOARD.ID) === 'z' || _ref1 === 'fk') { if ((_ref = g.BOARD.ID) === 'z' || _ref === 'fk') {
return Style.init(); return Style.init();
} }
switch (location.hostname) { switch (location.hostname) {
@ -17207,8 +17203,8 @@
return; return;
case 'i.4cdn.org': case 'i.4cdn.org':
$.ready(function() { $.ready(function() {
var URL, pathname, _ref2; var URL, pathname, _ref1;
if (Conf['404 Redirect'] && ((_ref2 = d.title) === '4chan - Temporarily Offline' || _ref2 === '4chan - 404 Not Found')) { if (Conf['404 Redirect'] && ((_ref1 = d.title) === '4chan - Temporarily Offline' || _ref1 === '4chan - 404 Not Found')) {
Redirect.init(); Redirect.init();
pathname = location.pathname.split('/'); pathname = location.pathname.split('/');
URL = Redirect.to('file', { URL = Redirect.to('file', {
@ -17222,9 +17218,9 @@
}); });
return; return;
} }
_ref2 = Main.features; _ref1 = Main.features;
for (_i = 0, _len = _ref2.length; _i < _len; _i++) { for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
_ref3 = _ref2[_i], name = _ref3[0], feature = _ref3[1]; _ref2 = _ref1[_i], name = _ref2[0], feature = _ref2[1];
try { try {
feature.init(); feature.init();
} catch (_error) { } catch (_error) {

View File

@ -48,11 +48,12 @@ Main =
initFeatures: -> initFeatures: ->
# Check if the current board we're on is SFW or not, so we can handle options that need to know that. # Check if the current board we're on is SFW or not, so we can handle options that need to know that.
g.TYPE = Favicon.el = $ 'link[rel="shortcut icon"]', d.head
if g.BOARD.ID in ['b', 'd', 'e', 'gif', 'h', 'hc', 'hm', 'hr', 'pol', 'r', 'r9k', 'rs', 's', 's4s', 'soc', 't', 'u', 'y'] Favicon.el.type = 'image/x-icon'
'nsfw' {href} = Favicon.el
else Favicon.SFW = /ws\.ico$/.test href
'sfw' Favicon.default = href
g.TYPE = if Favicon.SFW then 'sfw' else 'nsfw'
$.extend Themes, Conf["userThemes"] $.extend Themes, Conf["userThemes"]
$.extend Mascots, Conf["userMascots"] $.extend Mascots, Conf["userMascots"]

View File

@ -156,7 +156,7 @@ Navigate =
Favicon.SFW = sfw Favicon.SFW = sfw
Favicon.el.href = "//s.4cdn.org/image/favicon#{if sfw then '-ws' else ''}.ico" Favicon.el.href = "//s.4cdn.org/image/favicon#{if sfw then '-ws' else ''}.ico"
$.add d.head, Favicon.el # Changing the href alone doesn't update the icon on Firefox $.add d.head, Favicon.el # Changing the href alone doesn't update the icon on Firefox
Favicon.switch() Favicon.init()
mainStyleSheet.href = newStyleSheet.href mainStyleSheet.href = newStyleSheet.href

View File

@ -411,7 +411,7 @@ Settings =
@nextElementSibling.innerHTML = funk FileInfo, data @nextElementSibling.innerHTML = funk FileInfo, data
favicon: -> favicon: ->
Favicon.switch() Favicon.init()
Unread.update() if g.VIEW is 'thread' and Conf['Unread Favicon'] Unread.update() if g.VIEW is 'thread' and Conf['Unread Favicon']
$.id('favicon-preview').innerHTML = """ $.id('favicon-preview').innerHTML = """
<img src=#{Favicon.default}> <img src=#{Favicon.default}>

View File

@ -1,13 +1,5 @@
Favicon = Favicon =
init: -> init: ->
Favicon.el = $ 'link[rel="shortcut icon"]', d.head
Favicon.el.type = 'image/x-icon'
{href} = Favicon.el
Favicon.SFW = /ws\.ico$/.test href
Favicon.default = href
Favicon.switch()
switch: ->
t = 'data:image/png;base64,' t = 'data:image/png;base64,'
f = Favicon f = Favicon
[f.unreadDead, funreadDeadY, f.unreadSFW, f.unreadSFWY, f.unreadNSFW, f.unreadNSFWY] = switch Conf['favicon'] [f.unreadDead, funreadDeadY, f.unreadSFW, f.unreadSFWY, f.unreadNSFW, f.unreadNSFWY] = switch Conf['favicon']