File tree Expand file tree Collapse file tree 3 files changed +23
-17
lines changed Expand file tree Collapse file tree 3 files changed +23
-17
lines changed Original file line number Diff line number Diff line change @@ -59,25 +59,29 @@ export default {
5959
6060 // check for nsfw content
6161 img .onload = () => {
62- if (this .$parent .app_state .app_data .settings .nsfw_filter == false ) {
62+ if (this .$parent .app_state .app_data .settings .nsfw_filter == true ) {
6363 if (img .attached_cbs ) {
6464 if (img .attached_cbs .on_img )
6565 img .attached_cbs .on_img (impath);
6666 }
6767 }
68- nsfwjs .load ()
69- .then (model => model .classify (img))
70- .then (predictions => {
71- switch (predictions[0 ].className ) {
72- case ' Hentai' :
73- case ' Porn' :
74- impath = " nsfw" ;
75- }
76- if (img .attached_cbs ) {
77- if (img .attached_cbs .on_img )
78- img .attached_cbs .on_img (impath);
79- }
80- });
68+ else {
69+
70+ nsfwjs .load ()
71+ .then (model => model .classify (img))
72+ .catch (() => {
73+ console .log (" cant run nsfw" )
74+ })
75+ .then (predictions => {
76+ if (predictions && (predictions[0 ].className == ' Hentai' || predictions[0 ].className == ' Porn' )) {
77+ impath = " nsfw_" + Math .random ();
78+ }
79+ if (img .attached_cbs ) {
80+ if (img .attached_cbs .on_img )
81+ img .attached_cbs .on_img (impath);
82+ }
83+ });
84+ }
8185 }
8286 }
8387
Original file line number Diff line number Diff line change 1818 </div >
1919
2020
21- <img v-if =" path != 'nsfw' " @click =" open_image_popup( path )" class =" gal_img" :src =" 'file://' + path " style =" max-height : 100% ; max-width : 100% ;" >
21+ <img v-if =" !path.startsWith('nsfw_') " @click =" open_image_popup( path )" class =" gal_img" :src =" 'file://' + path " style =" max-height : 100% ; max-width : 100% ;" >
2222 <img v-else @click =" open_image_popup( path )" class =" gal_img" :src =" require('@/assets/nsfw.png')" style =" max-height : 100% ; max-width : 100% ;" >
2323 <br >
2424 <div v-if =" !hide_extra_save_button" @click =" save_image(path)" class =" l_button" >Save Image</div >
@@ -51,6 +51,8 @@ export default {
5151 },
5252 methods: {
5353 open_image_popup (img ){
54+ if (img .startsWith (' nsfw_' ))
55+ return ;
5456 open_popup (" file://" + img , undefined );
5557 },
5658
Original file line number Diff line number Diff line change 88 <br >
99 <div class =" setting_box" >
1010 <div class =" settings_left" >
11- <h2 >Block Adult Content</h2 >
12- <p >Prevents image generation considered NSFW</p >
11+ <h2 >Allow NSFW Content</h2 >
12+ <p >Allows image generation considered NSFW</p >
1313 </div >
1414 <hr >
1515 <div style =" float :right ;margin-right : 9px ;align-self : center ;" >
You can’t perform that action at this time.
0 commit comments