diff --git a/builds/appchan-x.user.js b/builds/appchan-x.user.js index f98527e27..93bf2d6cc 100644 --- a/builds/appchan-x.user.js +++ b/builds/appchan-x.user.js @@ -12197,12 +12197,6 @@ }); } }, - addSheet: function(_arg) { - var id, key, text; - - key = _arg[0], text = _arg[1], id = _arg[2]; - return Style[key] = $.addStyle(text, id); - }, setup: function() { var i, item, items, theme; @@ -12213,14 +12207,11 @@ items = [['layoutCSS', Style.layout, 'layout'], ['themeCSS', Style.theme(theme), 'theme'], ['emojiCSS', Emoji.css(), 'emoji'], ['dynamicCSS', Style.dynamic(), 'dynamic'], ['icons', "", 'icons'], ['paddingSheet', "", 'padding'], ['mascot', "", 'mascotSheet']]; i = 0; while (item = items[i++]) { - Style.addSheet(item); + Style[item[0]] = $.addStyle(item[1], item[2]); } $.addStyle(JSColor.css(), 'jsColor'); if (d.head) { this.remStyle(); - if (!Style.headCount) { - return this.cleanup(); - } } return this.observe(); }, @@ -12240,38 +12231,25 @@ wrapper: function() { if (d.head) { Style.remStyle(); - if (!Style.headCount || d.readyState === 'complete') { + if (d.readyState === 'complete') { if (Style.observer) { - Style.observer.disconnect(); + return Style.observer.disconnect(); } else { - $.off(d, 'DOMNodeInserted', Style.wrapper); + return $.off(d, 'DOMNodeInserted', Style.wrapper); } - return Style.cleanup(); } } }, - cleanup: function() { - delete Style.observe; - delete Style.wrapper; - delete Style.remStyle; - delete Style.headCount; - return delete Style.cleanup; - }, - headCount: 12, remStyle: function() { var href, i, node, nodes; nodes = d.head.children; i = nodes.length; while (i--) { - if (!Style.headCount) { - return; - } node = nodes[i]; if (node.nodeName === 'STYLE' && node.id || (/stylesheet/.test(node.rel) && (/flags.*\.css$/.test(href = node.href) || href.slice(0, 4) === 'data')) || (/\.typeset/.test(node.textContent))) { continue; } - Style.headCount--; $.rm(node); } }, diff --git a/builds/crx/script.js b/builds/crx/script.js index 8649c6b5e..306c0718c 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -12190,12 +12190,6 @@ }); } }, - addSheet: function(_arg) { - var id, key, text; - - key = _arg[0], text = _arg[1], id = _arg[2]; - return Style[key] = $.addStyle(text, id); - }, setup: function() { var i, item, items, theme; @@ -12206,14 +12200,11 @@ items = [['layoutCSS', Style.layout, 'layout'], ['themeCSS', Style.theme(theme), 'theme'], ['emojiCSS', Emoji.css(), 'emoji'], ['dynamicCSS', Style.dynamic(), 'dynamic'], ['icons', "", 'icons'], ['paddingSheet', "", 'padding'], ['mascot', "", 'mascotSheet']]; i = 0; while (item = items[i++]) { - Style.addSheet(item); + Style[item[0]] = $.addStyle(item[1], item[2]); } $.addStyle(JSColor.css(), 'jsColor'); if (d.head) { this.remStyle(); - if (!Style.headCount) { - return this.cleanup(); - } } return this.observe(); }, @@ -12233,38 +12224,25 @@ wrapper: function() { if (d.head) { Style.remStyle(); - if (!Style.headCount || d.readyState === 'complete') { + if (d.readyState === 'complete') { if (Style.observer) { - Style.observer.disconnect(); + return Style.observer.disconnect(); } else { - $.off(d, 'DOMNodeInserted', Style.wrapper); + return $.off(d, 'DOMNodeInserted', Style.wrapper); } - return Style.cleanup(); } } }, - cleanup: function() { - delete Style.observe; - delete Style.wrapper; - delete Style.remStyle; - delete Style.headCount; - return delete Style.cleanup; - }, - headCount: 12, remStyle: function() { var href, i, node, nodes; nodes = d.head.children; i = nodes.length; while (i--) { - if (!Style.headCount) { - return; - } node = nodes[i]; if (node.nodeName === 'STYLE' && node.id || (/stylesheet/.test(node.rel) && (/flags.*\.css$/.test(href = node.href) || href.slice(0, 4) === 'data')) || (/\.typeset/.test(node.textContent))) { continue; } - Style.headCount--; $.rm(node); } }, diff --git a/src/Theming/Style.coffee b/src/Theming/Style.coffee index 3e653eee2..204bb9222 100644 --- a/src/Theming/Style.coffee +++ b/src/Theming/Style.coffee @@ -47,9 +47,6 @@ Style = $.on exLink, "click", -> setTimeout Rice.nodes, 100 - addSheet: ([key, text, id]) -> - Style[key] = $.addStyle text, id - setup: -> theme = Themes[Conf['theme']] or Themes['Yotsuba B'] Style.svg = $.el 'div', @@ -67,15 +64,13 @@ Style = i = 0 while item = items[i++] - Style.addSheet item + Style[item[0]] = $.addStyle item[1], item[2] # Non-customizable $.addStyle JSColor.css(), 'jsColor' if d.head @remStyle() - unless Style.headCount - return @cleanup() @observe() observe: -> @@ -91,34 +86,21 @@ Style = if d.head Style.remStyle() - if not Style.headCount or d.readyState is 'complete' + if d.readyState is 'complete' if Style.observer Style.observer.disconnect() else $.off d, 'DOMNodeInserted', Style.wrapper - Style.cleanup() - - cleanup: -> - delete Style.observe - delete Style.wrapper - delete Style.remStyle - delete Style.headCount - delete Style.cleanup - - headCount: 12 remStyle: -> nodes = d.head.children i = nodes.length while i-- - return unless Style.headCount node = nodes[i] continue if node.nodeName is 'STYLE' and node.id or (/stylesheet/.test(node.rel) and (/flags.*\.css$/.test(href = node.href) or href[..3] is 'data')) or (/\.typeset/.test node.textContent) - - Style.headCount-- $.rm node return @@ -216,7 +198,6 @@ Style = position if Conf["Icon Orientation"] is "horizontal" - position = aligner( 2 [