diff --git a/CHANGELOG.md b/CHANGELOG.md index 555fa2d3d..174ffbb41 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,9 @@ ### v1.14.5 +**v1.14.5.1** *(2018-12-06)* - [[Userscript](https://raw.githubusercontent.com/ccd0/4chan-x/1.14.5.1/builds/4chan-X-noupdate.user.js)] [[Chrome extension](https://raw.githubusercontent.com/ccd0/4chan-x/1.14.5.1/builds/4chan-X-noupdate.crx)] +- Support style switcher and non-default styles on Tinyboard. + **v1.14.5.0** *(2018-12-06)* - [[Userscript](https://raw.githubusercontent.com/ccd0/4chan-x/1.14.5.0/builds/4chan-X-noupdate.user.js)] [[Chrome extension](https://raw.githubusercontent.com/ccd0/4chan-x/1.14.5.0/builds/4chan-X-noupdate.crx)] - Based on v1.14.4.7. - Show threads from other sites in Thread Watcher. When threads from multiple sites are shown, a prefix is added before the board name to distinguish sites. The prefix can be disabled by unchecking `Show Site Prefix` preference in thread watcher menu. More work remains; refreshing is still only working on 4chan, and the unread count still only works for 4chan threads. diff --git a/builds/4chan-X-beta.crx b/builds/4chan-X-beta.crx index 86c3f4411..722d68e70 100644 Binary files a/builds/4chan-X-beta.crx and b/builds/4chan-X-beta.crx differ diff --git a/builds/4chan-X-beta.meta.js b/builds/4chan-X-beta.meta.js index fc2cc9ecb..b05ac408c 100644 --- a/builds/4chan-X-beta.meta.js +++ b/builds/4chan-X-beta.meta.js @@ -1,6 +1,6 @@ // ==UserScript== // @name 4chan X beta -// @version 1.14.5.0 +// @version 1.14.5.1 // @minGMVer 1.14 // @minFFVer 26 // @namespace 4chan-X diff --git a/builds/4chan-X-beta.user.js b/builds/4chan-X-beta.user.js index 37aec7e78..cc0170540 100644 --- a/builds/4chan-X-beta.user.js +++ b/builds/4chan-X-beta.user.js @@ -1,6 +1,6 @@ // ==UserScript== // @name 4chan X beta -// @version 1.14.5.0 +// @version 1.14.5.1 // @minGMVer 1.14 // @minFFVer 26 // @namespace 4chan-X @@ -198,7 +198,7 @@ docSet = function() { }; g = { - VERSION: '1.14.5.0', + VERSION: '1.14.5.1', NAMESPACE: '4chan X.', boards: {} }; @@ -7340,7 +7340,8 @@ SW = {}; comment: '.body', spoiler: '.spoiler', quotelink: 'a[onclick^="highlightReply("]', - boardList: '.boardlist' + boardList: '.boardlist', + styleSheet: '#stylesheet' }, xpath: { thread: 'div[starts-with(@id,"thread_")]', @@ -7453,7 +7454,8 @@ SW = {}; comment: '.postMessage', spoiler: 's', quotelink: ':not(pre) > .quotelink', - boardList: '#boardNavDesktop > .boardList' + boardList: '#boardNavDesktop > .boardList', + styleSheet: 'link[title=switch]' }, xpath: { thread: 'div[contains(concat(" ",@class," ")," thread ")]', @@ -25302,59 +25304,71 @@ Main = (function() { return Main.setClass(); }, setClass: function() { - var mainStyleSheet, setStyle, style, styleSheets; - if (g.VIEW === 'catalog') { - $.addClass(doc, $.id('base-css').href.match(/catalog_(\w+)/)[1].replace('_new', '').replace(/_+/g, '-')); - return; + var knownStyles, mainStyleSheet, ref, setStyle, style, styleSheets; + knownStyles = ['yotsuba', 'yotsuba-b', 'futaba', 'burichan', 'photon', 'tomorrow', 'spooky']; + if (Site.software === 'yotsuba' && g.VIEW === 'catalog') { + if ((mainStyleSheet = $.id('base-css'))) { + style = (ref = mainStyleSheet.href.match(/catalog_(\w+)/)) != null ? ref[1].replace('_new', '').replace(/_+/g, '-') : void 0; + if (indexOf.call(knownStyles, style) >= 0) { + $.addClass(doc, style); + return; + } + } } - style = 'yotsuba-b'; - mainStyleSheet = $('link[title=switch]', d.head); - styleSheets = $$('link[rel="alternate stylesheet"]', d.head); + style = mainStyleSheet = styleSheets = null; setStyle = function() { var bgColor, div, j, len, rgb, s, styleSheet; - $.rmClass(doc, style); - style = null; - for (j = 0, len = styleSheets.length; j < len; j++) { - styleSheet = styleSheets[j]; - if (styleSheet.href === (mainStyleSheet != null ? mainStyleSheet.href : void 0)) { - style = styleSheet.title.toLowerCase().replace('new', '').trim().replace(/\s+/g, '-'); - if (style === '_special') { - style = styleSheet.href.match(/[a-z]*(?=[^\/]*$)/)[0]; + if (Site.software === 'yotsuba') { + $.rmClass(doc, style); + style = null; + for (j = 0, len = styleSheets.length; j < len; j++) { + styleSheet = styleSheets[j]; + if (styleSheet.href === (mainStyleSheet != null ? mainStyleSheet.href : void 0)) { + style = styleSheet.title.toLowerCase().replace('new', '').trim().replace(/\s+/g, '-'); + if (style === '_special') { + style = styleSheet.href.match(/[a-z]*(?=[^\/]*$)/)[0]; + } + if (indexOf.call(knownStyles, style) < 0) { + style = null; + } + break; } - if (style !== 'yotsuba' && style !== 'yotsuba-b' && style !== 'futaba' && style !== 'burichan' && style !== 'photon' && style !== 'tomorrow' && style !== 'spooky') { - style = null; - } - break; + } + if (style) { + $.addClass(doc, style); + $.rm(Main.bgColorStyle); + return; } } - if (style) { - $.addClass(doc, style); - return $.rm(Main.bgColorStyle); - } else { - div = Site.bgColoredEl(); - div.style.position = 'absolute'; - div.style.visibility = 'hidden'; - $.add(d.body, div); - bgColor = window.getComputedStyle(div).backgroundColor; - c.log(bgColor); - $.rm(div); - rgb = bgColor.match(/[\d.]+/g); - if (!/^rgb\(/.test(bgColor)) { - s = window.getComputedStyle(d.body); - bgColor = s.backgroundColor + " " + s.backgroundImage + " " + s.backgroundRepeat + " " + s.backgroundPosition; - } - Main.bgColorStyle.textContent = ".dialog, .suboption-list > div:last-of-type, :root.catalog-hover-expand .catalog-container:hover > .post {\n background: " + bgColor + ";\n}\n.unread-mark-read {\n background-color: rgba(" + (rgb.slice(0, 3).join(', ')) + ", " + (0.5 * (rgb[3] || 1)) + ");\n}"; - return $.after($.id('fourchanx-css'), Main.bgColorStyle); + div = Site.bgColoredEl(); + div.style.position = 'absolute'; + div.style.visibility = 'hidden'; + $.add(d.body, div); + bgColor = window.getComputedStyle(div).backgroundColor; + $.rm(div); + rgb = bgColor.match(/[\d.]+/g); + if (!/^rgb\(/.test(bgColor)) { + s = window.getComputedStyle(d.body); + bgColor = s.backgroundColor + " " + s.backgroundImage + " " + s.backgroundRepeat + " " + s.backgroundPosition; } + Main.bgColorStyle.textContent = ".dialog, .suboption-list > div:last-of-type, :root.catalog-hover-expand .catalog-container:hover > .post {\n background: " + bgColor + ";\n}\n.unread-mark-read {\n background-color: rgba(" + (rgb.slice(0, 3).join(', ')) + ", " + (0.5 * (rgb[3] || 1)) + ");\n}"; + return $.after($.id('fourchanx-css'), Main.bgColorStyle); }; - setStyle(); - if (!mainStyleSheet) { - return; - } - return new MutationObserver(setStyle).observe(mainStyleSheet, { - attributes: true, - attributeFilter: ['href'] + $.onExists(d.head, Site.selectors.styleSheet, function(el) { + mainStyleSheet = el; + if (Site.software === 'yotsuba') { + styleSheets = $$('link[rel="alternate stylesheet"]', d.head); + } + new MutationObserver(setStyle).observe(mainStyleSheet, { + attributes: true, + attributeFilter: ['href'] + }); + $.on(mainStyleSheet, 'load', setStyle); + return setStyle(); }); + if (!mainStyleSheet) { + return setStyle(); + } }, initReady: function() { var msg; diff --git a/builds/4chan-X-noupdate.crx b/builds/4chan-X-noupdate.crx index 5d48ddd5f..0dc30db50 100644 Binary files a/builds/4chan-X-noupdate.crx and b/builds/4chan-X-noupdate.crx differ diff --git a/builds/4chan-X-noupdate.user.js b/builds/4chan-X-noupdate.user.js index dd730c15c..6d043de2c 100644 --- a/builds/4chan-X-noupdate.user.js +++ b/builds/4chan-X-noupdate.user.js @@ -1,6 +1,6 @@ // ==UserScript== // @name 4chan X -// @version 1.14.5.0 +// @version 1.14.5.1 // @minGMVer 1.14 // @minFFVer 26 // @namespace 4chan-X @@ -198,7 +198,7 @@ docSet = function() { }; g = { - VERSION: '1.14.5.0', + VERSION: '1.14.5.1', NAMESPACE: '4chan X.', boards: {} }; @@ -7340,7 +7340,8 @@ SW = {}; comment: '.body', spoiler: '.spoiler', quotelink: 'a[onclick^="highlightReply("]', - boardList: '.boardlist' + boardList: '.boardlist', + styleSheet: '#stylesheet' }, xpath: { thread: 'div[starts-with(@id,"thread_")]', @@ -7453,7 +7454,8 @@ SW = {}; comment: '.postMessage', spoiler: 's', quotelink: ':not(pre) > .quotelink', - boardList: '#boardNavDesktop > .boardList' + boardList: '#boardNavDesktop > .boardList', + styleSheet: 'link[title=switch]' }, xpath: { thread: 'div[contains(concat(" ",@class," ")," thread ")]', @@ -25302,59 +25304,71 @@ Main = (function() { return Main.setClass(); }, setClass: function() { - var mainStyleSheet, setStyle, style, styleSheets; - if (g.VIEW === 'catalog') { - $.addClass(doc, $.id('base-css').href.match(/catalog_(\w+)/)[1].replace('_new', '').replace(/_+/g, '-')); - return; + var knownStyles, mainStyleSheet, ref, setStyle, style, styleSheets; + knownStyles = ['yotsuba', 'yotsuba-b', 'futaba', 'burichan', 'photon', 'tomorrow', 'spooky']; + if (Site.software === 'yotsuba' && g.VIEW === 'catalog') { + if ((mainStyleSheet = $.id('base-css'))) { + style = (ref = mainStyleSheet.href.match(/catalog_(\w+)/)) != null ? ref[1].replace('_new', '').replace(/_+/g, '-') : void 0; + if (indexOf.call(knownStyles, style) >= 0) { + $.addClass(doc, style); + return; + } + } } - style = 'yotsuba-b'; - mainStyleSheet = $('link[title=switch]', d.head); - styleSheets = $$('link[rel="alternate stylesheet"]', d.head); + style = mainStyleSheet = styleSheets = null; setStyle = function() { var bgColor, div, j, len, rgb, s, styleSheet; - $.rmClass(doc, style); - style = null; - for (j = 0, len = styleSheets.length; j < len; j++) { - styleSheet = styleSheets[j]; - if (styleSheet.href === (mainStyleSheet != null ? mainStyleSheet.href : void 0)) { - style = styleSheet.title.toLowerCase().replace('new', '').trim().replace(/\s+/g, '-'); - if (style === '_special') { - style = styleSheet.href.match(/[a-z]*(?=[^\/]*$)/)[0]; + if (Site.software === 'yotsuba') { + $.rmClass(doc, style); + style = null; + for (j = 0, len = styleSheets.length; j < len; j++) { + styleSheet = styleSheets[j]; + if (styleSheet.href === (mainStyleSheet != null ? mainStyleSheet.href : void 0)) { + style = styleSheet.title.toLowerCase().replace('new', '').trim().replace(/\s+/g, '-'); + if (style === '_special') { + style = styleSheet.href.match(/[a-z]*(?=[^\/]*$)/)[0]; + } + if (indexOf.call(knownStyles, style) < 0) { + style = null; + } + break; } - if (style !== 'yotsuba' && style !== 'yotsuba-b' && style !== 'futaba' && style !== 'burichan' && style !== 'photon' && style !== 'tomorrow' && style !== 'spooky') { - style = null; - } - break; + } + if (style) { + $.addClass(doc, style); + $.rm(Main.bgColorStyle); + return; } } - if (style) { - $.addClass(doc, style); - return $.rm(Main.bgColorStyle); - } else { - div = Site.bgColoredEl(); - div.style.position = 'absolute'; - div.style.visibility = 'hidden'; - $.add(d.body, div); - bgColor = window.getComputedStyle(div).backgroundColor; - c.log(bgColor); - $.rm(div); - rgb = bgColor.match(/[\d.]+/g); - if (!/^rgb\(/.test(bgColor)) { - s = window.getComputedStyle(d.body); - bgColor = s.backgroundColor + " " + s.backgroundImage + " " + s.backgroundRepeat + " " + s.backgroundPosition; - } - Main.bgColorStyle.textContent = ".dialog, .suboption-list > div:last-of-type, :root.catalog-hover-expand .catalog-container:hover > .post {\n background: " + bgColor + ";\n}\n.unread-mark-read {\n background-color: rgba(" + (rgb.slice(0, 3).join(', ')) + ", " + (0.5 * (rgb[3] || 1)) + ");\n}"; - return $.after($.id('fourchanx-css'), Main.bgColorStyle); + div = Site.bgColoredEl(); + div.style.position = 'absolute'; + div.style.visibility = 'hidden'; + $.add(d.body, div); + bgColor = window.getComputedStyle(div).backgroundColor; + $.rm(div); + rgb = bgColor.match(/[\d.]+/g); + if (!/^rgb\(/.test(bgColor)) { + s = window.getComputedStyle(d.body); + bgColor = s.backgroundColor + " " + s.backgroundImage + " " + s.backgroundRepeat + " " + s.backgroundPosition; } + Main.bgColorStyle.textContent = ".dialog, .suboption-list > div:last-of-type, :root.catalog-hover-expand .catalog-container:hover > .post {\n background: " + bgColor + ";\n}\n.unread-mark-read {\n background-color: rgba(" + (rgb.slice(0, 3).join(', ')) + ", " + (0.5 * (rgb[3] || 1)) + ");\n}"; + return $.after($.id('fourchanx-css'), Main.bgColorStyle); }; - setStyle(); - if (!mainStyleSheet) { - return; - } - return new MutationObserver(setStyle).observe(mainStyleSheet, { - attributes: true, - attributeFilter: ['href'] + $.onExists(d.head, Site.selectors.styleSheet, function(el) { + mainStyleSheet = el; + if (Site.software === 'yotsuba') { + styleSheets = $$('link[rel="alternate stylesheet"]', d.head); + } + new MutationObserver(setStyle).observe(mainStyleSheet, { + attributes: true, + attributeFilter: ['href'] + }); + $.on(mainStyleSheet, 'load', setStyle); + return setStyle(); }); + if (!mainStyleSheet) { + return setStyle(); + } }, initReady: function() { var msg; diff --git a/builds/4chan-X.crx b/builds/4chan-X.crx index cfbaf9c4f..8928adce6 100644 Binary files a/builds/4chan-X.crx and b/builds/4chan-X.crx differ diff --git a/builds/4chan-X.meta.js b/builds/4chan-X.meta.js index cdccd8a11..a6b87b76e 100644 --- a/builds/4chan-X.meta.js +++ b/builds/4chan-X.meta.js @@ -1,6 +1,6 @@ // ==UserScript== // @name 4chan X -// @version 1.14.5.0 +// @version 1.14.5.1 // @minGMVer 1.14 // @minFFVer 26 // @namespace 4chan-X diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index eaf6c0402..6a40d6325 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -1,6 +1,6 @@ // ==UserScript== // @name 4chan X -// @version 1.14.5.0 +// @version 1.14.5.1 // @minGMVer 1.14 // @minFFVer 26 // @namespace 4chan-X @@ -198,7 +198,7 @@ docSet = function() { }; g = { - VERSION: '1.14.5.0', + VERSION: '1.14.5.1', NAMESPACE: '4chan X.', boards: {} }; @@ -7340,7 +7340,8 @@ SW = {}; comment: '.body', spoiler: '.spoiler', quotelink: 'a[onclick^="highlightReply("]', - boardList: '.boardlist' + boardList: '.boardlist', + styleSheet: '#stylesheet' }, xpath: { thread: 'div[starts-with(@id,"thread_")]', @@ -7453,7 +7454,8 @@ SW = {}; comment: '.postMessage', spoiler: 's', quotelink: ':not(pre) > .quotelink', - boardList: '#boardNavDesktop > .boardList' + boardList: '#boardNavDesktop > .boardList', + styleSheet: 'link[title=switch]' }, xpath: { thread: 'div[contains(concat(" ",@class," ")," thread ")]', @@ -25302,59 +25304,71 @@ Main = (function() { return Main.setClass(); }, setClass: function() { - var mainStyleSheet, setStyle, style, styleSheets; - if (g.VIEW === 'catalog') { - $.addClass(doc, $.id('base-css').href.match(/catalog_(\w+)/)[1].replace('_new', '').replace(/_+/g, '-')); - return; + var knownStyles, mainStyleSheet, ref, setStyle, style, styleSheets; + knownStyles = ['yotsuba', 'yotsuba-b', 'futaba', 'burichan', 'photon', 'tomorrow', 'spooky']; + if (Site.software === 'yotsuba' && g.VIEW === 'catalog') { + if ((mainStyleSheet = $.id('base-css'))) { + style = (ref = mainStyleSheet.href.match(/catalog_(\w+)/)) != null ? ref[1].replace('_new', '').replace(/_+/g, '-') : void 0; + if (indexOf.call(knownStyles, style) >= 0) { + $.addClass(doc, style); + return; + } + } } - style = 'yotsuba-b'; - mainStyleSheet = $('link[title=switch]', d.head); - styleSheets = $$('link[rel="alternate stylesheet"]', d.head); + style = mainStyleSheet = styleSheets = null; setStyle = function() { var bgColor, div, j, len, rgb, s, styleSheet; - $.rmClass(doc, style); - style = null; - for (j = 0, len = styleSheets.length; j < len; j++) { - styleSheet = styleSheets[j]; - if (styleSheet.href === (mainStyleSheet != null ? mainStyleSheet.href : void 0)) { - style = styleSheet.title.toLowerCase().replace('new', '').trim().replace(/\s+/g, '-'); - if (style === '_special') { - style = styleSheet.href.match(/[a-z]*(?=[^\/]*$)/)[0]; + if (Site.software === 'yotsuba') { + $.rmClass(doc, style); + style = null; + for (j = 0, len = styleSheets.length; j < len; j++) { + styleSheet = styleSheets[j]; + if (styleSheet.href === (mainStyleSheet != null ? mainStyleSheet.href : void 0)) { + style = styleSheet.title.toLowerCase().replace('new', '').trim().replace(/\s+/g, '-'); + if (style === '_special') { + style = styleSheet.href.match(/[a-z]*(?=[^\/]*$)/)[0]; + } + if (indexOf.call(knownStyles, style) < 0) { + style = null; + } + break; } - if (style !== 'yotsuba' && style !== 'yotsuba-b' && style !== 'futaba' && style !== 'burichan' && style !== 'photon' && style !== 'tomorrow' && style !== 'spooky') { - style = null; - } - break; + } + if (style) { + $.addClass(doc, style); + $.rm(Main.bgColorStyle); + return; } } - if (style) { - $.addClass(doc, style); - return $.rm(Main.bgColorStyle); - } else { - div = Site.bgColoredEl(); - div.style.position = 'absolute'; - div.style.visibility = 'hidden'; - $.add(d.body, div); - bgColor = window.getComputedStyle(div).backgroundColor; - c.log(bgColor); - $.rm(div); - rgb = bgColor.match(/[\d.]+/g); - if (!/^rgb\(/.test(bgColor)) { - s = window.getComputedStyle(d.body); - bgColor = s.backgroundColor + " " + s.backgroundImage + " " + s.backgroundRepeat + " " + s.backgroundPosition; - } - Main.bgColorStyle.textContent = ".dialog, .suboption-list > div:last-of-type, :root.catalog-hover-expand .catalog-container:hover > .post {\n background: " + bgColor + ";\n}\n.unread-mark-read {\n background-color: rgba(" + (rgb.slice(0, 3).join(', ')) + ", " + (0.5 * (rgb[3] || 1)) + ");\n}"; - return $.after($.id('fourchanx-css'), Main.bgColorStyle); + div = Site.bgColoredEl(); + div.style.position = 'absolute'; + div.style.visibility = 'hidden'; + $.add(d.body, div); + bgColor = window.getComputedStyle(div).backgroundColor; + $.rm(div); + rgb = bgColor.match(/[\d.]+/g); + if (!/^rgb\(/.test(bgColor)) { + s = window.getComputedStyle(d.body); + bgColor = s.backgroundColor + " " + s.backgroundImage + " " + s.backgroundRepeat + " " + s.backgroundPosition; } + Main.bgColorStyle.textContent = ".dialog, .suboption-list > div:last-of-type, :root.catalog-hover-expand .catalog-container:hover > .post {\n background: " + bgColor + ";\n}\n.unread-mark-read {\n background-color: rgba(" + (rgb.slice(0, 3).join(', ')) + ", " + (0.5 * (rgb[3] || 1)) + ");\n}"; + return $.after($.id('fourchanx-css'), Main.bgColorStyle); }; - setStyle(); - if (!mainStyleSheet) { - return; - } - return new MutationObserver(setStyle).observe(mainStyleSheet, { - attributes: true, - attributeFilter: ['href'] + $.onExists(d.head, Site.selectors.styleSheet, function(el) { + mainStyleSheet = el; + if (Site.software === 'yotsuba') { + styleSheets = $$('link[rel="alternate stylesheet"]', d.head); + } + new MutationObserver(setStyle).observe(mainStyleSheet, { + attributes: true, + attributeFilter: ['href'] + }); + $.on(mainStyleSheet, 'load', setStyle); + return setStyle(); }); + if (!mainStyleSheet) { + return setStyle(); + } }, initReady: function() { var msg; diff --git a/builds/4chan-X.zip b/builds/4chan-X.zip index f73ef209a..2c4279989 100644 Binary files a/builds/4chan-X.zip and b/builds/4chan-X.zip differ diff --git a/builds/updates-beta.json b/builds/updates-beta.json index 71fe47875..e9dec896f 100644 --- a/builds/updates-beta.json +++ b/builds/updates-beta.json @@ -3,7 +3,7 @@ "4chan-x@4chan-x.net": { "updates": [ { - "version": "1.14.5.0", + "version": "1.14.5.1", "update_link": "https://www.4chan-x.net/builds/4chan-X-beta.crx" } ] diff --git a/builds/updates-beta.xml b/builds/updates-beta.xml index f1d2a59d7..26a10933c 100644 --- a/builds/updates-beta.xml +++ b/builds/updates-beta.xml @@ -1,7 +1,7 @@ - + diff --git a/builds/updates.json b/builds/updates.json index ee75d8807..02ec08fdb 100644 --- a/builds/updates.json +++ b/builds/updates.json @@ -3,7 +3,7 @@ "4chan-x@4chan-x.net": { "updates": [ { - "version": "1.14.5.0", + "version": "1.14.5.1", "update_link": "https://www.4chan-x.net/builds/4chan-X.crx" } ] diff --git a/builds/updates.xml b/builds/updates.xml index 2470be9bf..87720770e 100644 --- a/builds/updates.xml +++ b/builds/updates.xml @@ -1,7 +1,7 @@ - + diff --git a/version.json b/version.json index b454c1100..b97470b20 100644 --- a/version.json +++ b/version.json @@ -1,4 +1,4 @@ { - "version": "1.14.5.0", - "date": "2018-12-06T04:19:59.545Z" + "version": "1.14.5.1", + "date": "2018-12-06T17:15:24.488Z" } \ No newline at end of file