2019-09-20 22:32:52 +02:00
//META{"name":"ThemeRepo","website":"https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/ThemeRepo","source":"https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/ThemeRepo/ThemeRepo.plugin.js"}*//
2018-10-11 10:21:26 +02:00
class ThemeRepo {
2019-01-12 15:07:06 +01:00
getName ( ) { return "ThemeRepo" ; }
2019-10-11 23:21:52 +02:00
getVersion ( ) { return "1.8.9" ; }
2019-01-12 15:07:06 +01:00
getAuthor ( ) { return "DevilBro" ; }
getDescription ( ) { return "Allows you to preview all themes from the theme repo and download them on the fly. Repo button is in the theme settings." ; }
2019-01-26 22:45:19 +01:00
2019-09-04 12:34:02 +02:00
constructor ( ) {
2019-02-05 13:01:32 +01:00
this . changelog = {
2019-10-11 23:21:52 +02:00
"improved" : [ [ "ThemeFixer" , "Fixed and improved" ] ]
2019-02-05 13:01:32 +01:00
} ;
2019-09-04 12:34:02 +02:00
2019-01-07 20:25:35 +01:00
this . patchModules = {
"V2C_List" : "componentDidMount"
} ;
2019-09-04 12:34:02 +02:00
}
2019-01-26 22:45:19 +01:00
2019-09-04 12:34:02 +02:00
initConstructor ( ) {
2018-10-11 10:21:26 +02:00
this . sortings = {
sort : {
name : "Name" ,
author : "Author" ,
version : "Version" ,
description : "Description" ,
state : "Update State" ,
2019-04-16 09:52:09 +02:00
fav : "Favorites" ,
new : "New Themes"
2018-10-11 10:21:26 +02:00
} ,
order : {
asc : "Ascending" ,
desc : "Descending"
}
} ;
2019-01-26 22:45:19 +01:00
2018-12-14 11:43:54 +01:00
this . loading = { is : false , timeout : null , amount : 0 } ;
2019-01-26 22:45:19 +01:00
2019-04-16 09:52:09 +02:00
this . cachedThemes = [ ] ;
2018-10-11 10:21:26 +02:00
this . grabbedThemes = [ ] ;
this . foundThemes = [ ] ;
2019-09-04 12:34:02 +02:00
this . loadedThemes = { } ;
2019-09-25 17:35:00 +02:00
this . generatorThemes = [ ] ;
2019-01-26 22:45:19 +01:00
2018-10-11 10:21:26 +02:00
this . updateInterval ;
2019-01-26 22:45:19 +01:00
2018-10-11 10:21:26 +02:00
this . themeRepoButtonMarkup =
` <button class="bd-pfbtn bd-themerepobutton">Theme Repo</button> ` ;
2019-01-26 22:45:19 +01:00
2019-05-01 23:22:51 +02:00
this . themeRepoIconMarkup =
` <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="36" height="31" viewBox="20 0 400 332">
2018-11-25 19:54:05 +01:00
< path d = "M0.000 39.479 L 0.000 78.957 43.575 78.957 L 87.151 78.957 87.151 204.097 L 87.151 329.236 129.609 329.236 L 172.067 329.236 172.067 204.097 L 172.067 78.957 215.642 78.957 L 259.218 78.957 259.218 39.479 L 259.218 0.000 129.609 0.000 L 0.000 0.000 0.000 39.479" stroke = "none" fill = "#7289da" fill - rule = "evenodd" > < / p a t h >
< path d = "M274.115 38.624 L 274.115 77.248 280.261 77.734 C 309.962 80.083,325.986 106.575,313.378 132.486 C 305.279 149.131,295.114 152.700,255.800 152.700 L 230.168 152.700 230.168 123.277 L 230.168 93.855 208.566 93.855 L 186.965 93.855 186.965 211.546 L 186.965 329.236 208.566 329.236 L 230.168 329.236 230.168 277.068 L 230.168 224.899 237.268 225.113 L 244.368 225.326 282.215 277.095 L 320.062 328.864 360.031 329.057 L 400.000 329.249 400.000 313.283 L 400.000 297.317 367.924 256.908 L 335.848 216.499 340.182 214.869 C 376.035 201.391,395.726 170.616,399.382 122.342 C 405.008 48.071,360.214 0.000,285.379 0.000 L 274.115 0.000 274.115 38.624" stroke = "none" fill = "#7f8186" fill - rule = "evenodd" > < / p a t h >
< / s v g > ` ;
2019-01-26 22:45:19 +01:00
2018-10-11 10:21:26 +02:00
this . frameMarkup =
` <iframe class="discordPreview" src="https://mwittrien.github.io/BetterDiscordAddons/Plugins/ThemeRepo/res/DiscordPreview.html"></iframe> ` ;
2019-01-07 20:25:35 +01:00
2018-10-11 10:21:26 +02:00
this . themeEntryMarkup =
2019-01-07 20:25:35 +01:00
` <li class="themeEntry ${ BDFDB . disCNS . _reposettingsclosed + BDFDB . disCN . _repocheckboxitem } ">
< div class = "${BDFDB.disCN._repoheader}" style = "overflow: visible !important;" >
< span class = "${BDFDB.disCN._repoheadertitle}" >
< span class = "${BDFDB.disCN._reponame}" > < / s p a n > v < s p a n c l a s s = " $ { B D F D B . d i s C N . _ r e p o v e r s i o n } " > < / s p a n > b y < s p a n c l a s s = " $ { B D F D B . d i s C N . _ r e p o a u t h o r } " > < / s p a n >
2018-10-11 10:21:26 +02:00
< / s p a n >
2019-01-07 20:25:35 +01:00
< div class = "${BDFDB.disCN._repocontrols}" >
< div tabindex = "0" class = "${BDFDB.disCNS.giffavoritebutton + BDFDB.disCN.giffavoritecolor}" role = "button" style = "width: 24px !important; height: 24px !important; position: relative !important; opacity: 1 !important; transform: none !important;" >
< svg class = "${BDFDB.disCNS.giffavoriteicon}" name = "Favorite" viewBox = "2 2 20 20" width = "24" height = "24" > < / s v g >
< / d i v >
< svg class = "gitIcon" version = "1.1" xmlns = "http://www.w3.org/2000/svg" width = "24" height = "24" fill = "currentColor" transform = "translate(2,1.5)" >
< path d = "M 7.19, 16.027 c -0.139, 0.026 -0.199, 0.091 -0.182, 0.195 c 0.017, 0.104, 0.095, 0.138, 0.234, 0.104 c 0.139 -0.035, 0.199 -0.095, 0.182 -0.182 C 7.406, 16.049, 7.328, 16.01, 7.19, 16.027 z" > < / p a t h >
< path d = "M 6.45, 16.131 c -0.138, 0 -0.208, 0.047 -0.208, 0.143 c 0, 0.112, 0.074, 0.16, 0.221, 0.143 c 0.138, 0, 0.208 -0.048, 0.208 -0.143 C 6.671, 16.162, 6.597, 16.114, 6.45, 16.131 z" > < / p a t h >
< path d = "M 5.438, 16.092 c -0.035, 0.095, 0.022, 0.16, 0.169, 0.195 c 0.13, 0.052, 0.212, 0.026, 0.247 -0.078 c 0.026 -0.095 -0.03 -0.164 -0.169 -0.208 C 5.554, 15.967, 5.472, 15.996, 5.438, 16.092 z" > < / p a t h >
< path d = "M 18.837, 1.097 C 18.106, 0.366, 17.226, 0, 16.196, 0 H 3.738 C 2.708, 0, 1.828, 0.366, 1.097, 1.097 C 0.366, 1.828, 0, 2.708, 0, 3.738 v 12.459 c 0, 1.03, 0.366, 1.91, 1.097, 2.641 c 0.731, 0.731, 1.612, 1.097, 2.641, 1.097 h 2.907 c 0.19, 0, 0.333 -0.007, 0.428 -0.019 c 0.095 -0.013, 0.19 -0.069, 0.285 -0.169 c 0.095 -0.099, 0.143 -0.244, 0.143 -0.435 c 0 -0.026 -0.002 -0.32 -0.007 -0.883 c -0.004 -0.562 -0.007 -1.008 -0.007 -1.337 l -0.298, 0.052 c -0.19, 0.035 -0.43, 0.05 -0.72, 0.045 c -0.29 -0.004 -0.59 -0.035 -0.902 -0.091 c -0.312 -0.056 -0.601 -0.186 -0.87 -0.389 c -0.268 -0.203 -0.458 -0.469 -0.571 -0.798 l -0.13 -0.299 c -0.086 -0.199 -0.223 -0.419 -0.409 -0.662 c -0.186 -0.242 -0.374 -0.407 -0.564 -0.493 l -0.091 -0.065 c -0.06 -0.043 -0.117 -0.095 -0.169 -0.156 c -0.052 -0.061 -0.091 -0.121 -0.117 -0.182 c -0.026 -0.061 -0.004 -0.11, 0.065 -0.149 c 0.069 -0.039, 0.195 -0.058, 0.376 -0.058 l 0.259, 0.039 c 0.173, 0.035, 0.387, 0.138, 0.642, 0.311 c 0.255, 0.173, 0.465, 0.398, 0.629, 0.675 c 0.199, 0.355, 0.439, 0.625, 0.72, 0.811 c 0.281, 0.186, 0.565, 0.279, 0.85, 0.279 s 0.532 -0.022, 0.74 -0.065 c 0.208 -0.043, 0.402 -0.108, 0.584 -0.195 c 0.078 -0.58, 0.29 -1.025, 0.636 -1.337 c -0.493 -0.052 -0.936 -0.13 -1.33 -0.234 c -0.394 -0.104 -0.8 -0.272 -1.22 -0.506 c -0.42 -0.234 -0.768 -0.523 -1.045 -0.87 c -0.277 -0.346 -0.504 -0.8 -0.681 -1.363 c -0.177 -0.562 -0.266 -1.211 -0.266 -1.947 c 0 -1.047, 0.342 -1.938, 1.025 -2.673 c -0.32 -0.787 -0.29 -1.67, 0.091 -2.647 c 0.251 -0.078, 0.623 -0.019, 1.116, 0.175 c 0.493, 0.195, 0.854, 0.361, 1.084, 0.5 c 0.229, 0.138, 0.413, 0.255, 0.552, 0.35 c 0.805 -0.225, 1.635 -0.337, 2.492 -0.337 c 0.856, 0, 1.687, 0.112, 2.492, 0.337 l 0.493 -0.311 c 0.338 -0.208, 0.735 -0.398, 1.194 -0.571 c 0.459 -0.173, 0.809 -0.221, 1.051 -0.143 c 0.389, 0.978, 0.424, 1.86, 0.104, 2.647 c 0.683, 0.735, 1.025, 1.627, 1.025, 2.673 c 0, 0.735 -0.089, 1.387 -0.266, 1.953 c -0.177, 0.567 -0.406, 1.021 -0.688, 1.363 c -0.281, 0.342 -0.632, 0.629 -1.051, 0.863 c -0.42, 0.234 -0.826, 0.402 -1.22, 0.506 c -0.394, 0.104 -0.837, 0.182 -1.33, 0.234 c 0.45, 0.389, 0.675, 1.003, 0.675, 1.843 v 3.102 c 0, 0.147, 0.021, 0.266, 0.065, 0.357 c 0.044, 0.091, 0.113, 0.153, 0.208, 0.188 c 0.096, 0.035, 0.18, 0.056, 0.253, 0.065 c 0.074, 0.009, 0.18, 0.013, 0.318, 0.013 h 2.907 c 1.029, 0, 1.91 -0.366, 2.641 -1.097 c 0.731 -0.731, 1.097 -1.612, 1.097 -2.641 V 3.738 C 19.933, 2.708, 19.568, 1.827, 18.837, 1.097 z" > < / p a t h >
< path d = "M 3.945, 14.509 c -0.06, 0.043 -0.052, 0.112, 0.026, 0.208 c 0.087, 0.086, 0.156, 0.1, 0.208, 0.039 c 0.061 -0.043, 0.052 -0.112 -0.026 -0.208 C 4.066, 14.47, 3.997, 14.457, 3.945, 14.509 z" > < / p a t h >
< path d = "M 3.517, 14.184 c -0.026, 0.061, 0.004, 0.113, 0.091, 0.156 c 0.069, 0.043, 0.126, 0.035, 0.169 -0.026 c 0.026 -0.061 -0.004 -0.113 -0.091 -0.156 C 3.599, 14.132, 3.543, 14.141, 3.517, 14.184 z" > < / p a t h >
< path d = "M 4.348, 15.015 c -0.078, 0.043 -0.078, 0.121, 0, 0.234 c 0.078, 0.113, 0.151, 0.143, 0.221, 0.091 c 0.078 -0.061, 0.078 -0.143, 0 -0.247 C 4.499, 14.981, 4.425, 14.954, 4.348, 15.015 z" > < / p a t h >
< path d = "M 4.802, 15.599 c -0.078, 0.069 -0.061, 0.151, 0.052, 0.247 c 0.104, 0.104, 0.19, 0.117, 0.259, 0.039 c 0.069 -0.069, 0.052 -0.151 -0.052 -0.246 C 4.958, 15.534, 4.871, 15.521, 4.802, 15.599 z" > < / p a t h >
< / s v g >
< div class = "${BDFDB.disCNS.flexchild + BDFDB.disCNS.switchenabled + BDFDB.disCNS.switch + BDFDB.disCNS.switchvalue + BDFDB.disCNS.switchsizedefault + BDFDB.disCNS.switchsize + BDFDB.disCN.switchthemedefault} previewCheckboxWrapper" style = "flex: 0 0 auto;" >
< input type = "checkbox" class = "${BDFDB.disCNS.switchinnerenabled + BDFDB.disCN.switchinner} previewCheckbox" >
< / d i v >
2018-10-11 10:21:26 +02:00
< / d i v >
< / d i v >
2019-01-07 20:25:35 +01:00
< div class = "${BDFDB.disCNS._repodescriptionwrap + BDFDB.disCN.scrollerwrap}" >
< div class = "${BDFDB.disCNS._repodescription + BDFDB.disCN.scroller}" style = "display: block !important;" > < / d i v >
2018-10-11 10:21:26 +02:00
< / d i v >
2019-01-07 20:25:35 +01:00
< div class = "${BDFDB.disCN._repofooter}" >
< span class = "${BDFDB.disCN._repolinks}" > < / s p a n >
< svg class = "trashIcon" version = "1.1" xmlns = "http://www.w3.org/2000/svg" width = "20" height = "20" fill = "currentColor" style = "margin: 0 5px 0 auto !important;" >
2018-12-23 15:35:53 +01:00
< path d = "M 18.012, 0.648 H 12.98 C 12.944, 0.284, 12.637, 0, 12.264, 0 H 8.136 c -0.373, 0 -0.68, 0.284 -0.716, 0.648 H 2.389 c -0.398, 0 -0.72, 0.322 -0.72, 0.72 v 1.368 c 0, 0.398, 0.322, 0.72, 0.72, 0.72 h 15.623 c 0.398, 0, 0.72 -0.322, 0.72 -0.72 V 1.368 C 18.731, 0.97, 18.409, 0.648, 18.012, 0.648 z" > < / p a t h >
< path d = "M 3.178, 4.839 v 14.841 c 0, 0.397, 0.322, 0.72, 0.72, 0.72 h 12.604 c 0.398, 0, 0.72 -0.322, 0.72 -0.72 V 4.839 H 3.178 z M 8.449, 15.978 c 0, 0.438 -0.355, 0.794 -0.794, 0.794 c -0.438, 0 -0.794 -0.355 -0.794 -0.794 V 8.109 c 0 -0.438, 0.355 -0.794, 0.794 -0.794 c 0.438, 0, 0.794, 0.355, 0.794, 0.794 V 15.978 z M 13.538, 15.978 c 0, 0.438 -0.355, 0.794 -0.794, 0.794 s -0.794 -0.355 -0.794 -0.794 V 8.109 c 0 -0.438, 0.355 -0.794, 0.794 -0.794 c 0.438, 0, 0.794, 0.355, 0.794, 0.794 V 15.978 z" > < / p a t h >
< / s v g >
2019-01-07 20:25:35 +01:00
< button class = "${BDFDB.disCN._reposettingsbutton} btn-download" style = "margin-left: 0 !important;" > Download < / b u t t o n >
2018-10-11 10:21:26 +02:00
< / d i v >
< / l i > ` ;
2019-01-26 22:45:19 +01:00
2018-10-11 10:21:26 +02:00
this . themeRepoModalMarkup =
2019-04-18 09:28:20 +02:00
` <span class=" ${ this . name } -modal Repo-modal BDFDB-modal">
2018-10-11 10:21:26 +02:00
< div class = "${BDFDB.disCN.backdrop}" > < / d i v >
< div class = "${BDFDB.disCN.modal}" >
< div class = "${BDFDB.disCN.modalinner}" >
2019-02-17 20:46:17 +01:00
< div class = "${BDFDB.disCNS.modalsub + BDFDB.disCN.modalsizelarge}" >
2019-10-08 11:51:41 +02:00
< div class = "${BDFDB.disCNS.flex + BDFDB.disCNS.horizontal + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.modalheader}" style = "flex: 0 0 auto; padding-bottom: 10px;" >
2018-10-11 10:21:26 +02:00
< div class = "${BDFDB.disCN.flexchild}" style = "flex: 1 1 auto;" >
2019-09-11 12:14:43 +02:00
< h4 class = "${BDFDB.disCNS.h4 + BDFDB.disCNS.defaultcolor + BDFDB.disCN.h4defaultmargin} themeAmount" > Theme Repository < / h 4 >
2019-10-09 14:18:28 +02:00
< div class = "${BDFDB.disCNS.modalguildname + BDFDB.disCNS.small + BDFDB.disCNS.titlesize12 + BDFDB.disCNS.height16 + BDFDB.disCN.primary}" > < / d i v >
2018-10-11 10:21:26 +02:00
< / d i v >
2019-01-22 20:15:31 +01:00
< button type = "button" class = "${BDFDB.disCNS.modalclose + BDFDB.disCNS.flexchild + BDFDB.disCNS.button + BDFDB.disCNS.buttonlookblank + BDFDB.disCNS.buttoncolorbrand + BDFDB.disCN.buttongrow}" >
< div class = "${BDFDB.disCN.buttoncontents}" >
< svg name = "Close" width = "18" height = "18" viewBox = "0 0 12 12" style = "flex: 0 1 auto;" >
< g fill = "none" fill - rule = "evenodd" >
< path d = "M0 0h12v12H0" > < / p a t h >
< path class = "fill" fill = "currentColor" d = "M9.5 3.205L8.795 2.5 6 5.295 3.205 2.5l-.705.705L5.295 6 2.5 8.795l.705.705L6 6.705 8.795 9.5l.705-.705L6.705 6" > < / p a t h >
< / g >
< / s v g >
< / d i v >
< / b u t t o n >
2018-10-11 10:21:26 +02:00
< / d i v >
2019-10-08 11:51:41 +02:00
< div class = "${BDFDB.disCNS.flex + BDFDB.disCNS.horizontal + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCNS.marginbottom8 + BDFDB.disCN.tabbarcontainer}" style = "flex: 0 0 auto; padding-right: 12px;" >
2019-01-12 15:07:06 +01:00
< div class = "${BDFDB.disCNS.tabbar + BDFDB.disCN.tabbartop}" >
2019-04-23 08:26:48 +02:00
< div tab = "themes" class = "${BDFDB.disCNS.settingsitem + BDFDB.disCN.tabbaritem}" > Themes < / d i v >
2019-09-25 17:35:00 +02:00
< div tab = "generator" class = "${BDFDB.disCNS.settingsitem + BDFDB.disCN.tabbaritem}" > Generator < / d i v >
2019-04-23 08:26:48 +02:00
< div tab = "settings" class = "${BDFDB.disCNS.settingsitem + BDFDB.disCN.tabbaritem}" > Settings < / d i v >
2019-01-12 15:07:06 +01:00
< / d i v >
2019-10-08 11:51:41 +02:00
< div class = "${BDFDB.disCNS.flex + BDFDB.disCNS.horizontal + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.quickselect}" >
2018-10-11 10:21:26 +02:00
< div class = "${BDFDB.disCN.quickselectlabel}" > Sort by : < / d i v >
2019-10-08 11:51:41 +02:00
< div class = "${BDFDB.disCNS.flex + BDFDB.disCNS.horizontal + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.quickselectclick} sort-filter" style = "flex: 0 0 auto;" >
2018-10-11 10:21:26 +02:00
< div option = "${Object.keys(this.sortings.sort)[0]}" class = "${BDFDB.disCN.quickselectvalue}" > $ { this . sortings . sort [ Object . keys ( this . sortings . sort ) [ 0 ] ] } < / d i v >
< div class = "${BDFDB.disCN.quickselectarrow}" > < / d i v >
< / d i v >
< / d i v >
2019-10-08 11:51:41 +02:00
< div class = "${BDFDB.disCNS.flex + BDFDB.disCNS.horizontal + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.quickselect}" >
2018-10-11 10:21:26 +02:00
< div class = "${BDFDB.disCN.quickselectlabel}" > Order : < / d i v >
2019-10-08 11:51:41 +02:00
< div class = "${BDFDB.disCNS.flex + BDFDB.disCNS.horizontal + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.quickselectclick} order-filter" style = "flex: 0 0 auto;" >
2018-10-11 10:21:26 +02:00
< div option = "${Object.keys(this.sortings.order)[0]}" class = "${BDFDB.disCN.quickselectvalue}" > $ { this . sortings . order [ Object . keys ( this . sortings . order ) [ 0 ] ] } < / d i v >
< div class = "${BDFDB.disCN.quickselectarrow}" > < / d i v >
< / d i v >
< / d i v >
< / d i v >
2019-10-09 14:18:28 +02:00
< div tab = "themes" class = "${BDFDB.disCNS.scrollerwrap + BDFDB.disCNS.modalcontent + BDFDB.disCNS.scrollerthemed + BDFDB.disCN.scrollerthemeghosthairline} tab-content" >
2018-12-23 15:35:53 +01:00
< div class = "${BDFDB.disCNS.scroller + BDFDB.disCN.modalsubinner}" >
2019-10-08 11:51:41 +02:00
< ul class = "${BDFDB.disCNS.flex + BDFDB.disCNS.vertical + BDFDB.disCNS.justifystart + BDFDB.disCNS.alignstretch + BDFDB.disCNS.nowrap + BDFDB.disCN._repolist} themes" style = "flex: 1 1 auto; display: flex !important; display: flex-direction: column !important; margin: unset !important; width: unset !important;" > < / u l >
2018-10-11 10:21:26 +02:00
< / d i v >
< / d i v >
2019-10-09 14:18:28 +02:00
< div tab = "generator" class = "${BDFDB.disCNS.scrollerwrap + BDFDB.disCNS.modalcontent + BDFDB.disCNS.scrollerthemed + BDFDB.disCN.scrollerthemeghosthairline} tab-content" >
2019-10-08 11:51:41 +02:00
< div class = "${BDFDB.disCNS.flex + BDFDB.disCNS.horizontal + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom20}" style = "flex: 0 0 auto;" >
2019-10-09 14:18:28 +02:00
< h3 class = "${BDFDB.disCNS.titledefault + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.titlesize16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style = "flex: 0 1 auto;" > Generator Theme : < / h 3 >
2019-10-08 11:51:41 +02:00
< div class = "${BDFDB.disCNS.flex + BDFDB.disCNS.horizontal + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCN.nowrap} generator-select" style = "flex: 1 1 auto;" > < / d i v >
2019-09-25 17:35:00 +02:00
< button type = "button" id = "download-generated" class = "${BDFDB.disCNS.flexchild + BDFDB.disCNS.button + BDFDB.disCNS.buttonlookfilled + BDFDB.disCNS.buttoncolorbrand + BDFDB.disCNS.buttonsizemedium + BDFDB.disCN.buttongrow} btn-download" style = "flex: 0 0 auto;" >
< div class = "${BDFDB.disCN.buttoncontents}" > < / d i v >
< / b u t t o n >
< / d i v >
< div class = "${BDFDB.disCNS.scroller + BDFDB.disCN.modalsubinner}" >
2019-10-08 11:51:41 +02:00
< div class = "${BDFDB.disCNS.flex + BDFDB.disCNS.vertical + BDFDB.disCNS.justifystart + BDFDB.disCNS.alignstretch + BDFDB.disCN.nowrap} variables" style = "flex: 1 1 auto;" > < / d i v >
2019-09-25 17:35:00 +02:00
< / d i v >
< / d i v >
2019-10-08 11:51:41 +02:00
< div tab = "settings" class = "${BDFDB.disCNS.flex + BDFDB.disCNS.vertical + BDFDB.disCNS.justifystart + BDFDB.disCNS.alignstretch + BDFDB.disCNS.nowrap + BDFDB.disCN.modalsubinner} tab-content" style = "flex: 1 1 auto;" >
< div class = "${BDFDB.disCNS.flex + BDFDB.disCNS.horizontal + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom20}" style = "flex: 0 0 auto;" >
2019-10-09 14:18:28 +02:00
< h3 class = "${BDFDB.disCNS.titledefault + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.titlesize16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style = "flex: 1 1 auto;" > You can toggle this menu with the "Ctrl" key to take a better look at the preview . < / h 3 >
2018-10-11 10:21:26 +02:00
< / d i v >
2019-10-08 11:51:41 +02:00
< div class = "${BDFDB.disCNS.flex + BDFDB.disCNS.horizontal + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom20}" style = "flex: 0 0 auto;" >
2019-10-09 14:18:28 +02:00
< h3 class = "${BDFDB.disCNS.titledefault + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.titlesize16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style = "flex: 1 1 auto;" > Preview in light mode < / h 3 >
2018-10-11 10:21:26 +02:00
< div class = "${BDFDB.disCNS.flexchild + BDFDB.disCNS.switchenabled + BDFDB.disCNS.switch + BDFDB.disCNS.switchvalue + BDFDB.disCNS.switchsizedefault + BDFDB.disCNS.switchsize + BDFDB.disCN.switchthemedefault}" style = "flex: 0 0 auto;" >
< input type = "checkbox" class = "${BDFDB.disCNS.switchinnerenabled + BDFDB.disCN.switchinner}" id = "input-darklight" >
< / d i v >
< / d i v >
2019-10-08 11:51:41 +02:00
< div class = "${BDFDB.disCNS.flex + BDFDB.disCNS.horizontal + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom20}" style = "flex: 0 0 auto;" >
2019-10-09 14:18:28 +02:00
< h3 class = "${BDFDB.disCNS.titledefault + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.titlesize16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style = "flex: 1 1 auto;" > Preview with normalized classes < / h 3 >
2019-01-22 14:20:04 +01:00
< div class = "${BDFDB.disCNS.flexchild + BDFDB.disCNS.switchenabled + BDFDB.disCNS.switch + BDFDB.disCNS.switchvalue + BDFDB.disCNS.switchsizedefault + BDFDB.disCNS.switchsize + BDFDB.disCN.switchthemedefault}" style = "flex: 0 0 auto;" >
< input type = "checkbox" class = "${BDFDB.disCNS.switchinnerenabled + BDFDB.disCN.switchinner}" id = "input-normalize" >
< / d i v >
< / d i v >
2019-10-08 11:51:41 +02:00
< div class = "${BDFDB.disCNS.flex + BDFDB.disCNS.horizontal + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom20}" style = "flex: 0 0 auto;" >
2019-10-09 14:18:28 +02:00
< h3 class = "${BDFDB.disCNS.titledefault + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.titlesize16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style = "flex: 1 1 auto;" > Include Custom CSS in Preview < / h 3 >
2018-10-11 10:21:26 +02:00
< div class = "${BDFDB.disCNS.flexchild + BDFDB.disCNS.switchenabled + BDFDB.disCNS.switch + BDFDB.disCNS.switchvalue + BDFDB.disCNS.switchsizedefault + BDFDB.disCNS.switchsize + BDFDB.disCN.switchthemedefault}" style = "flex: 0 0 auto;" >
< input type = "checkbox" class = "${BDFDB.disCNS.switchinnerenabled + BDFDB.disCN.switchinner}" id = "input-customcss" >
< / d i v >
< / d i v >
2019-10-08 11:51:41 +02:00
< div class = "${BDFDB.disCNS.flex + BDFDB.disCNS.horizontal + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom20}" style = "flex: 0 0 auto;" >
2019-10-09 14:18:28 +02:00
< h3 class = "${BDFDB.disCNS.titledefault + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.titlesize16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style = "flex: 1 1 auto;" > Include ThemeFixer CSS in Preview < / h 3 >
2018-10-11 10:21:26 +02:00
< div class = "${BDFDB.disCNS.flexchild + BDFDB.disCNS.switchenabled + BDFDB.disCNS.switch + BDFDB.disCNS.switchvalue + BDFDB.disCNS.switchsizedefault + BDFDB.disCNS.switchsize + BDFDB.disCN.switchthemedefault}" style = "flex: 0 0 auto;" >
< input type = "checkbox" class = "${BDFDB.disCNS.switchinnerenabled + BDFDB.disCN.switchinner}" id = "input-themefixer" >
< / d i v >
< / d i v >
2019-10-08 11:51:41 +02:00
< div class = "${BDFDB.disCNS.flex + BDFDB.disCNS.horizontal + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom20}" style = "flex: 0 0 auto;" >
2019-10-09 14:18:28 +02:00
< h3 class = "${BDFDB.disCNS.titledefault + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.titlesize16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style = "flex: 1 1 auto;" > Download ThemeFixer < / h 3 >
2019-09-25 17:35:00 +02:00
< button type = "button" id = "download-themefixer" class = "${BDFDB.disCNS.flexchild + BDFDB.disCNS.button + BDFDB.disCNS.buttonlookfilled + BDFDB.disCNS.buttoncolorbrand + BDFDB.disCNS.buttonsizemedium + BDFDB.disCN.buttongrow} btn-download" style = "flex: 0 0 auto;" >
< div class = "${BDFDB.disCN.buttoncontents}" > < / d i v >
2018-10-11 10:21:26 +02:00
< / b u t t o n >
< / d i v >
2019-10-08 11:51:41 +02:00
< div class = "${BDFDB.disCNS.flex + BDFDB.disCNS.horizontal + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom20}" style = "flex: 0 0 auto;" >
2019-10-09 14:18:28 +02:00
< h3 class = "${BDFDB.disCNS.titledefault + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.titlesize16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style = "flex: 1 1 auto;" > Hide updated Themes . < / h 3 >
2018-10-11 10:21:26 +02:00
< div class = "${BDFDB.disCNS.flexchild + BDFDB.disCNS.switchenabled + BDFDB.disCNS.switch + BDFDB.disCNS.switchvalue + BDFDB.disCNS.switchsizedefault + BDFDB.disCNS.switchsize + BDFDB.disCN.switchthemedefault}" style = "flex: 0 0 auto;" >
< input type = "checkbox" value = "updated" class = "${BDFDB.disCNS.switchinnerenabled + BDFDB.disCN.switchinner} hide-checkbox" id = "input-hideupdated" >
< / d i v >
< / d i v >
2019-10-08 11:51:41 +02:00
< div class = "${BDFDB.disCNS.flex + BDFDB.disCNS.horizontal + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom20}" style = "flex: 0 0 auto;" >
2019-10-09 14:18:28 +02:00
< h3 class = "${BDFDB.disCNS.titledefault + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.titlesize16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style = "flex: 1 1 auto;" > Hide outdated Themes . < / h 3 >
2018-10-11 10:21:26 +02:00
< div class = "${BDFDB.disCNS.flexchild + BDFDB.disCNS.switchenabled + BDFDB.disCNS.switch + BDFDB.disCNS.switchvalue + BDFDB.disCNS.switchsizedefault + BDFDB.disCNS.switchsize + BDFDB.disCN.switchthemedefault}" style = "flex: 0 0 auto;" >
< input type = "checkbox" value = "outdated" class = "${BDFDB.disCNS.switchinnerenabled + BDFDB.disCN.switchinner} hide-checkbox" id = "input-hideoutdated" >
< / d i v >
< / d i v >
2019-10-08 11:51:41 +02:00
< div class = "${BDFDB.disCNS.flex + BDFDB.disCNS.horizontal + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom20}" style = "flex: 0 0 auto;" >
2019-10-09 14:18:28 +02:00
< h3 class = "${BDFDB.disCNS.titledefault + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.titlesize16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style = "flex: 1 1 auto;" > Hide downloadable Themes . < / h 3 >
2018-10-11 10:21:26 +02:00
< div class = "${BDFDB.disCNS.flexchild + BDFDB.disCNS.switchenabled + BDFDB.disCNS.switch + BDFDB.disCNS.switchvalue + BDFDB.disCNS.switchsizedefault + BDFDB.disCNS.switchsize + BDFDB.disCN.switchthemedefault}" style = "flex: 0 0 auto;" >
< input type = "checkbox" value = "downloadable" class = "${BDFDB.disCNS.switchinnerenabled + BDFDB.disCN.switchinner} hide-checkbox" id = "input-hidedownloadable" >
< / d i v >
< / d i v >
2019-10-08 11:51:41 +02:00
< div id = "RNMoption" class = "${BDFDB.disCNS.flex + BDFDB.disCNS.horizontal + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom20}" style = "flex: 0 0 auto;" >
2019-10-09 14:18:28 +02:00
< h3 class = "${BDFDB.disCNS.titledefault + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.titlesize16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style = "flex: 1 1 auto;" > Apply Theme after Download ( Automatic loading enabled ) < / h 3 >
2018-10-11 10:21:26 +02:00
< div class = "${BDFDB.disCNS.flexchild + BDFDB.disCNS.switchenabled + BDFDB.disCNS.switch + BDFDB.disCNS.switchvalue + BDFDB.disCNS.switchsizedefault + BDFDB.disCNS.switchsize + BDFDB.disCN.switchthemedefault}" style = "flex: 0 0 auto;" >
< input type = "checkbox" class = "${BDFDB.disCNS.switchinnerenabled + BDFDB.disCN.switchinner}" id = "input-rnmstart" >
< / d i v >
< / d i v >
< / d i v >
< / d i v >
< / d i v >
< / d i v >
< / s p a n > ` ;
2019-01-26 22:45:19 +01:00
2018-10-11 10:21:26 +02:00
this . sortPopoutMarkup =
` <div class=" ${ BDFDB . disCNS . popout + BDFDB . disCNS . popoutbottomright + BDFDB . disCN . popoutnoshadow } themerepo-sort-popout" style="position: fixed; z-index: 1100; visibility: visible; transform: translateX(-100%) translateY(0%) translateZ(0px);">
< div >
2019-09-11 12:14:43 +02:00
< div class = "${BDFDB.disCN.contextmenu} BDFDB-quickSelectPopout" >
2018-10-11 10:21:26 +02:00
< div class = "${BDFDB.disCN.contextmenuitemgroup}" >
2019-09-11 12:14:43 +02:00
$ { Object . keys ( this . sortings . sort ) . map ( ( key , i ) => ` <div option=" ${ key } " class=" ${ BDFDB . disCNS . contextmenuitem + BDFDB . disCN . contextmenuitemclickable } "><div class=" ${ BDFDB . disCN . contextmenulabel } BDFDB-textscrollwrapper" speed=3><div class="BDFDB-textscroll"> ${ this . sortings . sort [ key ] } </div></div></div> ` ) . join ( "" ) }
2018-10-11 10:21:26 +02:00
< / d i v >
< / d i v >
< / d i v >
< / d i v > ` ;
2019-01-26 22:45:19 +01:00
2018-10-11 10:21:26 +02:00
this . orderPopoutMarkup =
` <div class=" ${ BDFDB . disCNS . popout + BDFDB . disCNS . popoutbottomright + BDFDB . disCN . popoutnoshadow } themerepo-order-popout" style="position: fixed; z-index: 1100; visibility: visible; transform: translateX(-100%) translateY(0%) translateZ(0px);">
< div >
2019-09-11 12:14:43 +02:00
< div class = "${BDFDB.disCN.contextmenu} BDFDB-quickSelectPopout" >
2018-10-11 10:21:26 +02:00
< div class = "${BDFDB.disCN.contextmenuitemgroup}" >
2019-09-11 12:14:43 +02:00
$ { Object . keys ( this . sortings . order ) . map ( ( key , i ) => ` <div option=" ${ key } " class=" ${ BDFDB . disCNS . contextmenuitem + BDFDB . disCN . contextmenuitemclickable } "><div class=" ${ BDFDB . disCN . contextmenulabel } BDFDB-textscrollwrapper" speed=3><div class="BDFDB-textscroll"> ${ this . sortings . order [ key ] } </div></div></div> ` ) . join ( "" ) }
2018-10-11 10:21:26 +02:00
< / d i v >
< / d i v >
< / d i v >
< / d i v > ` ;
2019-01-26 22:45:19 +01:00
2019-04-16 09:52:09 +02:00
this . defaults = {
settings : {
notifyOutdated : { value : true , description : "Notifies you when one of your Themes is outdated." } ,
notifyNewentries : { value : true , description : "Notifies you when there are new entries in the Repo." }
}
} ;
2018-10-11 10:21:26 +02:00
this . css = `
2018-11-25 19:54:05 +01:00
$ { BDFDB . dotCN . app } > . repo - loadingwrapper {
position : absolute ;
bottom : 0 ;
right : 0 ;
z - index : 1000 ;
animation : repo - loadingwrapper - fade 3 s infinite ease ;
}
@ keyframes repo - loadingwrapper - fade {
from { opacity : 0.1 ; }
50 % { opacity : 0.9 ; }
to { opacity : 0.1 ; }
}
2019-04-16 09:52:09 +02:00
iframe . discordPreview {
2018-10-11 10:21:26 +02:00
width : 100 vw ! important ;
height : 100 vh ! important ;
position : absolute ! important ;
2018-12-23 15:35:53 +01:00
z - index : 999 ! important ;
2018-10-11 10:21:26 +02:00
}
2019-04-16 09:52:09 +02:00
iframe . discordPreview ~ $ { BDFDB . dotCN . appmount } {
2018-10-11 10:21:26 +02:00
position : absolute ! important ;
top : 0 ! important ;
}
2019-04-16 09:52:09 +02:00
iframe . discordPreview ~ $ { BDFDB . dotCNS . appmount + BDFDB . dotCN . titlebar } ,
2019-06-14 11:13:15 +02:00
iframe . discordPreview ~ $ { BDFDB . dotCNS . appmount + BDFDB . dotCN . app } > * : not ( . toasts ) : not ( . bd - toasts ) {
2018-12-23 15:35:53 +01:00
opacity : 0 ! important ;
visibility : hidden ! important ;
2018-10-11 10:21:26 +02:00
}
2019-01-24 13:37:08 +01:00
. $ { this . name } - modal . Repo - modal $ { BDFDB . dotCN . modalinner } {
2018-10-11 10:21:26 +02:00
min - height : 100 % ;
2018-12-23 15:35:53 +01:00
min - width : 800 px ;
width : 50 % ;
2018-10-11 10:21:26 +02:00
}
2019-01-24 13:37:08 +01:00
. $ { this . name } - modal . themeEntry $ { BDFDB . dotCN . _repocontrols } > * {
2018-12-23 15:35:53 +01:00
margin - right : 5 px ! important ;
2018-10-11 10:21:26 +02:00
}
2019-01-24 13:37:08 +01:00
. $ { this . name } - modal . themeEntry $ { BDFDB . dotCN . _repocontrols } > . previewCheckboxWrapper {
2019-01-12 15:07:06 +01:00
margin - right : 0 px ! important ;
}
2019-01-24 13:37:08 +01:00
. $ { this . name } - modal . themeEntry svg [ fill = "currentColor" ] ,
. $ { this . name } - modal . themeEntry $ { BDFDB . dotCN . giffavoritebutton } {
2019-01-14 18:55:51 +01:00
cursor : pointer ;
}
2019-01-24 13:37:08 +01:00
. $ { this . name } - modal . themeEntry svg [ fill = "currentColor" ] ,
. $ { this . name } - modal . themeEntry $ { BDFDB . dotCN . giffavoritebutton + BDFDB . notCN . giffavoriteselected } {
2019-01-07 20:25:35 +01:00
color : # 72767 d ! important ;
2018-10-11 10:21:26 +02:00
}
2019-01-24 13:37:08 +01:00
$ { BDFDB . dotCN . themedark } . $ { this . name } - modal . themeEntry svg [ fill = "currentColor" ] ,
$ { BDFDB . dotCN . themedark } . $ { this . name } - modal . themeEntry $ { BDFDB . dotCN . giffavoritebutton + BDFDB . notCN . giffavoriteselected } {
2019-01-07 20:25:35 +01:00
color : # dcddde ! important ;
2018-10-11 10:21:26 +02:00
}
2019-01-24 13:37:08 +01:00
. $ { this . name } - modal . themeEntry . downloadable . trashIcon {
2018-12-23 15:35:53 +01:00
opacity : 0 ! important ;
pointer - events : none ! important ;
2018-10-11 10:21:26 +02:00
} ` ;
}
2019-01-26 22:45:19 +01:00
2018-10-11 10:21:26 +02:00
getSettingsPanel ( ) {
2019-01-22 11:28:32 +01:00
if ( ! global . BDFDB || typeof BDFDB != "object" || ! BDFDB . loaded || ! this . started ) return ;
2019-10-22 19:49:57 +02:00
var settings = BDFDB . DataUtils . get ( this , "settings" ) ;
2019-10-09 14:18:28 +02:00
var settingshtml = ` <div class=" ${ this . name } -settings BDFDB-settings"><div class=" ${ BDFDB . disCNS . titledefault + BDFDB . disCNS . titlesize18 + BDFDB . disCNS . height24 + BDFDB . disCNS . weightnormal + BDFDB . disCN . marginbottom8 } "> ${ this . name } </div><div class="BDFDB-settings-inner"> ` ;
2019-04-16 09:52:09 +02:00
for ( let key in settings ) {
2019-10-09 14:18:28 +02:00
settingshtml += ` <div class=" ${ BDFDB . disCNS . flex + BDFDB . disCNS . horizontal + BDFDB . disCNS . justifystart + BDFDB . disCNS . aligncenter + BDFDB . disCNS . nowrap + BDFDB . disCN . marginbottom8 } " style="flex: 1 1 auto;"><h3 class=" ${ BDFDB . disCNS . titledefault + BDFDB . disCNS . marginreset + BDFDB . disCNS . weightmedium + BDFDB . disCNS . titlesize16 + BDFDB . disCNS . height24 + BDFDB . disCN . flexchild } " style="flex: 1 1 auto;"> ${ this . defaults . settings [ key ] . description } </h3><div class=" ${ BDFDB . disCNS . flexchild + BDFDB . disCNS . switchenabled + BDFDB . disCNS . switch + BDFDB . disCNS . switchvalue + BDFDB . disCNS . switchsizedefault + BDFDB . disCNS . switchsize + BDFDB . disCN . switchthemedefault } " style="flex: 0 0 auto;"><input type="checkbox" value="settings ${ key } " class=" ${ BDFDB . disCNS . switchinnerenabled + BDFDB . disCN . switchinner } settings-switch" ${ settings [ key ] ? " checked" : "" } ></div></div> ` ;
2019-04-16 09:52:09 +02:00
}
2019-10-09 14:18:28 +02:00
settingshtml += ` <div class=" ${ BDFDB . disCNS . flex + BDFDB . disCNS . horizontal + BDFDB . disCNS . justifystart + BDFDB . disCNS . aligncenter + BDFDB . disCNS . nowrap + BDFDB . disCN . marginbottom8 } " style="flex: 0 0 auto;"><h3 class=" ${ BDFDB . disCNS . titledefault + BDFDB . disCNS . marginreset + BDFDB . disCNS . weightmedium + BDFDB . disCNS . titlesize16 + BDFDB . disCNS . height24 + BDFDB . disCN . flexchild } " style="flex: 0 0 auto;">Add Theme:</h3><input type="text" placeholder="Insert Raw Github Link of Theme (https://raw.githubusercontent.com/...)" class=" ${ BDFDB . disCNS . inputdefault + BDFDB . disCNS . input + BDFDB . disCN . titlesize16 } " id="input-themeurl" style="flex: 1 1 auto;"><button type="button" class=" ${ BDFDB . disCNS . flexchild + BDFDB . disCNS . button + BDFDB . disCNS . buttonlookfilled + BDFDB . disCNS . buttoncolorbrand + BDFDB . disCNS . buttonsizemedium + BDFDB . disCN . buttongrow } btn-add btn-addtheme" style="flex: 0 0 auto;"><div class=" ${ BDFDB . disCN . buttoncontents } "></div></button></div> ` ;
settingshtml += ` <h3 class=" ${ BDFDB . disCNS . titledefault + BDFDB . disCNS . marginreset + BDFDB . disCNS . weightmedium + BDFDB . disCNS . titlesize16 + BDFDB . disCNS . height24 + BDFDB . disCN . flexchild } " style="flex: 1 1 auto;">Your additional Theme List:</h3><div class="BDFDB-settings-inner-list theme-list ${ BDFDB . disCN . marginbottom8 } "> ` ;
2019-10-22 20:16:05 +02:00
var ownlist = BDFDB . DataUtils . load ( this , "ownlist" , "ownlist" ) || [ ] ;
2018-10-11 10:21:26 +02:00
if ( ownlist ) for ( let url of ownlist ) {
2019-09-18 10:19:56 +02:00
settingshtml += ` <div class=" ${ BDFDB . disCNS . flex + BDFDB . disCNS . vertical + BDFDB . disCNS . directionrow + BDFDB . disCNS . justifystart + BDFDB . disCNS . alignstretch + BDFDB . disCNS . nowrap + BDFDB . disCNS . margintop4 + BDFDB . disCNS . marginbottom4 + BDFDB . disCN . hovercard } "><div class=" ${ BDFDB . disCN . hovercardinner } "><div class=" ${ BDFDB . disCNS . description + BDFDB . disCNS . formtext + BDFDB . disCNS . note + BDFDB . disCNS . margintop4 + BDFDB . disCNS . modedefault + BDFDB . disCNS . primary + BDFDB . disCN . ellipsis } entryurl"> ${ url } </div></div><div class=" ${ BDFDB . disCN . hovercardbutton } remove-theme"></div></div> ` ;
2018-10-11 10:21:26 +02:00
}
settingshtml += ` </div> ` ;
2019-10-09 14:18:28 +02:00
settingshtml += ` <div class=" ${ BDFDB . disCNS . flex + BDFDB . disCNS . horizontal + BDFDB . disCNS . justifystart + BDFDB . disCNS . aligncenter + BDFDB . disCNS . nowrap + BDFDB . disCN . marginbottom8 } " style="flex: 0 0 auto;"><h3 class=" ${ BDFDB . disCNS . titledefault + BDFDB . disCNS . marginreset + BDFDB . disCNS . weightmedium + BDFDB . disCNS . titlesize16 + BDFDB . disCNS . height24 + BDFDB . disCN . flexchild } " style="flex: 1 1 auto;">Force all Themes to be fetched again.</h3><button type="button" class=" ${ BDFDB . disCNS . flexchild + BDFDB . disCNS . button + BDFDB . disCNS . buttonlookfilled + BDFDB . disCNS . buttoncolorbrand + BDFDB . disCNS . buttonsizemedium + BDFDB . disCN . buttongrow } refresh-button" style="flex: 0 0 auto;"><div class=" ${ BDFDB . disCN . buttoncontents } ">Refresh</div></button></div> ` ;
settingshtml += ` <div class=" ${ BDFDB . disCNS . flex + BDFDB . disCNS . horizontal + BDFDB . disCNS . justifystart + BDFDB . disCNS . aligncenter + BDFDB . disCNS . nowrap + BDFDB . disCN . marginbottom20 } " style="flex: 0 0 auto;"><h3 class=" ${ BDFDB . disCNS . titledefault + BDFDB . disCNS . marginreset + BDFDB . disCNS . weightmedium + BDFDB . disCNS . titlesize16 + BDFDB . disCNS . height24 + BDFDB . disCN . flexchild } " style="flex: 1 1 auto;">Remove all added Themes from your own list.</h3><button type="button" class=" ${ BDFDB . disCNS . flexchild + BDFDB . disCNS . button + BDFDB . disCNS . buttonlookfilled + BDFDB . disCNS . buttoncolorred + BDFDB . disCNS . buttonsizemedium + BDFDB . disCN . buttongrow } remove-all" style="flex: 0 0 auto;"><div class=" ${ BDFDB . disCN . buttoncontents } ">Reset</div></button></div> ` ;
2018-10-11 10:21:26 +02:00
settingshtml += ` </div></div> ` ;
2019-01-26 22:45:19 +01:00
2019-10-23 11:10:01 +02:00
let settingspanel = BDFDB . DOMUtils . create ( settingshtml ) ;
2018-10-11 10:21:26 +02:00
2019-01-14 18:55:51 +01:00
BDFDB . initElements ( settingspanel , this ) ;
2018-10-11 10:21:26 +02:00
2019-10-22 18:55:25 +02:00
BDFDB . ListenerUtils . add ( this , settingspanel , "click" , ".btn-addtheme" , ( ) => { this . addThemeToOwnList ( settingspanel ) ; } ) ;
BDFDB . ListenerUtils . add ( this , settingspanel , "click" , "#input-themeurl" , e => { if ( e . which == 13 ) this . addThemeToOwnList ( settingspanel ) ; } ) ;
BDFDB . ListenerUtils . add ( this , settingspanel , "click" , ".remove-theme" , e => { this . removeThemeFromOwnList ( e ) ; } ) ;
2019-10-22 19:49:57 +02:00
BDFDB . ListenerUtils . add ( this , settingspanel , "click" , ".remove-all" , ( ) => { this . removeAllFromOwnList ( settingspanel ) ; } ) ;
2019-10-22 18:55:25 +02:00
BDFDB . ListenerUtils . add ( this , settingspanel , "click" , ".refresh-button" , ( ) => {
2019-01-14 18:55:51 +01:00
this . loading = { is : false , timeout : null , amount : 0 } ;
this . loadThemes ( ) ;
} ) ;
2019-04-16 10:21:45 +02:00
return settingspanel ;
2018-10-11 10:21:26 +02:00
}
//legacy
load ( ) { }
start ( ) {
2019-02-04 09:13:15 +01:00
if ( ! global . BDFDB ) global . BDFDB = { myPlugins : { } } ;
if ( global . BDFDB && global . BDFDB . myPlugins && typeof global . BDFDB . myPlugins == "object" ) global . BDFDB . myPlugins [ this . getName ( ) ] = this ;
2019-05-26 13:55:26 +02:00
var libraryScript = document . querySelector ( 'head script#BDFDBLibraryScript' ) ;
if ( ! libraryScript || ( performance . now ( ) - libraryScript . getAttribute ( "date" ) ) > 600000 ) {
2018-10-11 10:21:26 +02:00
if ( libraryScript ) libraryScript . remove ( ) ;
libraryScript = document . createElement ( "script" ) ;
2019-05-26 13:55:26 +02:00
libraryScript . setAttribute ( "id" , "BDFDBLibraryScript" ) ;
2018-10-11 10:21:26 +02:00
libraryScript . setAttribute ( "type" , "text/javascript" ) ;
2019-10-18 10:56:41 +02:00
libraryScript . setAttribute ( "src" , "https://mwittrien.github.io/BetterDiscordAddons/Plugins/BDFDB.min.js" ) ;
2019-01-17 23:48:29 +01:00
libraryScript . setAttribute ( "date" , performance . now ( ) ) ;
2019-05-26 13:55:26 +02:00
libraryScript . addEventListener ( "load" , ( ) => { this . initialize ( ) ; } ) ;
2018-10-11 10:21:26 +02:00
document . head . appendChild ( libraryScript ) ;
2019-05-26 13:55:26 +02:00
}
else if ( global . BDFDB && typeof BDFDB === "object" && BDFDB . loaded ) this . initialize ( ) ;
2019-11-01 10:27:07 +01:00
this . startTimeout = setTimeout ( ( ) => {
try { return this . initialize ( ) ; }
catch ( err ) { console . error ( ` %c[ ${ this . getName ( ) } ]%c ` , "color: #3a71c1; font-weight: 700;" , "" , "Fatal Error: Could not initiate plugin! " + err ) ; }
} , 30000 ) ;
2018-10-11 10:21:26 +02:00
}
initialize ( ) {
2019-01-17 23:48:29 +01:00
if ( global . BDFDB && typeof BDFDB === "object" && BDFDB . loaded ) {
2019-01-22 11:05:54 +01:00
if ( this . started ) return ;
2019-10-22 18:55:25 +02:00
BDFDB . PluginUtils . init ( this ) ;
2019-01-26 22:45:19 +01:00
2018-10-11 10:21:26 +02:00
this . loadThemes ( ) ;
2019-01-26 22:45:19 +01:00
2019-11-01 11:09:32 +01:00
this . updateInterval = BDFDB . TimeUtils . interval ( ( ) => { this . checkForNewThemes ( ) ; } , 1000 * 60 * 30 ) ;
2019-01-26 22:45:19 +01:00
2019-10-22 18:55:25 +02:00
BDFDB . ModuleUtils . forceAllUpdates ( this ) ;
2018-10-11 10:21:26 +02:00
}
2019-11-01 10:14:50 +01:00
else console . error ( ` %c[ ${ this . getName ( ) } ]%c ` , "color: #3a71c1; font-weight: 700;" , "" , "Fatal Error: Could not load BD functions!" ) ;
2018-10-11 10:21:26 +02:00
}
stop ( ) {
2019-01-17 23:48:29 +01:00
if ( global . BDFDB && typeof BDFDB === "object" && BDFDB . loaded ) {
2019-10-22 11:37:23 +02:00
this . stopping = true ;
2019-11-01 11:09:32 +01:00
BDFDB . TimeUtils . clear ( this . updateInterval ) ;
BDFDB . TimeUtils . clear ( this . loading . timeout ) ;
2019-01-26 22:45:19 +01:00
2019-10-23 11:10:01 +02:00
BDFDB . DOMUtils . remove ( "iframe.discordPreview" , ".themerepo-notice" , ".bd-themerepobutton" , ".themerepo-loadingicon" , BDFDB . dotCN . app + " > .repo-loadingwrapper:empty" ) ;
2019-01-26 22:45:19 +01:00
2019-10-22 18:55:25 +02:00
BDFDB . PluginUtils . clear ( this ) ;
2018-10-11 10:21:26 +02:00
}
}
2019-01-26 22:45:19 +01:00
2018-10-11 10:21:26 +02:00
// begin of own functions
2019-01-26 22:45:19 +01:00
2019-09-11 12:14:43 +02:00
onUserSettingsCogContextMenu ( instance , menu , returnvalue ) {
2019-11-01 11:09:32 +01:00
BDFDB . TimeUtils . timeout ( ( ) => { for ( let child of returnvalue . props . children ) if ( child && child . props && child . props . label == "BandagedBD" && Array . isArray ( child . props . render ) ) {
2019-10-22 18:55:25 +02:00
const repoItem = BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . ContextMenuItem , {
2019-09-11 12:14:43 +02:00
label : "Theme Repo" ,
action : e => {
2019-11-01 10:14:50 +01:00
if ( ! this . loading . is ) BDFDB . ContextMenuUtils . close ( menu ) ;
2019-09-11 12:14:43 +02:00
this . openThemeRepoModal ( ) ;
}
2019-01-07 20:25:35 +01:00
} ) ;
2019-09-11 12:14:43 +02:00
child . props . render . push ( repoItem ) ;
break ;
} } ) ;
2019-01-07 20:25:35 +01:00
}
2019-01-26 22:45:19 +01:00
2019-09-25 17:35:00 +02:00
processV2CList ( instance , wrapper , returnvalue ) {
2019-01-07 20:25:35 +01:00
if ( ! document . querySelector ( ".bd-themerepobutton" ) && window . PluginUpdates && window . PluginUpdates . plugins && instance . _reactInternalFiber . key && instance . _reactInternalFiber . key . split ( "-" ) [ 0 ] == "theme" ) {
var folderbutton = document . querySelector ( BDFDB . dotCN . _repofolderbutton ) ;
if ( folderbutton ) {
2019-10-23 11:10:01 +02:00
var repoButton = BDFDB . DOMUtils . create ( ` <button class=" ${ BDFDB . disCN . _repofolderbutton } bd-themerepobutton">ThemeRepo</button> ` ) ;
2019-01-07 20:25:35 +01:00
repoButton . addEventListener ( "click" , ( ) => {
2019-10-22 19:49:57 +02:00
this . openThemeRepoModal ( ) ;
2018-10-11 10:21:26 +02:00
} ) ;
2019-01-07 20:25:35 +01:00
repoButton . addEventListener ( "mouseenter" , ( ) => {
2019-10-22 18:55:25 +02:00
BDFDB . TooltipUtils . create ( repoButton , "Open Theme Repo" , { type : "top" , selector : "themerepo-button-tooltip" } ) ;
2019-01-26 22:45:19 +01:00
} ) ;
2019-01-07 20:25:35 +01:00
folderbutton . parentElement . insertBefore ( repoButton , folderbutton . nextSibling ) ;
2018-10-11 10:21:26 +02:00
}
}
2019-01-07 20:25:35 +01:00
} ;
2019-01-26 22:45:19 +01:00
2018-10-11 10:21:26 +02:00
addThemeToOwnList ( settingspanel ) {
var themeUrlInput = settingspanel . querySelector ( "#input-themeurl" ) ;
var themeList = settingspanel . querySelector ( ".theme-list" ) ;
if ( themeUrlInput && themeList ) {
var url = themeUrlInput . value ;
themeUrlInput . value = null ;
2019-10-22 20:16:05 +02:00
var ownlist = BDFDB . DataUtils . load ( this , "ownlist" , "ownlist" ) || [ ] ;
2018-10-11 10:21:26 +02:00
if ( ! ownlist . includes ( url ) ) {
ownlist . push ( url ) ;
2019-10-22 20:16:05 +02:00
BDFDB . DataUtils . save ( ownlist , this , "ownlist" , "ownlist" ) ;
2019-10-23 11:10:01 +02:00
let entry = BDFDB . DOMUtils . create ( ` <div class=" ${ BDFDB . disCNS . flex + BDFDB . disCNS . vertical + BDFDB . disCNS . directionrow + BDFDB . disCNS . justifystart + BDFDB . disCNS . alignstretch + BDFDB . disCNS . nowrap + BDFDB . disCNS . margintop4 + BDFDB . disCNS . marginbottom4 + BDFDB . disCN . hovercard } "><div class=" ${ BDFDB . disCN . hovercardinner } "><div class=" ${ BDFDB . disCNS . description + BDFDB . disCNS . formtext + BDFDB . disCNS . note + BDFDB . disCNS . margintop4 + BDFDB . disCNS . modedefault + BDFDB . disCNS . primary + BDFDB . disCN . ellipsis } entryurl"> ${ url } </div></div><div class=" ${ BDFDB . disCN . hovercardbutton } remove-theme"></div></div> ` ) ;
2019-10-22 18:55:25 +02:00
BDFDB . ListenerUtils . addToChildren ( entry , "click" , ".remove-theme" , e => { this . removeThemeFromOwnList ( e ) ; } ) ;
2019-01-17 23:48:29 +01:00
themeList . appendChild ( entry ) ;
2018-10-11 10:21:26 +02:00
}
}
}
2019-01-26 22:45:19 +01:00
2018-10-11 10:21:26 +02:00
removeThemeFromOwnList ( e ) {
var entry = e . currentTarget . parentElement ;
var url = entry . querySelector ( ".entryurl" ) . textContent ;
entry . remove ( ) ;
2019-10-22 20:16:05 +02:00
var ownlist = BDFDB . DataUtils . load ( this , "ownlist" , "ownlist" ) || [ ] ;
2019-10-22 18:55:25 +02:00
BDFDB . ArrayUtils . remove ( ownlist , url ) ;
2019-10-22 20:16:05 +02:00
BDFDB . DataUtils . save ( ownlist , this , "ownlist" , "ownlist" ) ;
2018-10-11 10:21:26 +02:00
}
2019-01-26 22:45:19 +01:00
2019-01-17 23:48:29 +01:00
removeAllFromOwnList ( settingspanel ) {
2019-10-30 13:27:14 +01:00
BDFDB . ModalUtils . confirm ( this , "Are you sure you want to remove all added Themes from your own list?" , ( ) => {
2019-10-22 20:16:05 +02:00
BDFDB . DataUtils . save ( [ ] , this , "ownlist" , "ownlist" ) ;
2019-10-23 11:10:01 +02:00
BDFDB . DOMUtils . remove ( settingspanel . querySelector ( BDFDB . dotCN . hovercard ) ) ;
2019-01-06 23:37:28 +01:00
} ) ;
2018-10-11 10:21:26 +02:00
}
2019-01-26 22:45:19 +01:00
2019-04-16 09:52:09 +02:00
openThemeRepoModal ( options = { } ) {
2018-12-14 11:43:54 +01:00
if ( this . loading . is ) {
2019-10-22 18:55:25 +02:00
BDFDB . NotificationUtils . toast ( ` Themes are still being fetched. Try again in some seconds. ` , { type : "danger" } ) ;
2018-10-11 10:21:26 +02:00
return ;
}
2019-01-26 22:45:19 +01:00
2019-01-14 18:55:51 +01:00
var keyPressed = e => {
2019-09-27 13:10:10 +02:00
if ( e . which == 17 ) {
var toggle = true ;
for ( let ele of themeRepoModal . querySelectorAll ( ".varinput, " + BDFDB . dotCN . searchbarinput ) ) if ( ele == document . activeElement ) {
toggle = false ;
break ;
}
2019-10-23 11:10:01 +02:00
if ( toggle ) BDFDB . DOMUtils . toggle ( themeRepoModal ) ;
2019-09-27 13:10:10 +02:00
}
else if ( e . which == 27 ) frame . remove ( ) ;
2019-01-14 18:55:51 +01:00
} ;
2019-01-26 22:45:19 +01:00
2019-01-14 18:55:51 +01:00
var messageReceived = e => {
2019-06-14 11:13:15 +02:00
if ( ! document . contains ( frame ) ) {
document . removeEventListener ( "keyup" , keyPressed ) ;
window . removeEventListener ( "message" , messageReceived ) ;
}
else if ( typeof e . data === "object" && e . data . origin == "DiscordPreview" ) {
2019-01-14 18:55:51 +01:00
switch ( e . data . reason ) {
case "OnLoad" :
2019-10-22 18:55:25 +02:00
var username = BDFDB . UserUtils . me . username ;
var id = BDFDB . UserUtils . me . id ;
var discriminator = BDFDB . UserUtils . me . discriminator ;
var avatar = BDFDB . UserUtils . getAvatar ( ) ;
2019-01-14 18:55:51 +01:00
var nativecss = document . querySelector ( "head link[rel='stylesheet'][integrity]" ) ;
nativecss = nativecss && nativecss . href ? nativecss . href : null ;
2019-05-29 17:12:16 +02:00
var titlebar = document . querySelector ( BDFDB . dotCN . titlebar ) ;
titlebar = titlebar ? titlebar . outerHTML : null ;
2019-10-09 14:45:23 +02:00
frame . contentWindow . postMessage ( { origin : "ThemeRepo" , reason : "OnLoad" , classes : JSON . stringify ( BDFDB . DiscordClasses ) , classmodules : JSON . stringify ( BDFDB . DiscordClassModules ) , username , id , discriminator , avatar , nativecss , html : document . documentElement . className , titlebar } , "*" ) ;
2019-10-09 15:21:48 +02:00
frame . contentWindow . postMessage ( { origin : "ThemeRepo" , reason : "DarkLight" , checked : darklightinput . checked } , "*" ) ;
2019-04-16 10:35:03 +02:00
frame . contentWindow . postMessage ( { origin : "ThemeRepo" , reason : "Normalize" , checked : normalizeinput . checked } , "*" ) ;
2019-01-14 18:55:51 +01:00
break ;
case "KeyUp" :
2019-01-14 20:12:36 +01:00
keyPressed ( e . data ) ;
2019-01-14 18:55:51 +01:00
break ;
}
}
} ;
2019-01-26 22:45:19 +01:00
2019-09-25 17:35:00 +02:00
var createSelectChoice = index => {
let theme = this . loadedThemes [ this . generatorThemes [ index - 1 ] ] || { name : "-----" , author : "-----" } ;
2019-10-23 11:10:01 +02:00
return ` <div class=" ${ BDFDB . disCNS . title + BDFDB . disCNS . medium + BDFDB . disCNS . primary + BDFDB . disCNS . weightnormal + BDFDB . disCN . cursorpointer } " style="flex: 1 1 auto;"><strong> ${ BDFDB . StringUtils . htmlEscape ( theme . name ) } </strong> by ${ BDFDB . StringUtils . htmlEscape ( theme . author ) } </div> ` ;
2019-09-25 17:35:00 +02:00
} ;
var saveSelectChoice = ( selectWrap , type , index ) => {
let theme = this . loadedThemes [ this . generatorThemes [ index - 1 ] ] || { name : "-----" , author : "-----" } ;
2019-10-23 11:10:01 +02:00
selectWrap . querySelector ( BDFDB . dotCN . title ) . innerHTML = ` <strong> ${ BDFDB . StringUtils . htmlEscape ( theme . name ) } </strong> by ${ BDFDB . StringUtils . htmlEscape ( theme . author ) } ` ;
2019-09-25 17:35:00 +02:00
themeRepoModal . querySelectorAll ( ".previewCheckbox" ) . forEach ( checkbox => {
checkbox . checked = false ;
2019-10-23 11:10:01 +02:00
BDFDB . DOMUtils . removeClass ( checkbox . parentElement , BDFDB . disCN . switchvaluechecked ) ;
BDFDB . DOMUtils . addClass ( checkbox . parentElement , BDFDB . disCN . switchvalueunchecked ) ;
2019-09-25 17:35:00 +02:00
} ) ;
let container = themeRepoModal . querySelector ( ".variables" ) ;
2019-10-23 11:10:01 +02:00
BDFDB . DOMUtils . remove ( themeRepoModal . querySelectorAll ( ".varcontainer" ) ) ;
2019-09-25 17:35:00 +02:00
if ( container && theme . fullcss ) {
frame . contentWindow . postMessage ( { origin : "ThemeRepo" , reason : "NewTheme" , checked : true , css : theme . fullcss } , "*" ) ;
this . createGeneratorVars ( frame , container , theme ) ;
}
} ;
2019-01-14 18:55:51 +01:00
document . addEventListener ( "keyup" , keyPressed ) ;
window . addEventListener ( "message" , messageReceived ) ;
2019-09-04 12:34:02 +02:00
2019-10-23 11:10:01 +02:00
var frame = BDFDB . DOMUtils . create ( this . frameMarkup ) ;
var themeRepoModal = BDFDB . DOMUtils . create ( this . themeRepoModalMarkup ) ;
2019-04-23 14:54:10 +02:00
var tabbar = themeRepoModal . querySelector ( BDFDB . dotCN . tabbar ) ;
tabbar . parentElement . insertBefore ( BDFDB . createSearchBar ( "small" ) , tabbar . nextElementSibling ) ;
2019-10-22 19:49:57 +02:00
var hiddenSettings = BDFDB . DataUtils . load ( this , "hidden" ) ;
2019-01-14 18:55:51 +01:00
var darklightinput = themeRepoModal . querySelector ( "#input-darklight" ) ;
2019-01-22 14:20:04 +01:00
var normalizeinput = themeRepoModal . querySelector ( "#input-normalize" ) ;
2019-01-14 18:55:51 +01:00
var customcssinput = themeRepoModal . querySelector ( "#input-customcss" ) ;
var themefixerinput = themeRepoModal . querySelector ( "#input-themefixer" ) ;
2019-10-22 18:55:25 +02:00
darklightinput . checked = BDFDB . DiscordUtils . getTheme ( ) == BDFDB . disCN . themelight ;
2019-06-09 16:26:16 +02:00
normalizeinput . checked = window . settingsCookie [ "fork-ps-4" ] == true ;
2019-01-14 18:55:51 +01:00
customcssinput . checked = false ;
themefixerinput . checked = false ;
2019-04-16 09:52:09 +02:00
themeRepoModal . querySelector ( "#input-hideupdated" ) . checked = hiddenSettings . updated || options . showOnlyOutdated ;
themeRepoModal . querySelector ( "#input-hideoutdated" ) . checked = hiddenSettings . outdated && ! options . showOnlyOutdated ;
themeRepoModal . querySelector ( "#input-hidedownloadable" ) . checked = hiddenSettings . downloadable || options . showOnlyOutdated ;
2019-10-23 11:10:01 +02:00
if ( ! BDFDB . BDUtils . isAutoLoadEnabled ( ) ) themeRepoModal . querySelector ( "#RNMoption" ) . remove ( ) ;
2019-10-22 20:16:05 +02:00
else themeRepoModal . querySelector ( "#input-rnmstart" ) . checked = BDFDB . DataUtils . load ( this , "RNMstart" , "RNMstart" ) ;
2019-09-04 12:34:02 +02:00
2019-04-16 09:52:09 +02:00
if ( options . forcedSort && this . sortings . sort [ options . forcedSort ] ) {
var sortinput = themeRepoModal . querySelector ( ".sort-filter " + BDFDB . dotCN . quickselectvalue ) ;
sortinput . innerText = this . sortings . sort [ options . forcedSort ] ;
sortinput . setAttribute ( 'option' , options . forcedSort ) ;
}
if ( options . forcedOrder && this . sortings . order [ options . forcedOrder ] ) {
var orderinput = themeRepoModal . querySelector ( ".order-filter " + BDFDB . dotCN . quickselectvalue ) ;
orderinput . innerText = this . sortings . order [ options . forcedOrder ] ;
orderinput . setAttribute ( 'option' , options . forcedOrder ) ;
}
2019-01-26 22:45:19 +01:00
2019-01-14 18:55:51 +01:00
darklightinput . addEventListener ( "change" , e => {
2019-04-16 10:35:03 +02:00
frame . contentWindow . postMessage ( { origin : "ThemeRepo" , reason : "DarkLight" , checked : darklightinput . checked , light : BDFDB . disCN . themelight , dark : BDFDB . disCN . themedark } , "*" ) ;
2019-01-22 14:20:04 +01:00
} ) ;
normalizeinput . addEventListener ( "change" , e => {
2019-04-16 10:35:03 +02:00
frame . contentWindow . postMessage ( { origin : "ThemeRepo" , reason : "Normalize" , checked : normalizeinput . checked } , "*" ) ;
2019-01-14 18:55:51 +01:00
} ) ;
customcssinput . addEventListener ( "change" , e => {
var customCSS = document . querySelector ( "style#customcss" ) ;
2019-04-16 10:35:03 +02:00
if ( customCSS && customCSS . innerText . length > 0 ) frame . contentWindow . postMessage ( { origin : "ThemeRepo" , reason : "CustomCSS" , checked : customcssinput . checked , css : customCSS . innerText } , "*" ) ;
2019-01-14 18:55:51 +01:00
} ) ;
themefixerinput . addEventListener ( "change" , e => {
2019-10-11 23:21:52 +02:00
BDFDB . LibraryRequires . request ( "https://mwittrien.github.io/BetterDiscordAddons/Plugins/ThemeRepo/res/ThemeFixer.css" , ( error , response , body ) => {
frame . contentWindow . postMessage ( { origin : "ThemeRepo" , reason : "ThemeFixer" , checked : themefixerinput . checked , css : this . createFixerCSS ( body ) } , "*" ) ;
} ) ;
2019-01-14 18:55:51 +01:00
} ) ;
themeRepoModal . querySelector ( "#download-themefixer" ) . addEventListener ( "click" , e => {
2019-10-11 23:21:52 +02:00
BDFDB . LibraryRequires . request ( "https://mwittrien.github.io/BetterDiscordAddons/Plugins/ThemeRepo/res/ThemeFixer.css" , ( error , response , body ) => {
this . createThemeFile ( "ThemeFixer.theme.css" , ` //META{"name":"ThemeFixer","description":"ThemeFixerCSS for transparent themes","author":"DevilBro","version":"1.0.2"}*// \n \n ` + this . createFixerCSS ( body ) ) ;
} ) ;
2019-01-14 18:55:51 +01:00
} ) ;
2019-09-25 17:35:00 +02:00
themeRepoModal . querySelector ( "#download-generated" ) . addEventListener ( "click" , e => {
let inputs = themeRepoModal . querySelectorAll ( ".varinput" ) ;
2019-10-22 18:55:25 +02:00
if ( ! inputs . length ) BDFDB . NotificationUtils . toast ( ` Select a Theme to download a custom generated Theme. ` , { type : "error" } ) ;
2019-09-25 17:35:00 +02:00
else {
let data = this . loadedThemes [ this . generatorThemes [ themeRepoModal . querySelector ( ".generator-select " + BDFDB . dotCN . select ) . getAttribute ( "value" ) - 1 ] ] ;
let css = data . fullcss ;
for ( let input of inputs ) {
let oldvalue = input . getAttribute ( "placeholder" ) ;
let newvalue = input . value ;
if ( newvalue && newvalue . trim ( ) && newvalue != oldvalue ) {
let varname = input . getAttribute ( "option" ) ;
2019-10-23 11:10:01 +02:00
css = css . replace ( new RegExp ( ` -- ${ BDFDB . StringUtils . regEscape ( varname ) } ( \\ s*):( \\ s*) ${ BDFDB . StringUtils . regEscape ( oldvalue ) } ` , "g" ) , ` -- ${ varname } $ 1: $ 2 ${ newvalue } ` ) ;
2019-09-25 17:35:00 +02:00
}
}
this . createThemeFile ( data . name + ".theme.css" , css ) ;
}
} ) ;
2019-10-22 18:55:25 +02:00
BDFDB . ListenerUtils . addToChildren ( themeRepoModal , "click" , BDFDB . dotCNC . modalclose + BDFDB . dotCN . backdrop , ( ) => {
2019-01-14 18:55:51 +01:00
frame . remove ( ) ;
document . removeEventListener ( "keyup" , keyPressed ) ;
window . removeEventListener ( "message" , messageReceived ) ;
} ) ;
2019-10-22 18:55:25 +02:00
BDFDB . ListenerUtils . addToChildren ( themeRepoModal , "mouseenter" , BDFDB . dotCN . backdrop , e => {
2019-09-25 17:35:00 +02:00
if ( ! document . querySelector ( BDFDB . dotCN . colorpicker ) ) {
for ( let child of themeRepoModal . childNodes ) {
child . style . setProperty ( "transition" , "opacity .5s ease-in-out" , "important" ) ;
child . style . setProperty ( "opacity" , "0" , "important" ) ;
}
}
} ) ;
2019-10-22 18:55:25 +02:00
BDFDB . ListenerUtils . addToChildren ( themeRepoModal , "mouseleave" , BDFDB . dotCN . backdrop , e => {
2019-09-25 17:35:00 +02:00
if ( ! document . querySelector ( BDFDB . dotCN . colorpicker ) ) {
themeRepoModal . childNodes [ 0 ] . style . setProperty ( "opacity" , "0.85" ) ;
themeRepoModal . childNodes [ 1 ] . style . setProperty ( "opacity" , "1" ) ;
2019-11-01 11:09:32 +01:00
BDFDB . TimeUtils . timeout ( ( ) => { for ( let child of themeRepoModal . childNodes ) child . style . removeProperty ( "transition" ) ; } , 500 ) ;
2019-09-25 17:35:00 +02:00
}
} ) ;
2019-10-22 18:55:25 +02:00
BDFDB . ListenerUtils . addToChildren ( themeRepoModal , "keyup" , BDFDB . dotCN . searchbarinput , ( ) => {
2019-11-01 11:09:32 +01:00
BDFDB . TimeUtils . clear ( themeRepoModal . searchTimeout ) ;
themeRepoModal . searchTimeout = BDFDB . TimeUtils . timeout ( ( ) => { this . sortEntries ( themeRepoModal ) ; } , 1000 ) ;
2019-01-14 18:55:51 +01:00
} ) ;
2019-10-22 18:55:25 +02:00
BDFDB . ListenerUtils . addToChildren ( themeRepoModal , "click" , BDFDB . dotCN . searchbarclear , ( ) => {
2019-11-01 11:09:32 +01:00
BDFDB . TimeUtils . clear ( themeRepoModal . searchTimeout ) ;
themeRepoModal . searchTimeout = BDFDB . TimeUtils . timeout ( ( ) => { this . sortEntries ( themeRepoModal ) ; } , 1000 ) ;
2019-01-14 18:55:51 +01:00
} ) ;
2019-10-22 18:55:25 +02:00
BDFDB . ListenerUtils . addToChildren ( themeRepoModal , "change" , ".hide-checkbox" , e => {
2019-01-15 09:18:33 +01:00
themeRepoModal . updateHidden = true ;
2019-10-22 20:16:05 +02:00
BDFDB . DataUtils . save ( e . currentTarget . checked , this , "hidden" , e . currentTarget . value ) ;
2019-01-14 18:55:51 +01:00
} ) ;
2019-10-22 18:55:25 +02:00
BDFDB . ListenerUtils . addToChildren ( themeRepoModal , "change" , "#input-rnmstart" , e => {
2019-10-22 20:16:05 +02:00
BDFDB . DataUtils . save ( e . currentTarget . checked , this , "RNMstart" , "RNMstart" ) ;
2019-01-14 18:55:51 +01:00
} ) ;
2019-10-22 18:55:25 +02:00
BDFDB . ListenerUtils . addToChildren ( themeRepoModal , "click" , ".sort-filter" , e => {
2019-01-14 18:55:51 +01:00
BDFDB . createSortPopout ( e . currentTarget , this . sortPopoutMarkup , ( ) => { this . sortEntries ( themeRepoModal ) ; } ) ;
} ) ;
2019-10-22 18:55:25 +02:00
BDFDB . ListenerUtils . addToChildren ( themeRepoModal , "click" , ".order-filter" , e => {
2019-01-14 18:55:51 +01:00
BDFDB . createSortPopout ( e . currentTarget , this . orderPopoutMarkup , ( ) => { this . sortEntries ( themeRepoModal ) ; } ) ;
} ) ;
2019-10-22 18:55:25 +02:00
BDFDB . ListenerUtils . addToChildren ( themeRepoModal , "click" , BDFDB . dotCN . tabbaritem + "[tab=themes]" , e => {
2019-10-23 11:10:01 +02:00
if ( ! BDFDB . DOMUtils . containsClass ( e . currentTarget , BDFDB . disCN . settingsitemselected ) ) {
2019-01-15 09:18:33 +01:00
if ( themeRepoModal . updateHidden ) {
delete themeRepoModal . updateHidden ;
2019-01-07 20:25:35 +01:00
this . sortEntries ( themeRepoModal ) ;
2018-12-23 15:35:53 +01:00
}
2019-01-14 18:55:51 +01:00
}
} ) ;
2019-01-26 22:45:19 +01:00
2019-10-22 19:49:57 +02:00
let favorites = BDFDB . DataUtils . load ( this , "favorites" ) ;
2019-01-07 20:25:35 +01:00
let container = themeRepoModal . querySelector ( ".themes" ) ;
themeRepoModal . entries = { } ;
for ( let url in this . loadedThemes ) {
let theme = this . loadedThemes [ url ] ;
2019-10-23 11:10:01 +02:00
let instTheme = BDFDB . BDUtils . getTheme ( theme . name ) ;
2019-01-07 20:25:35 +01:00
if ( instTheme && instTheme . author . toUpperCase ( ) == theme . author . toUpperCase ( ) ) theme . state = instTheme . version != theme . version ? 1 : 0 ;
else theme . state = 2 ;
let data = {
url : theme . url ,
2019-05-21 23:29:25 +02:00
requesturl : theme . requesturl ,
2019-01-07 20:25:35 +01:00
search : ( theme . name + " " + theme . version + " " + theme . author + " " + theme . description ) . toUpperCase ( ) ,
name : theme . name ,
version : theme . version ,
author : theme . author ,
description : theme . description ,
2019-04-16 10:03:38 +02:00
fav : favorites [ url ] ? 0 : 1 ,
new : ! this . cachedThemes . includes ( url ) ? 0 : 1 ,
2019-01-07 20:25:35 +01:00
state : theme . state ,
css : theme . css
} ;
themeRepoModal . entries [ url ] = data ;
this . addEntry ( frame , themeRepoModal , container , data ) ;
}
this . sortEntries ( themeRepoModal ) ;
2019-09-25 17:35:00 +02:00
var genselect = themeRepoModal . querySelector ( ".generator-select" ) ;
genselect . innerHTML = BDFDB . createSelectMenu ( createSelectChoice ( "-----" ) , "-----" ) ;
genselect . addEventListener ( "click" , e => {
BDFDB . openDropdownMenu ( e , saveSelectChoice . bind ( this ) , createSelectChoice . bind ( this ) , [ "-----" ] . concat ( this . generatorThemes ) ) ;
} ) ;
2019-01-26 22:45:19 +01:00
2019-01-07 20:25:35 +01:00
BDFDB . appendModal ( themeRepoModal ) ;
2019-01-26 22:45:19 +01:00
2019-01-14 18:55:51 +01:00
document . body . insertBefore ( frame , document . body . firstElementChild ) ;
2019-01-26 22:45:19 +01:00
2019-01-22 11:14:05 +01:00
themeRepoModal . querySelector ( BDFDB . dotCN . searchbarinput ) . focus ( ) ;
2018-10-11 10:21:26 +02:00
}
2019-09-25 17:35:00 +02:00
2019-10-11 23:21:52 +02:00
createFixerCSS ( body ) {
var oldcss = body . replace ( /\n/g , "\\n" ) . replace ( /\t/g , "\\t" ) . replace ( /\r/g , "\\r" ) . split ( "REPLACE_CLASS_" ) ;
var newcss = oldcss . shift ( ) ;
for ( let str of oldcss ) {
let reg = /([A-z0-9_]+)(.*)/ . exec ( str ) ;
newcss += BDFDB . dotCN [ reg [ 1 ] ] + reg [ 2 ] ;
}
return newcss . replace ( /\\n/g , "\n" ) . replace ( /\\t/g , "\t" ) . replace ( /\\r/g , "\r" ) ;
}
2019-09-25 17:35:00 +02:00
createGeneratorVars ( frame , container , data ) {
let vars = data . fullcss . split ( ":root" ) ;
if ( vars . length < 2 ) return ;
2019-09-27 13:10:10 +02:00
vars = vars [ 1 ] . replace ( /\t\(/g , " (" ) . replace ( /\r|\t| {2,}/g , "" ) . replace ( /\/\*\n*((?!\/\*|\*\/).|\n)*\n+((?!\/\*|\*\/).|\n)*\n*\*\//g , "" ) . replace ( /\n\/\*.*?\*\//g , "" ) . replace ( /\n/g , "" ) ;
2019-09-25 17:35:00 +02:00
vars = vars . split ( "{" ) ;
vars . shift ( ) ;
vars = vars . join ( "{" ) . replace ( /\s*(:|;|--|\*)\s*/g , "$1" ) ;
vars = vars . split ( "}" ) [ 0 ] ;
vars = vars . slice ( 2 ) . split ( /;--|\*\/--/ ) ;
2019-10-23 11:10:01 +02:00
var maxwidth = BDFDB . DOMUtils . getRects ( container ) . width - 80 ;
2019-09-25 17:35:00 +02:00
for ( let varstr of vars ) {
varstr = varstr . split ( ":" ) ;
let varname = varstr . shift ( ) . trim ( ) ;
varstr = varstr . join ( ":" ) . split ( /;[^A-z0-9]|\/\*/ ) ;
let varvalue = varstr . shift ( ) . trim ( ) ;
if ( varvalue ) {
let vardescription = varstr . join ( "" ) . replace ( /\*\/|\/\*/g , "" ) . replace ( /:/g , ": " ) . replace ( /: \//g , ":/" ) . replace ( /--/g , " --" ) . replace ( /\( --/g , "(--" ) . trim ( ) ;
vardescription = vardescription && vardescription . indexOf ( "*" ) == 0 ? vardescription . slice ( 1 ) : vardescription ;
2019-10-23 11:10:01 +02:00
let varcontainer = BDFDB . DOMUtils . create ( ` <div class=" ${ BDFDB . disCNS . flex + BDFDB . disCNS . horizontal + BDFDB . disCNS . directioncolumn + BDFDB . disCNS . justifystart + BDFDB . disCNS . alignstretch + BDFDB . disCNS . nowrap + BDFDB . disCN . marginbottom20 } varcontainer" style="flex: 1 1 auto;"><div class=" ${ BDFDB . disCNS . flex + BDFDB . disCNS . horizontal + BDFDB . disCNS . justifystart + BDFDB . disCNS . aligncenter + BDFDB . disCN . nowrap } " style="flex: 1 1 auto;"><h3 class=" ${ BDFDB . disCNS . titledefault + BDFDB . disCNS . weightmedium + BDFDB . disCNS . titlesize16 + BDFDB . disCN . flexchild } BDFDB-textscrollwrapper" style="flex: 0 0 30%;"><div class="BDFDB-textscroll"> ${ varname [ 0 ] . toUpperCase ( ) + varname . slice ( 1 ) } </div></h3><div class=" ${ BDFDB . disCNS . inputwrapper + BDFDB . disCNS . vertical + BDFDB . disCNS . flex2 + BDFDB . disCN . directioncolumn } " style="flex: 1 1 auto;"><input type="text" option=" ${ varname } " class=" ${ BDFDB . disCNS . inputdefault + BDFDB . disCNS . input + BDFDB . disCN . titlesize16 } varinput"></div><button type="button" class=" ${ BDFDB . disCN . colorpickerswatch } single-swatch" style="background-color: black;"></button><button type="button" class=" ${ BDFDB . disCNS . flexchild + BDFDB . disCNS . button + BDFDB . disCNS . buttonlookfilled + BDFDB . disCNS . buttoncolorbrand + BDFDB . disCNS . buttonsizemedium + BDFDB . disCN . buttongrow } file-navigator" style="flex: 0 0 auto;"><div class=" ${ BDFDB . disCN . buttoncontents } "></div><input type="file" accept="image/*" style="display:none!important;"></button></div> ${ vardescription ? ` <div class=" ${ BDFDB . disCNS . description + BDFDB . disCNS . note + BDFDB . disCN . primary } BDFDB-textscrollwrapper" style="flex: 1 1 auto; max-width: ${ maxwidth } px !important;"><div class="BDFDB-textscroll"> ${ BDFDB . StringUtils . htmlEscape ( vardescription ) } </div></div> ` : "" } ${ vars [ vars . length - 1 ] == varstr ? '' : ` <div class=" ${ BDFDB . disCNS . divider + BDFDB . disCN . dividerdefault } "></div> ` } </div> ` ) ;
2019-09-25 17:35:00 +02:00
let varinput = varcontainer . querySelector ( BDFDB . dotCN . input ) ;
varinput . value = varvalue ;
varinput . setAttribute ( "placeholder" , varvalue ) ;
let swatch = varcontainer . querySelector ( ".single-swatch" ) ;
let navigator = varcontainer . querySelector ( ".file-navigator" ) ;
2019-10-23 10:03:33 +02:00
let iscolor = BDFDB . ColorUtils . getType ( varvalue ) ;
2019-09-25 17:35:00 +02:00
let iscomp = ! iscolor && /[0-9 ]+,[0-9 ]+,[0-9 ]+/g . test ( varvalue ) ;
let isurlfile = ! iscolor && ! iscolor && /url\(.+\)/gi . test ( varvalue ) ;
let isfile = ! iscolor && ! iscolor && ! isurlfile && /(http(s)?):\/\/[(www\.)?a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/ . test ( varvalue ) ;
if ( iscolor || iscomp ) {
2019-10-23 10:03:33 +02:00
let color = iscomp ? BDFDB . ColorUtils . convert ( varvalue . split ( "," ) , "RGB" ) : varvalue ;
2019-09-25 17:35:00 +02:00
swatch . style . setProperty ( "background-color" , color , "important" ) ;
swatch . addEventListener ( "click" , e => {
2019-10-23 11:10:01 +02:00
BDFDB . ColorUtils . openPicker ( varcontainer , e . currentTarget , color , { gradient : false , comp : iscomp , alpha : iscolor , callback : updatePreview } ) ;
2019-09-25 17:35:00 +02:00
} ) ;
}
2019-10-23 11:10:01 +02:00
else BDFDB . DOMUtils . remove ( swatch ) ;
2019-09-25 17:35:00 +02:00
if ( isurlfile || isfile ) {
navigator . addEventListener ( "change" , e => {
let file = navigator . querySelector ( "input" ) . files [ 0 ] ;
if ( file && file . type . indexOf ( "image" ) == 0 ) varinput . value = ` ${ isurlfile ? "url('" : "" } data: ${ file . type } ;base64, ${ BDFDB . LibraryRequires . fs . readFileSync ( file . path ) . toString ( "base64" ) } ${ isurlfile ? "')" : "" } ` ;
else varinput . value = varvalue ;
updatePreview ( ) ;
} ) ;
}
2019-10-23 11:10:01 +02:00
else BDFDB . DOMUtils . remove ( navigator ) ;
2019-09-25 17:35:00 +02:00
container . appendChild ( varcontainer ) ;
}
}
let inputs = container . querySelectorAll ( ".varinput" ) , updateTimeout , updatePreview = ( ) => {
2019-11-01 11:09:32 +01:00
BDFDB . TimeUtils . clear ( updateTimeout ) ;
updateTimeout = BDFDB . TimeUtils . timeout ( ( ) => {
2019-09-25 17:35:00 +02:00
let css = data . fullcss ;
for ( let input of inputs ) {
let oldvalue = input . getAttribute ( "placeholder" ) ;
let newvalue = input . value ;
if ( newvalue && newvalue . trim ( ) && newvalue != oldvalue ) {
let varname = input . getAttribute ( "option" ) ;
2019-10-23 11:10:01 +02:00
css = css . replace ( new RegExp ( ` -- ${ BDFDB . StringUtils . regEscape ( varname ) } ( \\ s*):( \\ s*) ${ BDFDB . StringUtils . regEscape ( oldvalue ) } ` , "g" ) , ` -- ${ varname } $ 1: $ 2 ${ newvalue } ` ) ;
2019-09-25 17:35:00 +02:00
}
}
frame . contentWindow . postMessage ( { origin : "ThemeRepo" , reason : "NewTheme" , checked : true , css } , "*" ) ;
} , 1000 ) ;
} ;
2019-10-22 18:55:25 +02:00
BDFDB . ListenerUtils . addToChildren ( container , "change input" , ".varinput" , updatePreview ) ;
2019-09-25 17:35:00 +02:00
BDFDB . initElements ( container ) ;
}
2019-01-26 22:45:19 +01:00
2019-01-07 20:25:35 +01:00
addEntry ( frame , themeRepoModal , container , data ) {
if ( ! frame || ! themeRepoModal || ! container || ! data ) return ;
2019-10-23 11:10:01 +02:00
let entry = BDFDB . DOMUtils . create ( this . themeEntryMarkup ) ;
2019-01-07 20:25:35 +01:00
setEntryState ( data . state ) ;
entry . setAttribute ( "data-name" , data . name ) ;
entry . setAttribute ( "data-version" , data . version ) ;
entry . setAttribute ( "data-url" , data . url ) ;
entry . querySelector ( BDFDB . dotCN . _reponame ) . innerHTML = data . name ;
entry . querySelector ( BDFDB . dotCN . _repoversion ) . innerHTML = data . version ;
entry . querySelector ( BDFDB . dotCN . _repoauthor ) . innerHTML = data . author ;
entry . querySelector ( BDFDB . dotCN . _repodescription ) . innerHTML = data . description ;
2019-10-23 11:10:01 +02:00
if ( data . new == 0 ) entry . querySelector ( BDFDB . dotCN . _repoheadertitle ) . appendChild ( BDFDB . DOMUtils . create ( ` <span class="newentries-tag ${ BDFDB . disCNS . bottag + BDFDB . disCNS . bottagregular + BDFDB . disCN . bottagnametag } " style="background-color: rgb(250, 166, 26) !important; color: white !important; padding: 1px 3px; font-size: 10px; top: -2px;">NEW</span> ` ) ) ;
2019-01-14 18:55:51 +01:00
let favbutton = entry . querySelector ( BDFDB . dotCN . giffavoritebutton ) ;
2019-10-23 11:10:01 +02:00
BDFDB . DOMUtils . toggleClass ( favbutton , BDFDB . disCN . giffavoriteselected , data . fav == 0 ) ;
2019-01-14 18:55:51 +01:00
favbutton . addEventListener ( "click" , e => {
let favorize = data . fav == 1 ;
data . fav = favorize ? 0 : 1 ;
2019-10-22 20:16:05 +02:00
if ( favorize ) BDFDB . DataUtils . save ( true , this , "favorites" , data . url ) ;
else BDFDB . DataUtils . remove ( this , "favorites" , data . url ) ;
2019-01-14 18:55:51 +01:00
themeRepoModal . entries [ data . url ] = data ;
} ) ;
let gitbutton = entry . querySelector ( ".gitIcon" ) ;
gitbutton . addEventListener ( "click" , e => {
var giturl = null ;
2019-05-21 23:29:25 +02:00
if ( data . requesturl . indexOf ( "https://raw.githubusercontent.com" ) == 0 ) {
var temp = data . requesturl . replace ( "//raw.githubusercontent" , "//github" ) . split ( "/" ) ;
2019-01-14 18:55:51 +01:00
temp . splice ( 5 , 0 , "blob" ) ;
giturl = temp . join ( "/" ) ;
}
2019-05-21 23:29:25 +02:00
else if ( data . requesturl . indexOf ( "https://gist.githubusercontent.com/" ) == 0 ) {
giturl = data . requesturl . replace ( "//gist.githubusercontent" , "//gist.github" ) . split ( "/raw/" ) [ 0 ] ;
2019-01-14 18:55:51 +01:00
}
if ( giturl ) window . open ( giturl , "_blank" ) ;
} ) ;
gitbutton . addEventListener ( "mouseenter" , e => {
2019-10-22 18:55:25 +02:00
BDFDB . TooltipUtils . create ( gitbutton , "Go to Git" , { type : "top" , selector : "themerepo-giticon-tooltip" } ) ;
2019-01-14 18:55:51 +01:00
} ) ;
let trashbutton = entry . querySelector ( ".trashIcon" ) ;
trashbutton . addEventListener ( "click" , e => {
2019-10-23 11:10:01 +02:00
if ( BDFDB . DOMUtils . containsClass ( entry , "outdated" , "updated" , false ) ) {
2019-01-14 18:55:51 +01:00
setEntryState ( 2 ) ;
2019-01-15 09:18:33 +01:00
this . deleteThemeFile ( data ) ;
2019-10-23 11:10:01 +02:00
if ( ! BDFDB . BDUtils . isAutoLoadEnabled ( ) ) this . removeTheme ( data ) ;
2019-01-14 18:55:51 +01:00
}
} ) ;
trashbutton . addEventListener ( "mouseenter" , e => {
2019-10-22 18:55:25 +02:00
BDFDB . TooltipUtils . create ( trashbutton , "Delete Themefile" , { type : "top" , selector : "themerepo-trashicon-tooltip" } ) ;
2019-01-14 18:55:51 +01:00
} ) ;
entry . querySelector ( ".btn-download" ) . addEventListener ( "click" , e => {
setEntryState ( 0 ) ;
this . downloadTheme ( data ) ;
2019-11-01 11:09:32 +01:00
if ( themeRepoModal . querySelector ( "#input-rnmstart" ) . checked ) BDFDB . TimeUtils . timeout ( ( ) => { this . applyTheme ( data ) ; } , 3000 ) ;
2019-01-14 18:55:51 +01:00
} ) ;
2019-01-14 21:39:18 +01:00
entry . querySelector ( ".previewCheckbox" ) . addEventListener ( "click" , e => {
2019-09-25 17:35:00 +02:00
themeRepoModal . querySelector ( ".generator-select " + BDFDB . dotCN . select ) . setAttribute ( 'value' , "-----" ) ;
themeRepoModal . querySelector ( ".generator-select " + BDFDB . dotCN . title ) . innerHTML = ` <strong>-----</strong> by ----- ` ;
2019-10-23 11:10:01 +02:00
BDFDB . DOMUtils . remove ( themeRepoModal . querySelectorAll ( ".varcontainer" ) ) ;
2019-01-14 18:55:51 +01:00
if ( e . currentTarget . checked ) themeRepoModal . querySelectorAll ( ".previewCheckbox" ) . forEach ( checkbox => {
if ( e . currentTarget != checkbox ) {
checkbox . checked = false ;
2019-10-23 11:10:01 +02:00
BDFDB . DOMUtils . removeClass ( checkbox . parentElement , BDFDB . disCN . switchvaluechecked ) ;
BDFDB . DOMUtils . addClass ( checkbox . parentElement , BDFDB . disCN . switchvalueunchecked ) ;
2019-01-07 20:25:35 +01:00
}
} ) ;
2019-01-14 18:55:51 +01:00
frame . contentWindow . postMessage ( { origin : "ThemeRepo" , reason : "NewTheme" , checked : e . currentTarget . checked , css : data . css } , "*" ) ;
} ) ;
2019-01-26 22:45:19 +01:00
2019-01-07 20:25:35 +01:00
container . appendChild ( entry ) ;
2019-01-26 22:45:19 +01:00
2019-01-07 20:25:35 +01:00
function setEntryState ( state ) {
data . state = state ;
2019-10-23 11:10:01 +02:00
BDFDB . DOMUtils . toggleClass ( entry , "downloadable" , state > 1 ) ;
BDFDB . DOMUtils . toggleClass ( entry , "outdated" , state == 1 ) ;
BDFDB . DOMUtils . toggleClass ( entry , "updated" , state < 1 ) ;
2019-01-07 20:25:35 +01:00
let downloadbutton = entry . querySelector ( ".btn-download" ) ;
downloadbutton . innerText = state < 1 ? "Updated" : ( state > 1 ? "Download" : "Outdated" ) ;
2019-02-16 16:14:02 +01:00
downloadbutton . style . setProperty ( "background-color" , "rgb(" + ( state < 1 ? "67,181,129" : ( state > 1 ? "114,137,218" : "241,71,71" ) ) + ")" , state > 1 ? "" : "important" ) ;
2019-01-07 20:25:35 +01:00
themeRepoModal . entries [ data . url ] = data ;
} ;
}
2019-01-26 22:45:19 +01:00
2019-01-07 20:25:35 +01:00
sortEntries ( themeRepoModal ) {
if ( ! themeRepoModal || typeof themeRepoModal . entries != "object" ) return ;
2019-01-26 22:45:19 +01:00
2019-01-07 20:25:35 +01:00
let container = themeRepoModal . querySelector ( ".themes" ) ;
if ( ! container ) return ;
2019-01-26 22:45:19 +01:00
2019-01-07 20:25:35 +01:00
let searchstring = themeRepoModal . querySelector ( BDFDB . dotCN . searchbarinput ) . value . replace ( /[<|>]/g , "" ) . toUpperCase ( ) ;
2019-01-26 22:45:19 +01:00
2019-01-07 20:25:35 +01:00
let entries = themeRepoModal . entries ;
2019-10-22 18:55:25 +02:00
if ( themeRepoModal . querySelector ( "#input-hideupdated" ) . checked ) entries = BDFDB . ObjectUtils . filter ( entries , entry => { return entry . state < 1 ? null : entry ; } ) ;
if ( themeRepoModal . querySelector ( "#input-hideoutdated" ) . checked ) entries = BDFDB . ObjectUtils . filter ( entries , entry => { return entry . state == 1 ? null : entry ; } ) ;
if ( themeRepoModal . querySelector ( "#input-hidedownloadable" ) . checked ) entries = BDFDB . ObjectUtils . filter ( entries , entry => { return entry . state > 1 ? null : entry ; } ) ;
entries = BDFDB . ObjectUtils . filter ( entries , entry => { return entry . search . indexOf ( searchstring ) > - 1 ? entry : null ; } ) ;
2019-01-26 22:45:19 +01:00
2019-04-16 09:52:09 +02:00
let sortfilter = themeRepoModal . querySelector ( ".sort-filter " + BDFDB . dotCN . quickselectvalue ) . getAttribute ( "option" ) ;
2019-10-22 18:55:25 +02:00
entries = BDFDB . ObjectUtils . sort ( entries , sortfilter == "new" && ! themeRepoModal . querySelector ( ".newentries-tag" ) ? "name" : sortfilter ) ;
if ( themeRepoModal . querySelector ( ".order-filter " + BDFDB . dotCN . quickselectvalue ) . getAttribute ( "option" ) == "desc" ) entries = BDFDB . ObjectUtils . reverse ( entries ) ;
2019-01-26 22:45:19 +01:00
2019-01-07 20:25:35 +01:00
let entrypositions = Object . keys ( entries ) ;
2019-01-26 22:45:19 +01:00
2019-01-07 20:25:35 +01:00
themeRepoModal . querySelector ( ".themeAmount" ) . innerText = "ThemeRepo Repository " + entrypositions . length + "/" + Object . keys ( this . loadedThemes ) . length + " Themes" ;
2019-01-26 22:45:19 +01:00
2019-01-07 20:25:35 +01:00
for ( let li of container . children ) {
let pos = entrypositions . indexOf ( li . getAttribute ( "data-url" ) ) ;
if ( pos > - 1 ) {
li . querySelectorAll ( BDFDB . dotCNC . _reponame + BDFDB . dotCNC . _repoversion + BDFDB . dotCNC . _repoauthor + BDFDB . dotCN . _repodescription ) . forEach ( ele => {
2019-01-12 15:07:06 +01:00
if ( searchstring && searchstring . length > 2 || ele . querySelector ( BDFDB . dotCN . highlight ) ) ele . innerHTML = BDFDB . highlightText ( ele . innerText , searchstring ) ;
2019-01-07 20:25:35 +01:00
} ) ;
li . style . setProperty ( "order" , pos , "important" ) ;
}
2019-01-17 10:02:26 +01:00
else li . style . removeProperty ( "order" ) ;
2019-10-23 11:10:01 +02:00
BDFDB . DOMUtils . toggle ( li , pos > - 1 ) ;
2019-01-07 20:25:35 +01:00
}
}
2019-01-26 22:45:19 +01:00
2018-10-11 10:21:26 +02:00
loadThemes ( ) {
2019-10-23 11:10:01 +02:00
BDFDB . DOMUtils . remove ( ".themerepo-loadingicon" ) ;
2019-10-22 23:04:35 +02:00
let settings = BDFDB . DataUtils . load ( this , "settings" ) ;
2019-05-21 23:29:25 +02:00
var getThemeInfo , outdated = 0 , newentries = 0 , i = 0 , NFLDreplace = null ;
2018-10-11 10:21:26 +02:00
var tags = [ "name" , "description" , "author" , "version" ] ;
2019-10-22 20:16:05 +02:00
var newentriesdata = BDFDB . DataUtils . load ( this , "newentriesdata" ) , ownlist = BDFDB . DataUtils . load ( this , "ownlist" , "ownlist" ) || [ ] ;
2019-04-16 09:57:55 +02:00
this . cachedThemes = ( newentriesdata . urlbase64 ? atob ( newentriesdata . urlbase64 ) . split ( "\n" ) : [ ] ) . concat ( ownlist ) ;
2019-09-11 12:14:43 +02:00
BDFDB . LibraryRequires . request ( "https://mwittrien.github.io/BetterDiscordAddons/Plugins/ThemeRepo/res/ThemeList.txt" , ( error , response , body ) => {
2019-05-21 23:29:25 +02:00
if ( ! error && body ) {
body = body . replace ( /[\r\t]/g , "" ) ;
2019-10-22 20:16:05 +02:00
BDFDB . DataUtils . save ( btoa ( body ) , this , "newentriesdata" , "urlbase64" ) ;
2018-10-11 10:21:26 +02:00
this . loadedThemes = { } ;
2019-06-14 11:13:15 +02:00
this . grabbedThemes = body . split ( "\n" ) . filter ( n => n ) ;
2019-09-11 12:14:43 +02:00
BDFDB . LibraryRequires . request ( "https://github.com/NFLD99/Better-Discord" , ( error2 , response2 , body2 ) => {
2019-05-21 23:29:25 +02:00
if ( ! error2 && body2 ) {
NFLDreplace = /\/NFLD99\/Better-Discord\/tree\/master\/Themes_[^"]+">([^<]+)/i . exec ( body2 ) ;
NFLDreplace = NFLDreplace && NFLDreplace . length > 1 ? NFLDreplace [ 1 ] : null ;
2018-12-14 11:43:54 +01:00
}
2019-05-21 23:29:25 +02:00
this . foundThemes = this . grabbedThemes . concat ( ownlist ) ;
2019-09-04 12:34:02 +02:00
2019-11-01 11:09:32 +01:00
this . loading = { is : true , timeout : BDFDB . TimeUtils . timeout ( ( ) => {
BDFDB . TimeUtils . clear ( this . loading . timeout ) ;
2019-05-21 23:29:25 +02:00
if ( this . started ) {
2019-11-01 11:09:32 +01:00
if ( this . loading . is && this . loading . amount < 4 ) BDFDB . TimeUtils . timeout ( ( ) => { this . loadThemes ( ) ; } , 10000 ) ;
2019-05-21 23:29:25 +02:00
this . loading = { is : false , timeout : null , amount : this . loading . amount } ;
}
} , 1200000 ) , amount : this . loading . amount + 1 } ;
var loadingiconwrapper = document . querySelector ( BDFDB . dotCN . app + "> .repo-loadingwrapper" ) ;
if ( ! loadingiconwrapper ) {
2019-10-23 11:10:01 +02:00
loadingiconwrapper = BDFDB . DOMUtils . create ( ` <div class="repo-loadingwrapper"></div> ` ) ;
2019-05-21 23:29:25 +02:00
document . querySelector ( BDFDB . dotCN . app ) . appendChild ( loadingiconwrapper ) ;
2018-10-11 10:21:26 +02:00
}
2019-10-23 11:10:01 +02:00
var loadingicon = BDFDB . DOMUtils . create ( this . themeRepoIconMarkup ) ;
BDFDB . DOMUtils . addClass ( loadingicon , "themerepo-loadingicon" ) ;
2019-10-22 18:55:25 +02:00
loadingicon . addEventListener ( "mouseenter" , ( ) => {
BDFDB . TooltipUtils . create ( loadingicon , this . getLoadingTooltipText ( ) , { type : "left" , delay : 500 , style : "max-width:unset;" , selector : "themerepo-loading-tooltip" } ) ;
} ) ;
2019-05-21 23:29:25 +02:00
loadingiconwrapper . appendChild ( loadingicon ) ;
getThemeInfo ( ( ) => {
if ( ! this . started ) {
2019-11-01 11:09:32 +01:00
BDFDB . TimeUtils . clear ( this . loading . timeout ) ;
2019-05-21 23:29:25 +02:00
return ;
}
2019-10-23 11:10:01 +02:00
BDFDB . DOMUtils . remove ( loadingicon , ".themerepo-loadingicon" ) ;
if ( ! loadingiconwrapper . firstChild ) BDFDB . DOMUtils . remove ( loadingiconwrapper ) ;
2019-11-01 11:09:32 +01:00
BDFDB . TimeUtils . clear ( this . loading . timeout ) ;
2019-05-21 23:29:25 +02:00
this . loading = { is : false , timeout : null , amount : this . loading . amount } ;
console . log ( ` %c[ ${ this . name } ]%c ` , "color: #3a71c1; font-weight: 700;" , "" , "Finished fetching Themes." ) ;
2019-10-22 18:55:25 +02:00
if ( document . querySelector ( ".bd-themerepobutton" ) ) BDFDB . NotificationUtils . toast ( ` Finished fetching Themes. ` , { type : "success" } ) ;
2019-05-21 23:29:25 +02:00
if ( ( settings . notifyOutdated || settings . notifyOutdated == undefined ) && outdated > 0 ) {
var oldbarbutton = document . querySelector ( ".themerepo-outdate-notice " + BDFDB . dotCN . noticedismiss ) ;
if ( oldbarbutton ) oldbarbutton . click ( ) ;
2019-10-22 18:55:25 +02:00
var bar = BDFDB . NotificationUtils . notice ( ` ${ outdated } of your Themes ${ outdated == 1 ? "is" : "are" } outdated. Check: ` , { type : "danger" , btn : "ThemeRepo" , selector : "themerepo-notice themerepo-outdate-notice" , customicon : this . themeRepoIconMarkup . replace ( /#7289da/gi , "#FFF" ) . replace ( /#7f8186/gi , "#B9BBBE" ) } ) ;
2019-01-14 18:55:51 +01:00
bar . querySelector ( BDFDB . dotCN . noticebutton ) . addEventListener ( "click" , e => {
2019-05-21 23:29:25 +02:00
this . openThemeRepoModal ( { showOnlyOutdated : true } ) ;
bar . querySelector ( BDFDB . dotCN . noticedismiss ) . click ( ) ;
2018-10-11 10:21:26 +02:00
} ) ;
}
2019-05-21 23:29:25 +02:00
if ( ( settings . notifyNewentries || settings . notifyNewentries == undefined ) && newentries > 0 ) {
var oldbarbutton = document . querySelector ( ".themerepo-newentries-notice " + BDFDB . dotCN . noticedismiss ) ;
if ( oldbarbutton ) oldbarbutton . click ( ) ;
2019-10-22 18:55:25 +02:00
var bar = BDFDB . NotificationUtils . notice ( ` There ${ newentries == 1 ? "is" : "are" } ${ newentries } new Theme ${ newentries == 1 ? "" : "s" } in the Repo. Check: ` , { type : "success" , btn : "ThemeRepo" , selector : "themerepo-notice themerepo-newentries-notice" , customicon : this . themeRepoIconMarkup . replace ( /#7289da/gi , "#FFF" ) . replace ( /#7f8186/gi , "#B9BBBE" ) } ) ;
2019-05-21 23:29:25 +02:00
bar . querySelector ( BDFDB . dotCN . noticebutton ) . addEventListener ( "click" , e => {
this . openThemeRepoModal ( { forcedSort : "new" , forcedOrder : "asc" } ) ;
bar . querySelector ( BDFDB . dotCN . noticedismiss ) . click ( ) ;
} ) ;
}
2019-10-22 18:55:25 +02:00
if ( BDFDB . UserUtils . me . id == "278543574059057154" ) {
2019-05-21 23:29:25 +02:00
let wrongUrls = [ ] ;
for ( let url of this . foundThemes ) if ( url && ! this . loadedThemes [ url ] && ! wrongUrls . includes ( url ) ) wrongUrls . push ( url ) ;
if ( wrongUrls . length > 0 ) {
2019-10-22 18:55:25 +02:00
var bar = BDFDB . NotificationUtils . notice ( ` ThemeRepo: ${ wrongUrls . length } Theme ${ wrongUrls . length > 1 ? "s" : "" } could not be loaded. ` , { type : "danger" , btn : "List" , selector : "themerepo-notice" , customicon : this . themeRepoIconMarkup . replace ( /#7289da/gi , "#FFF" ) . replace ( /#7f8186/gi , "#B9BBBE" ) } ) ;
2019-05-21 23:29:25 +02:00
bar . querySelector ( BDFDB . dotCN . noticebutton ) . addEventListener ( "click" , e => {
2019-10-22 18:55:25 +02:00
var toast = BDFDB . NotificationUtils . toast ( wrongUrls . join ( "\n" ) , { type : "error" } ) ;
2019-05-21 23:29:25 +02:00
toast . style . overflow = "hidden" ;
console . log ( wrongUrls . length == 1 ? wrongUrls [ 0 ] : wrongUrls ) ;
} ) ;
}
}
2019-09-25 17:35:00 +02:00
BDFDB . LibraryRequires . request ( "https://mwittrien.github.io/BetterDiscordAddons/Plugins/ThemeRepo/res/GeneratorList.txt" , ( error3 , response3 , body3 ) => {
if ( ! error3 && body3 ) for ( let url of body3 . replace ( /[\r\t]/g , "" ) . split ( "\n" ) . filter ( n => n ) ) if ( this . loadedThemes [ url ] ) this . generatorThemes . push ( url ) ;
} ) ;
2019-05-21 23:29:25 +02:00
} ) ;
2018-10-11 10:21:26 +02:00
} ) ;
}
} ) ;
getThemeInfo = ( callback ) => {
2018-12-14 11:43:54 +01:00
if ( i >= this . foundThemes . length || ! this . started || ! this . loading . is ) {
2018-10-11 10:21:26 +02:00
callback ( ) ;
return ;
}
2019-04-16 09:52:09 +02:00
let url = this . foundThemes [ i ] ;
2019-05-21 23:29:25 +02:00
let requesturl = NFLDreplace && url . includes ( "NFLD99/Better-Discord/master/Themes" ) ? url . replace ( "master/Themes" , "master/" + NFLDreplace ) : url ;
2019-09-11 12:14:43 +02:00
BDFDB . LibraryRequires . request ( requesturl , ( error , response , body ) => {
2018-10-18 12:10:34 +02:00
if ( ! response ) {
2019-10-22 18:55:25 +02:00
if ( url && BDFDB . ArrayUtils . getAllIndexes ( this . foundThemes , url ) . length < 2 ) this . foundThemes . push ( url ) ;
2018-10-18 12:10:34 +02:00
}
2018-12-14 20:51:25 +01:00
else if ( body && body . indexOf ( "404: Not Found" ) != 0 && response . statusCode == 200 ) {
2018-10-11 10:21:26 +02:00
let theme = { } ;
let text = body ;
2019-06-20 10:07:17 +02:00
if ( ( text . split ( "*//" ) . length > 1 || text . indexOf ( "/**" ) == 0 ) && text . split ( "\n" ) . length > 1 ) {
2019-09-20 22:32:52 +02:00
var hasMETAline = text . replace ( /\s/g , "" ) . indexOf ( "//META{" ) ;
2019-06-20 10:07:17 +02:00
if ( hasMETAline < 20 && hasMETAline > - 1 ) {
var searchtext = text . replace ( /\s*:\s*/g , ":" ) . replace ( /\s*}\s*/g , "}" ) ;
for ( let tag of tags ) {
let result = searchtext . split ( '"' + tag + '":"' ) ;
result = result . length > 1 ? result [ 1 ] . split ( '",' ) [ 0 ] . split ( '"}' ) [ 0 ] : null ;
result = result && tag != "version" ? result . charAt ( 0 ) . toUpperCase ( ) + result . slice ( 1 ) : result ;
2019-09-25 17:35:00 +02:00
theme [ tag ] = result ? result . trim ( ) : result ;
2019-06-20 10:07:17 +02:00
}
2018-10-11 10:21:26 +02:00
}
2019-06-20 10:07:17 +02:00
else {
var searchtext = text . replace ( /[\r\t| ]*\*\s*/g , "*" ) ;
for ( let tag of tags ) {
let result = searchtext . split ( '@' + tag + ' ' ) ;
result = result . length > 1 ? result [ 1 ] . split ( '\n' ) [ 0 ] : null ;
result = result && tag != "version" ? result . charAt ( 0 ) . toUpperCase ( ) + result . slice ( 1 ) : result ;
2019-09-25 17:35:00 +02:00
theme [ tag ] = result ? result . trim ( ) : result ;
2019-06-20 10:07:17 +02:00
}
2018-10-11 10:21:26 +02:00
}
2019-06-20 10:07:17 +02:00
let valid = true ;
for ( let tag of tags ) if ( theme [ tag ] === null ) valid = false ;
2018-10-11 10:21:26 +02:00
if ( valid ) {
2019-09-25 17:35:00 +02:00
theme . fullcss = text ;
2019-06-20 10:07:17 +02:00
theme . css = hasMETAline < 20 && hasMETAline > - 1 ? text . split ( "\n" ) . slice ( 1 ) . join ( "\n" ) . replace ( /[\r|\n|\t]/g , "" ) : text . replace ( /[\r|\n|\t]/g , "" ) ;
2018-10-11 10:21:26 +02:00
theme . url = url ;
2019-05-21 23:29:25 +02:00
theme . requesturl = requesturl ;
2018-10-11 10:21:26 +02:00
this . loadedThemes [ url ] = theme ;
2019-10-23 11:10:01 +02:00
var instTheme = BDFDB . BDUtils . getTheme ( theme . name ) ;
2019-01-07 20:25:35 +01:00
if ( instTheme && instTheme . author . toUpperCase ( ) == theme . author . toUpperCase ( ) && instTheme . version != theme . version ) outdated ++ ;
2019-04-16 09:52:09 +02:00
if ( ! this . cachedThemes . includes ( url ) ) newentries ++ ;
2018-10-11 10:21:26 +02:00
}
}
}
i ++ ;
2019-06-13 11:13:18 +02:00
var loadingtooltip = document . querySelector ( ".themerepo-loading-tooltip" ) ;
if ( loadingtooltip ) {
2019-10-23 11:10:01 +02:00
BDFDB . DOMUtils . setText ( loadingtooltip , this . getLoadingTooltipText ( ) ) ;
2019-10-22 18:55:25 +02:00
BDFDB . TooltipUtils . update ( loadingtooltip ) ;
2019-06-13 11:13:18 +02:00
}
2018-10-11 10:21:26 +02:00
getThemeInfo ( callback ) ;
} ) ;
}
}
2019-09-04 12:34:02 +02:00
2019-06-13 11:13:18 +02:00
getLoadingTooltipText ( ) {
return ` Loading ThemeRepo - [ ${ Object . keys ( this . loadedThemes ) . length } / ${ Object . keys ( this . grabbedThemes ) . length } ] ` ;
}
2019-01-26 22:45:19 +01:00
2018-10-11 10:21:26 +02:00
checkForNewThemes ( ) {
2019-09-11 12:14:43 +02:00
BDFDB . LibraryRequires . request ( "https://mwittrien.github.io/BetterDiscordAddons/Plugins/ThemeRepo/res/ThemeList.txt" , ( error , response , result ) => {
2019-07-12 12:55:34 +02:00
if ( response && ! BDFDB . equals ( result . replace ( /\t|\r/g , "" ) . split ( "\n" ) . filter ( n => n ) , this . grabbedThemes ) ) {
2018-12-14 11:43:54 +01:00
this . loading = { is : false , timeout : null , amount : 0 } ;
this . loadThemes ( ) ;
}
2018-10-11 10:21:26 +02:00
} ) ;
}
2019-01-26 22:45:19 +01:00
2019-01-07 20:25:35 +01:00
downloadTheme ( data ) {
2019-09-11 12:14:43 +02:00
BDFDB . LibraryRequires . request ( data . requesturl , ( error , response , body ) => {
2019-10-22 18:55:25 +02:00
if ( error ) BDFDB . NotificationUtils . toast ( ` Unable to download Theme " ${ data . name } ". ` , { type : "danger" } ) ;
2019-05-21 23:29:25 +02:00
else this . createThemeFile ( data . requesturl . split ( "/" ) . pop ( ) , body ) ;
2018-10-11 10:21:26 +02:00
} ) ;
}
2019-01-26 22:45:19 +01:00
2018-10-11 10:21:26 +02:00
createThemeFile ( filename , content ) {
2019-10-23 11:10:01 +02:00
BDFDB . LibraryRequires . fs . writeFile ( BDFDB . LibraryRequires . path . join ( BDFDB . BDUtils . getThemesFolder ( ) , filename ) , content , ( error ) => {
2019-10-22 18:55:25 +02:00
if ( error ) BDFDB . NotificationUtils . toast ( ` Unable to save Theme " ${ filename } ". ` , { type : "danger" } ) ;
else BDFDB . NotificationUtils . toast ( ` Successfully saved Theme " ${ filename } ". ` , { type : "success" } ) ;
2018-10-11 10:21:26 +02:00
} ) ;
}
2019-01-26 22:45:19 +01:00
2019-01-07 20:25:35 +01:00
applyTheme ( data ) {
2019-10-23 11:10:01 +02:00
if ( BDFDB . BDUtils . isThemeEnabled ( data . name ) == false ) {
BDFDB . DOMUtils . remove ( ` style# ${ data . name } ` ) ;
document . head . appendChild ( BDFDB . DOMUtils . create ( ` <style id= ${ data . name } > ${ data . css } </style> ` ) ) ;
2019-09-25 17:35:00 +02:00
window . themeModule . enableTheme ( data . name ) ;
2019-05-01 21:02:25 +02:00
console . log ( ` %c[ ${ this . name } ]%c ` , "color: #3a71c1; font-weight: 700;" , "" , "Applied Theme " + data . name + "." ) ;
2018-10-11 10:21:26 +02:00
}
}
2019-01-26 22:45:19 +01:00
2019-01-07 20:25:35 +01:00
deleteThemeFile ( data ) {
2019-05-21 23:29:25 +02:00
let filename = data . requesturl . split ( "/" ) . pop ( ) ;
2019-10-23 11:10:01 +02:00
BDFDB . LibraryRequires . fs . unlink ( BDFDB . LibraryRequires . path . join ( BDFDB . BDUtils . getThemesFolder ( ) , filename ) , ( error ) => {
2019-10-22 18:55:25 +02:00
if ( error ) BDFDB . NotificationUtils . toast ( ` Unable to delete Theme " ${ filename } ". ` , { type : "danger" } ) ;
else BDFDB . NotificationUtils . toast ( ` Successfully deleted Theme " ${ filename } ". ` ) ;
2018-10-11 10:21:26 +02:00
} ) ;
}
2019-01-26 22:45:19 +01:00
2019-01-07 20:25:35 +01:00
removeTheme ( data ) {
2019-10-23 11:10:01 +02:00
if ( BDFDB . BDUtils . isThemeEnabled ( data . name ) == true ) {
BDFDB . DOMUtils . remove ( ` style# ${ data . name } ` ) ;
2019-09-25 17:35:00 +02:00
window . themeModule . disableTheme ( data . name ) ;
2019-05-01 21:02:25 +02:00
console . log ( ` %c[ ${ this . name } ]%c ` , "color: #3a71c1; font-weight: 700;" , "" , "Removed Theme " + data . name + "." ) ;
2018-10-11 10:21:26 +02:00
}
}
}