2020-10-20 23:25:34 +02:00
/ * *
* @ name ImageUtilities
* @ authorId 278543574059057154
* @ invite Jx3TjNS
2020-11-19 16:45:36 +01:00
* @ donate https : //www.paypal.me/MircoWittrien
* @ patreon https : //www.patreon.com/MircoWittrien
* @ website https : //github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/ImageUtilities
* @ source https : //raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/ImageUtilities/ImageUtilities.plugin.js
* @ updateUrl https : //raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/ImageUtilities/ImageUtilities.plugin.js
2020-10-20 23:25:34 +02:00
* /
2020-08-14 14:37:10 +02:00
2020-09-19 20:49:33 +02:00
module . exports = ( _ => {
2020-10-09 21:09:35 +02:00
const config = {
2020-09-19 20:49:33 +02:00
"info" : {
"name" : "ImageUtilities" ,
"author" : "DevilBro" ,
2020-12-17 20:33:36 +01:00
"version" : "4.2.4" ,
2020-10-16 10:25:30 +02:00
"description" : "Add a handful of options for images/emotes/avatars (direct download, reverse image search, zoom, copy image link, copy image to clipboard, gallery mode)"
2020-10-15 20:10:00 +02:00
} ,
"changeLog" : {
2020-12-15 15:03:09 +01:00
"improved" : {
2020-12-16 10:58:13 +01:00
"Download locations" : "Merged 'save' and 'save as' entry, clicking it opens the save as modal, and hovering over it opens a submenu for preset paths, you can add your own download locations in the plugin settings" ,
"Toggle" : "You can now toggle the download locations"
2020-12-15 15:03:09 +01:00
} ,
2020-11-26 09:53:49 +01:00
"fixed" : {
2020-12-17 20:33:36 +01:00
"Slow modal transitions" : "Fixed issue where the css of the plugin would cause render slow downds for modals" ,
"New download locations" : "Fixed issue where you needed to restart plugin for new locations to be editable"
2020-10-15 20:10:00 +02:00
}
2020-08-14 15:18:33 +02:00
}
2020-09-19 20:49:33 +02:00
} ;
2020-10-15 20:10:00 +02:00
2020-10-09 21:09:35 +02:00
return ! window . BDFDB _Global || ( ! window . BDFDB _Global . loaded && ! window . BDFDB _Global . started ) ? class {
2021-01-06 12:38:36 +01:00
getName ( ) { return config . info . name ; }
getAuthor ( ) { return config . info . author ; }
getVersion ( ) { return config . info . version ; }
getDescription ( ) { return config . info . description ; }
2020-09-19 20:49:33 +02:00
2021-01-06 12:38:36 +01:00
load ( ) {
2020-11-19 16:51:14 +01:00
if ( ! window . BDFDB _Global || ! Array . isArray ( window . BDFDB _Global . pluginQueue ) ) window . BDFDB _Global = Object . assign ( { } , window . BDFDB _Global , { pluginQueue : [ ] } ) ;
2020-09-19 20:49:33 +02:00
if ( ! window . BDFDB _Global . downloadModal ) {
window . BDFDB _Global . downloadModal = true ;
BdApi . showConfirmationModal ( "Library Missing" , ` The library plugin needed for ${ config . info . name } is missing. Please click "Download Now" to install it. ` , {
confirmText : "Download Now" ,
cancelText : "Cancel" ,
onCancel : _ => { delete window . BDFDB _Global . downloadModal ; } ,
2020-09-20 08:15:13 +02:00
onConfirm : _ => {
delete window . BDFDB _Global . downloadModal ;
2020-11-19 16:45:36 +01:00
require ( "request" ) . get ( "https://mwittrien.github.io/BetterDiscordAddons/Library/0BDFDB.plugin.js" , ( e , r , b ) => {
2020-10-20 23:25:34 +02:00
if ( ! e && b && b . indexOf ( ` * @name BDFDB ` ) > - 1 ) require ( "fs" ) . writeFile ( require ( "path" ) . join ( BdApi . Plugins . folder , "0BDFDB.plugin.js" ) , b , _ => { } ) ;
2020-09-20 08:15:13 +02:00
else BdApi . alert ( "Error" , "Could not download BDFDB library plugin, try again some time later." ) ;
} ) ;
}
2020-09-19 20:49:33 +02:00
} ) ;
}
if ( ! window . BDFDB _Global . pluginQueue . includes ( config . info . name ) ) window . BDFDB _Global . pluginQueue . push ( config . info . name ) ;
2020-10-09 21:09:35 +02:00
}
2021-01-06 12:38:36 +01:00
start ( ) { this . load ( ) ; }
stop ( ) { }
getSettingsPanel ( ) {
2020-11-28 23:12:09 +01:00
let template = document . createElement ( "template" ) ;
template . innerHTML = ` <div style="color: var(--header-primary); font-size: 16px; font-weight: 300; white-space: pre; line-height: 22px;">The library plugin needed for ${ config . info . name } is missing. \n Please click <a style="font-weight: 500;">Download Now</a> to install it.</div> ` ;
template . content . firstElementChild . querySelector ( "a" ) . addEventListener ( "click" , _ => {
require ( "request" ) . get ( "https://mwittrien.github.io/BetterDiscordAddons/Library/0BDFDB.plugin.js" , ( e , r , b ) => {
if ( ! e && b && b . indexOf ( ` * @name BDFDB ` ) > - 1 ) require ( "fs" ) . writeFile ( require ( "path" ) . join ( BdApi . Plugins . folder , "0BDFDB.plugin.js" ) , b , _ => { } ) ;
else BdApi . alert ( "Error" , "Could not download BDFDB library plugin, try again some time later." ) ;
} ) ;
} ) ;
return template . content . firstElementChild ;
}
2020-10-09 21:09:35 +02:00
} : ( ( [ Plugin , BDFDB ] ) => {
2020-09-19 20:49:33 +02:00
const imgUrlReplaceString = "DEVILBRO_BD_REVERSEIMAGESEARCH_REPLACE_IMAGEURL" ;
var firedEvents = [ ] , clickedImage ;
2020-12-15 15:03:09 +01:00
var settings = { } , amounts = { } , zoomSettings = { } , engines = { } , enabledEngines = { } , ownLocations = { } , downloadsFolder ;
2020-09-19 20:49:33 +02:00
const ImageDetails = class ImageDetails extends BdApi . React . Component {
2021-01-06 12:38:36 +01:00
componentDidMount ( ) {
2020-11-26 09:53:49 +01:00
this . props . attachment = BDFDB . ReactUtils . findValue ( BDFDB . ObjectUtils . get ( this , ` ${ BDFDB . ReactUtils . instanceKey } .return ` ) , "attachment" , { up : true } ) ;
2020-08-14 15:18:33 +02:00
BDFDB . ReactUtils . forceUpdate ( this ) ;
}
2021-01-06 12:38:36 +01:00
componentDidUpdate ( ) {
2020-09-19 20:49:33 +02:00
if ( ( ! this . props . attachment || ! this . props . attachment . size ) && ! this . props . loaded ) {
this . props . loaded = true ;
2020-11-26 09:53:49 +01:00
this . props . attachment = BDFDB . ReactUtils . findValue ( BDFDB . ObjectUtils . get ( this , ` ${ BDFDB . ReactUtils . instanceKey } .return ` ) , "attachment" , { up : true } ) ;
2020-09-19 20:49:33 +02:00
BDFDB . ReactUtils . forceUpdate ( this ) ;
2020-08-14 14:37:10 +02:00
}
2020-09-19 20:49:33 +02:00
}
2021-01-06 12:38:36 +01:00
render ( ) {
2020-09-19 20:49:33 +02:00
return ! this . props . attachment ? null : BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . Flex , {
className : BDFDB . disCN . _imageutilitiesimagedetails ,
children : [
BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . Flex . Child , {
children : BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . Anchor , {
title : this . props . original ,
href : this . props . original ,
children : this . props . attachment . filename ,
onClick : event => {
BDFDB . ListenerUtils . stopEvent ( event ) ;
BDFDB . DiscordUtils . openLink ( this . props . original ) ;
}
} )
} ) ,
BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . Flex . Child , {
children : BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . TextElement , {
children : BDFDB . NumberUtils . formatBytes ( this . props . attachment . size )
} )
} ) ,
BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . Flex . Child , {
children : BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . TextElement , {
children : ` ${ this . props . attachment . width } x ${ this . props . attachment . height } px `
} )
} )
]
} ) ;
}
} ;
2020-10-09 21:09:35 +02:00
return class ImageUtilities extends Plugin {
2021-01-06 12:38:36 +01:00
onLoad ( ) {
2020-09-19 20:49:33 +02:00
firedEvents = [ ] ;
clickedImage = null ;
this . defaults = {
settings : {
2021-01-10 11:41:01 +01:00
resizeImage : { value : true , inner : false , description : "Always resize Image to fit the whole Image Modal" } ,
addDetails : { value : true , inner : false , description : "Add Image Details (Name, Size, Amount) in the Image Modal" } ,
showAsHeader : { value : true , inner : false , description : "Show Image Details as a Details Header above the Image in the Chat" } ,
showOnHover : { value : false , inner : false , description : "Show Image Details as Tooltip in the Chat" } ,
enableGallery : { value : true , inner : false , description : "Display previous/next Images in the same message in the Image Modal" } ,
enableZoom : { value : true , inner : false , description : "Create a Zoom Lens if you press down on an Image in the Image Modal" } ,
enableCopyImg : { value : true , inner : false , description : "Add a copy Image option in the Image Modal" } ,
enableSaveImg : { value : true , inner : false , description : "Add a save Image as option in the Image Modal" } ,
2020-11-19 16:51:14 +01:00
addUserAvatarEntry : { value : true , inner : true , description : "User Avatars" } ,
addGuildIconEntry : { value : true , inner : true , description : "Server Icons" } ,
addEmojiEntry : { value : true , inner : true , description : "Custom Emojis/Emotes" }
2020-09-19 20:49:33 +02:00
} ,
amounts : {
2021-01-10 11:41:01 +01:00
hoverDelay : { value : 0 , min : 0 , description : "Image Tooltip Delay (in ms)" }
2020-09-19 20:49:33 +02:00
} ,
zoomSettings : {
2020-12-16 10:58:13 +01:00
zoomlevel : { value : 2 , digits : 1 , minValue : 1 , maxValue : 20 , unit : "x" , label : "ACCESSIBILITY_ZOOM_LEVEL_LABEL" } ,
2020-12-21 19:56:36 +01:00
lensesize : { value : 200 , digits : 0 , minValue : 50 , maxValue : 5000 , unit : "px" , label : "context_lenssize" }
2020-09-19 20:49:33 +02:00
} ,
engines : {
2020-11-19 16:51:14 +01:00
_all : { value : true , name : BDFDB . LanguageUtils . LanguageStrings . FORM _LABEL _ALL , url : null } ,
Baidu : { value : true , name : "Baidu" , url : "http://image.baidu.com/pcdutu?queryImageUrl=" + imgUrlReplaceString } ,
Bing : { value : true , name : "Bing" , url : "https://www.bing.com/images/search?q=imgurl: " + imgUrlReplaceString + "&view=detailv2&iss=sbi&FORM=IRSBIQ" } ,
2020-12-15 15:03:09 +01:00
Google : { value : true , name : "Google" , url : "https://images.google.com/searchbyimage?image_url=" + imgUrlReplaceString } ,
2020-11-19 16:51:14 +01:00
IQDB : { value : true , name : "IQDB" , url : "https://iqdb.org/?url=" + imgUrlReplaceString } ,
2020-12-15 15:03:09 +01:00
Reddit : { value : true , name : "Reddit" , url : "http://karmadecay.com/search?q=" + imgUrlReplaceString } ,
2020-11-19 16:51:14 +01:00
SauceNAO : { value : true , name : "SauceNAO" , url : "https://saucenao.com/search.php?db=999&url=" + imgUrlReplaceString } ,
Sogou : { value : true , name : "Sogou" , url : "http://pic.sogou.com/ris?flag=1&drag=0&query=" + imgUrlReplaceString + "&flag=1" } ,
2020-12-15 15:03:09 +01:00
TinEye : { value : true , name : "TinEye" , url : "https://tineye.com/search?url=" + imgUrlReplaceString } ,
2020-11-19 16:51:14 +01:00
WhatAnime : { value : true , name : "WhatAnime" , url : "https://trace.moe/?url=" + imgUrlReplaceString } ,
2020-12-15 15:03:09 +01:00
Yandex : { value : true , name : "Yandex" , url : "https://yandex.com/images/search?url=" + imgUrlReplaceString + "&rpt=imageview" }
2020-09-19 20:49:33 +02:00
}
} ;
2020-08-14 14:37:10 +02:00
2020-09-19 20:49:33 +02:00
this . patchedModules = {
2020-10-16 19:47:23 +02:00
before : {
LazyImage : "render"
} ,
2020-09-19 20:49:33 +02:00
after : {
ImageModal : [ "render" , "componentDidMount" ] ,
LazyImage : [ "render" , "componentDidMount" ]
}
} ;
this . css = `
$ { BDFDB . dotCN . _imageutilitiesimagedetails } {
margin : 5 px 0 ;
}
$ { BDFDB . dotCNS . spoilerhidden + BDFDB . dotCN . _imageutilitiesimagedetails } {
visibility : hidden ;
max - width : 1 px ;
}
2020-12-15 15:03:09 +01:00
$ { BDFDB . dotCN . _imageutilitiesgallery } ,
$ { BDFDB . dotCN . _imageutilitiesdetailsadded } {
2020-09-19 20:49:33 +02:00
transform : unset ! important ;
}
$ { BDFDB . dotCN . _imageutilitiessibling } {
display : flex ;
align - items : center ;
position : fixed ;
top : 50 % ;
bottom : 50 % ;
cursor : pointer ;
}
$ { BDFDB . dotCN . _imageutilitiesprevious } {
justify - content : flex - end ;
right : 90 % ;
}
$ { BDFDB . dotCN . _imageutilitiesnext } {
justify - content : flex - start ;
left : 90 % ;
}
$ { BDFDB . dotCN . _imageutilitiesswitchicon } {
position : absolute ;
background : rgba ( 0 , 0 , 0 , 0.3 ) ;
border - radius : 50 % ;
padding : 15 px ;
transition : all 0.3 s ease ;
}
$ { BDFDB . dotCNS . _imageutilitiesprevious + BDFDB . dotCN . _imageutilitiesswitchicon } {
right : 10 px ;
}
$ { BDFDB . dotCNS . _imageutilitiesnext + BDFDB . dotCN . _imageutilitiesswitchicon } {
left : 10 px ;
}
$ { BDFDB . dotCN . _imageutilitiessibling } : hover $ { BDFDB . dotCN . _imageutilitiesswitchicon } {
background : rgba ( 0 , 0 , 0 , 0.5 ) ;
}
$ { BDFDB . dotCN . _imageutilitiesdetailswrapper } {
position : fixed ;
bottom : 10 px ;
left : 15 px ;
right : 15 px ;
pointer - events : none ;
}
$ { BDFDB . dotCN . _imageutilitiesdetails } {
2020-11-17 21:56:17 +01:00
color : # dcddde ;
2020-09-19 20:49:33 +02:00
margin - top : 5 px ;
font - size : 14 px ;
font - weight : 500 ;
2020-10-16 19:47:23 +02:00
white - space : nowrap ;
overflow : hidden ;
text - overflow : ellipsis ;
2020-09-19 20:49:33 +02:00
}
$ { BDFDB . dotCN . _imageutilitiesdetailslabel } {
font - weight : 600 ;
}
$ { BDFDB . dotCN . _imageutilitieslense } {
border : 2 px solid rgb ( 114 , 137 , 218 ) ;
}
$ { BDFDB . dotCN . _imageutilitiesoperations } {
position : absolute ;
display : flex ;
}
$ { BDFDB . dotCNS . _imageutilitiesoperations + BDFDB . dotCN . downloadlink } {
position : relative ! important ;
white - space : nowrap ! important ;
}
$ { BDFDB . dotCNS . _imageutilitiesoperations + BDFDB . dotCN . anchor + BDFDB . dotCN . downloadlink } {
margin : 0 ! important ;
}
` ;
2020-08-14 14:37:10 +02:00
}
2020-09-19 20:49:33 +02:00
2021-01-06 12:38:36 +01:00
onStart ( ) {
2020-12-16 10:58:13 +01:00
// REMOVE 16.12.2020
let oL = BDFDB . DataUtils . load ( this , "ownLocations" ) , c = false ;
for ( let i in oL ) if ( ! BDFDB . ObjectUtils . is ( oL [ i ] ) ) {
oL [ i ] = { enabled : true , location : oL [ i ] } ;
c = true ;
}
if ( c ) BDFDB . DataUtils . save ( oL , this , "ownLocations" )
2020-08-14 14:37:10 +02:00
BDFDB . ListenerUtils . add ( this , document . body , "click" , BDFDB . dotCNS . message + BDFDB . dotCNS . imagewrapper + "img" , e => {
clickedImage = e . target ;
BDFDB . TimeUtils . timeout ( _ => { clickedImage = null ; } ) ;
} ) ;
2020-08-14 15:26:54 +02:00
2020-09-11 19:31:36 +02:00
BDFDB . PatchUtils . patch ( this , ( BDFDB . ModuleUtils . findByName ( "renderImageComponent" , false ) . exports || { } ) , "renderImageComponent" , { after : e => {
2020-11-19 16:45:36 +01:00
if ( e . returnValue && e . returnValue . type && ( e . returnValue . type . displayName == "LazyImageZoomable" || e . returnValue . type . displayName == "LazyImage" ) && e . methodArguments [ 0 ] . original && e . methodArguments [ 0 ] . src . indexOf ( "https://media.discordapp.net/attachments" ) == 0 && ( e . methodArguments [ 0 ] . className || "" ) . indexOf ( BDFDB . disCN . embedthumbnail ) == - 1 ) return this . injectImageDetails ( e . methodArguments [ 0 ] , e . returnValue ) ;
2020-08-14 15:26:54 +02:00
} } ) ;
2020-08-14 14:37:10 +02:00
this . forceUpdateAll ( ) ;
}
2020-09-19 20:49:33 +02:00
2021-01-06 12:38:36 +01:00
onStop ( ) {
2020-08-15 10:38:15 +02:00
this . cleanupListeners ( "Gallery" ) ;
this . cleanupListeners ( "Zoom" ) ;
2020-08-14 14:37:10 +02:00
this . forceUpdateAll ( ) ;
}
2020-09-19 20:49:33 +02:00
getSettingsPanel ( collapseStates = { } ) {
2020-12-15 15:03:09 +01:00
let settingsPanel ;
2020-09-19 20:49:33 +02:00
2020-12-15 15:03:09 +01:00
return settingsPanel = BDFDB . PluginUtils . createSettingsPanel ( this , {
2020-09-19 20:49:33 +02:00
collapseStates : collapseStates ,
2020-12-15 15:03:09 +01:00
children : _ => {
let settingsItems = [ ] ;
settingsItems . push ( BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . CollapseContainer , {
title : "Settings" ,
collapseStates : collapseStates ,
children : Object . keys ( settings ) . map ( key => ! this . defaults . settings [ key ] . inner && BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . SettingsSaveItem , {
type : "Switch" ,
plugin : this ,
keys : [ "settings" , key ] ,
label : this . defaults . settings [ key ] . description ,
value : settings [ key ]
} ) ) . concat ( Object . keys ( amounts ) . map ( key => BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . SettingsSaveItem , {
type : "TextInput" ,
plugin : this ,
keys : [ "amounts" , key ] ,
label : this . defaults . amounts [ key ] . description ,
basis : "50%" ,
childProps : { type : "number" } ,
min : this . defaults . amounts [ key ] . min ,
max : this . defaults . amounts [ key ] . max ,
value : amounts [ key ]
} ) ) ) . filter ( n => n )
} ) ) ;
settingsItems . push ( BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . CollapseContainer , {
title : "Download Locations" ,
collapseStates : collapseStates ,
children : [
BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . FormComponents . FormTitle , {
className : BDFDB . disCN . marginbottom4 ,
tag : BDFDB . LibraryComponents . FormComponents . FormTitle . Tags . H3 ,
children : "Add additional Download Locations: "
} ) ,
BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . Flex , {
className : BDFDB . disCN . marginbottom8 ,
align : BDFDB . LibraryComponents . Flex . Align . END ,
children : [
BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . Flex . Child , {
children : BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . FormComponents . FormItem , {
title : "Name:" ,
children : BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . TextInput , {
className : "input-newlocation input-name" ,
value : "" ,
placeholder : "Name"
} )
} )
} ) ,
BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . Flex . Child , {
children : BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . FormComponents . FormItem , {
title : "Location:" ,
children : BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . TextInput , {
className : "input-newlocation input-location" ,
value : "" ,
placeholder : "Location"
} )
} )
} ) ,
BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . Button , {
style : { marginBottom : 1 } ,
onClick : _ => {
for ( let input of settingsPanel . props . _node . querySelectorAll ( ".input-newlocation " + BDFDB . dotCN . input ) ) if ( ! input . value || input . value . length == 0 || input . value . trim ( ) . length == 0 ) return BDFDB . NotificationUtils . toast ( "Fill out all fields to add a new location." , { type : "danger" } ) ;
let name = settingsPanel . props . _node . querySelector ( ".input-name " + BDFDB . dotCN . input ) . value . trim ( ) ;
let location = settingsPanel . props . _node . querySelector ( ".input-location " + BDFDB . dotCN . input ) . value . trim ( ) ;
if ( ownLocations [ name ] || name == "Downloads" ) return BDFDB . NotificationUtils . toast ( "A location with the choosen name already exists, please choose another name" , { type : "danger" } ) ;
else if ( ! BDFDB . LibraryRequires . fs . existsSync ( location ) ) return BDFDB . NotificationUtils . toast ( "The choosen download location is not a valid path to a folder" , { type : "danger" } ) ;
else {
2020-12-17 20:33:36 +01:00
ownLocations [ name ] = { enabled : true , location : location } ;
2020-12-15 15:03:09 +01:00
BDFDB . DataUtils . save ( ownLocations , this , "ownLocations" ) ;
BDFDB . PluginUtils . refreshSettingsPanel ( this , settingsPanel , collapseStates ) ;
}
} ,
children : BDFDB . LanguageUtils . LanguageStrings . ADD
} )
]
} )
] . concat ( BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . SettingsPanelList , {
title : "Your own Download Locations:" ,
dividerTop : true ,
children : Object . keys ( ownLocations ) . map ( name => {
let editable = name != "Downloads" ;
return BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . Card , {
horizontal : true ,
children : [
BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . Flex . Child , {
grow : 0 ,
basis : "180px" ,
children : BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . TextInput , {
value : name ,
placeholder : name ,
size : BDFDB . LibraryComponents . TextInput . Sizes . MINI ,
maxLength : 100000000000000000000 ,
style : { marginRight : 6 } ,
disabled : ! editable ,
onChange : ! editable ? null : value => {
ownLocations [ value ] = ownLocations [ name ] ;
delete ownLocations [ name ] ;
BDFDB . DataUtils . save ( ownLocations , this , "ownLocations" ) ;
}
} )
} ) ,
BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . Flex . Child , {
children : BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . TextInput , {
2020-12-16 10:58:13 +01:00
value : ownLocations [ name ] . location ,
placeholder : ownLocations [ name ] . location ,
2020-12-15 15:03:09 +01:00
size : BDFDB . LibraryComponents . TextInput . Sizes . MINI ,
maxLength : 100000000000000000000 ,
2020-12-16 10:58:13 +01:00
style : { marginRight : 10 } ,
2020-12-15 15:03:09 +01:00
disabled : ! editable ,
onChange : ! editable ? null : value => {
2020-12-16 10:58:13 +01:00
ownLocations [ name ] . location = value ;
BDFDB . DataUtils . save ( ownLocations , this , "ownLocations" ) ;
}
} )
} ) ,
BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . Flex . Child , {
children : BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . Switch , {
value : ownLocations [ name ] . enabled ,
size : BDFDB . LibraryComponents . Switch . Sizes . MINI ,
onChange : value => {
ownLocations [ name ] . enabled = value ;
2020-12-15 15:03:09 +01:00
BDFDB . DataUtils . save ( ownLocations , this , "ownLocations" ) ;
}
} )
} )
] ,
noRemove : ! editable ,
onRemove : ! editable ? null : _ => {
delete ownLocations [ name ] ;
BDFDB . DataUtils . save ( ownLocations , this , "ownLocations" ) ;
BDFDB . PluginUtils . refreshSettingsPanel ( this , settingsPanel ) ;
}
} ) ;
} )
} ) ) . filter ( n => n )
} ) ) ;
settingsItems . push ( BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . CollapseContainer , {
title : "Context Menu Entries" ,
collapseStates : collapseStates ,
children : [ BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . FormComponents . FormTitle , {
className : BDFDB . disCN . marginbottom4 ,
tag : BDFDB . LibraryComponents . FormComponents . FormTitle . Tags . H3 ,
children : "Add additional Context Menu Entry for: "
} ) ] . concat ( Object . keys ( settings ) . map ( key => this . defaults . settings [ key ] . inner && BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . SettingsSaveItem , {
type : "Switch" ,
plugin : this ,
keys : [ "settings" , key ] ,
label : this . defaults . settings [ key ] . description ,
value : settings [ key ]
} ) ) )
} ) ) ;
settingsItems . push ( BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . CollapseContainer , {
title : "Search Engines" ,
collapseStates : collapseStates ,
children : Object . keys ( engines ) . filter ( n => n && n != "_all" ) . map ( key => BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . SettingsSaveItem , {
type : "Switch" ,
plugin : this ,
keys : [ "engines" , key ] ,
label : this . defaults . engines [ key ] . name ,
value : engines [ key ]
} ) )
} ) ) ;
return settingsItems ;
}
} ) ;
2020-09-19 20:49:33 +02:00
}
2021-01-06 12:38:36 +01:00
onSettingsClosed ( ) {
2020-09-19 20:49:33 +02:00
if ( this . SettingsUpdated ) {
delete this . SettingsUpdated ;
this . forceUpdateAll ( ) ;
}
}
2020-08-14 14:37:10 +02:00
2021-01-06 12:38:36 +01:00
forceUpdateAll ( ) {
2020-09-19 20:49:33 +02:00
settings = BDFDB . DataUtils . get ( this , "settings" ) ;
amounts = BDFDB . DataUtils . get ( this , "amounts" ) ;
zoomSettings = BDFDB . DataUtils . get ( this , "zoomSettings" ) ;
engines = BDFDB . DataUtils . get ( this , "engines" ) ;
enabledEngines = BDFDB . ObjectUtils . filter ( engines , n => n ) ;
2020-12-16 10:58:13 +01:00
ownLocations = Object . assign ( { "Downloads" : { enabled : true , location : this . getDownloadLocation ( ) } } , BDFDB . DataUtils . load ( this , "ownLocations" ) ) ;
2020-08-14 14:37:10 +02:00
2020-09-19 20:49:33 +02:00
BDFDB . PatchUtils . forceAllUpdates ( this ) ;
BDFDB . MessageUtils . rerenderAll ( ) ;
2020-08-14 14:37:10 +02:00
}
2020-09-19 20:49:33 +02:00
onGuildContextMenu ( e ) {
if ( e . instance . props . guild && settings . addGuildIconEntry ) {
let banner = BDFDB . DOMUtils . getParent ( BDFDB . dotCN . guildheader , e . instance . props . target ) || BDFDB . DOMUtils . getParent ( BDFDB . dotCN . guildchannels , e . instance . props . target ) && ! e . instance . props . target . className && e . instance . props . target . parentElement . firstElementChild == e . instance . props . target ;
if ( banner ) {
2020-09-20 07:29:33 +02:00
if ( e . instance . props . guild . banner ) this . injectItem ( e , BDFDB . LibraryModules . IconUtils . getGuildBannerURL ( e . instance . props . guild ) ) ;
2020-09-19 20:49:33 +02:00
}
else if ( e . type != "GuildChannelListContextMenu" ) this . injectItem ( e , e . instance . props . guild . getIconURL ( "png" ) , BDFDB . LibraryModules . IconUtils . hasAnimatedGuildIcon ( e . instance . props . guild ) && e . instance . props . guild . getIconURL ( "gif" ) ) ;
2020-09-13 19:22:10 +02:00
}
}
2020-08-14 14:37:10 +02:00
2020-09-19 20:49:33 +02:00
onUserContextMenu ( e ) {
if ( e . instance . props . user && settings . addUserAvatarEntry ) this . injectItem ( e , e . instance . props . user . getAvatarURL ( "png" ) , BDFDB . LibraryModules . IconUtils . hasAnimatedAvatar ( e . instance . props . user ) && e . instance . props . user . getAvatarURL ( "gif" ) )
2020-08-14 14:37:10 +02:00
}
2020-09-19 20:49:33 +02:00
onNativeContextMenu ( e ) {
if ( e . type == "NativeImageContextMenu" && ( e . instance . props . href || e . instance . props . src ) ) {
this . injectItem ( e , e . instance . props . href || e . instance . props . src ) ;
2020-08-14 14:37:10 +02:00
}
}
2020-09-19 20:49:33 +02:00
onMessageContextMenu ( e ) {
if ( e . instance . props . message && e . instance . props . channel && e . instance . props . target ) {
if ( e . instance . props . attachment ) this . injectItem ( e , e . instance . props . attachment . url ) ;
else if ( e . instance . props . target . tagName == "A" && e . instance . props . message . embeds && e . instance . props . message . embeds [ 0 ] && e . instance . props . message . embeds [ 0 ] . type == "image" ) this . injectItem ( e , e . instance . props . target . href ) ;
else if ( e . instance . props . target . tagName == "IMG" ) {
if ( BDFDB . DOMUtils . containsClass ( e . instance . props . target . parentElement , BDFDB . disCN . imagewrapper ) ) this . injectItem ( e , e . instance . props . target . src ) ;
else if ( BDFDB . DOMUtils . containsClass ( e . instance . props . target , BDFDB . disCN . embedauthoricon ) && settings . addUserAvatarEntry ) this . injectItem ( e , e . instance . props . target . src ) ;
else if ( BDFDB . DOMUtils . containsClass ( e . instance . props . target , BDFDB . disCN . emojiold , "emote" , false ) && settings . addEmojiEntry ) this . injectItem ( e , e . instance . props . target . src ) ;
2020-08-31 21:41:39 +02:00
}
2020-09-19 20:49:33 +02:00
else {
let reaction = BDFDB . DOMUtils . getParent ( BDFDB . dotCN . messagereaction , e . instance . props . target ) ;
if ( reaction && settings . addEmojiEntry ) this . injectItem ( e , reaction . querySelector ( BDFDB . dotCN . emojiold ) . src ) ;
2020-08-24 21:10:15 +02:00
}
2020-09-19 20:49:33 +02:00
}
}
injectItem ( e , ... urls ) {
let types = [ ] ;
let validUrls = urls . filter ( n => this . isValidImg ( n ) ) . map ( n => {
let url = n . replace ( /^url\(|\)$|"|'/g , "" ) . replace ( /\?size\=\d+$/ , "?size=4096" ) . replace ( /[\?\&](height|width)=\d+/g , "" ) ;
2020-11-19 16:45:36 +01:00
if ( url . indexOf ( "https://images-ext-1.discordapp.net/external/" ) > - 1 ) {
if ( url . split ( "/https/" ) . length > 1 ) url = "https://" + url . split ( "/https/" ) . pop ( ) ;
else if ( url . split ( "/http/" ) . length > 1 ) url = "http://" + url . split ( "/http/" ) . pop ( ) ;
2020-08-24 21:10:15 +02:00
}
2020-09-19 20:49:33 +02:00
const file = url && ( BDFDB . LibraryModules . URLParser . parse ( url ) . pathname || "" ) . toLowerCase ( ) ;
const type = file && file . split ( "." ) . pop ( ) ;
return url && type && ! types . includes ( type ) && types . push ( type ) && { url , type } ;
} ) . filter ( n => n ) ;
if ( ! validUrls . length ) return ;
let [ children , index ] = BDFDB . ContextMenuUtils . findItem ( e . returnvalue , { id : "devmode-copy-id" , group : true } ) ;
children . splice ( index > - 1 ? index : children . length , 0 , BDFDB . ContextMenuUtils . createItem ( BDFDB . LibraryComponents . MenuItems . MenuGroup , {
children : BDFDB . ContextMenuUtils . createItem ( BDFDB . LibraryComponents . MenuItems . MenuItem , {
2020-12-21 20:30:41 +01:00
label : BDFDB . LanguageUtils . LanguageStrings . IMAGE + " " + BDFDB . LanguageUtils . LanguageStrings . ACTIONS ,
2020-09-19 20:49:33 +02:00
id : BDFDB . ContextMenuUtils . createItemId ( this . name , "main-subitem" ) ,
children : validUrls . length == 1 ? this . createUrlMenu ( e , validUrls [ 0 ] . url ) : validUrls . map ( ( urlData , i ) => BDFDB . ContextMenuUtils . createItem ( BDFDB . LibraryComponents . MenuItems . MenuItem , {
label : urlData . type . toUpperCase ( ) ,
id : BDFDB . ContextMenuUtils . createItemId ( this . name , "subitem" , i ) ,
children : this . createUrlMenu ( e , urlData . url )
} ) )
} )
} ) ) ;
}
createUrlMenu ( e , url ) {
let enginesWithoutAll = BDFDB . ObjectUtils . filter ( enabledEngines , n => n != "_all" , true ) ;
let engineKeys = Object . keys ( enginesWithoutAll ) ;
2020-12-16 10:58:13 +01:00
let locations = Object . keys ( ownLocations ) . filter ( n => ownLocations [ n ] . enabled ) ;
2020-09-19 20:49:33 +02:00
return [
BDFDB . ContextMenuUtils . createItem ( BDFDB . LibraryComponents . MenuItems . MenuItem , {
2020-12-21 19:56:36 +01:00
label : this . labels . context _viewimage ,
2020-09-19 20:49:33 +02:00
id : BDFDB . ContextMenuUtils . createItemId ( this . name , "view-image" ) ,
action : _ => {
let img = new Image ( ) ;
img . onload = function ( ) {
BDFDB . LibraryModules . ModalUtils . openModal ( modalData => {
return BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . ModalComponents . ModalRoot , Object . assign ( {
className : BDFDB . disCN . imagemodal
} , modalData , {
size : BDFDB . LibraryComponents . ModalComponents . ModalSize . DYNAMIC ,
"aria-label" : BDFDB . LanguageUtils . LanguageStrings . IMAGE ,
children : BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . ImageModal , {
src : url ,
original : url ,
width : this . width ,
height : this . height ,
className : BDFDB . disCN . imagemodalimage ,
shouldAnimate : true ,
renderLinkComponent : props => BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . Anchor , props )
} )
} ) , true ) ;
} ) ;
} ;
img . src = url ;
}
} ) ,
BDFDB . ContextMenuUtils . createItem ( BDFDB . LibraryComponents . MenuItems . MenuItem , {
2020-12-21 19:56:36 +01:00
label : this . labels . context _saveimageas ,
2020-09-19 20:49:33 +02:00
id : BDFDB . ContextMenuUtils . createItemId ( this . name , "download-image-as" ) ,
action : _ => {
2020-12-15 15:03:09 +01:00
this . downloadImageAs ( url ) ;
} ,
2020-12-16 10:58:13 +01:00
children : locations . length && BDFDB . ContextMenuUtils . createItem ( BDFDB . LibraryComponents . MenuItems . MenuGroup , {
children : locations . map ( ( name , i ) => BDFDB . ContextMenuUtils . createItem ( BDFDB . LibraryComponents . MenuItems . MenuItem , {
2020-12-15 15:03:09 +01:00
id : BDFDB . ContextMenuUtils . createItemId ( this . name , "download" , name , i ) ,
label : name ,
action : _ => {
2020-12-16 10:58:13 +01:00
this . downloadImage ( url , ownLocations [ name ] . location ) ;
2020-12-15 15:03:09 +01:00
}
} ) )
} )
2020-09-19 20:49:33 +02:00
} ) ,
! this . isCopyable ( url ) ? null : BDFDB . ContextMenuUtils . createItem ( BDFDB . LibraryComponents . MenuItems . MenuItem , {
2020-12-21 19:56:36 +01:00
label : this . labels . context _copyimage ,
2020-09-19 20:49:33 +02:00
id : BDFDB . ContextMenuUtils . createItemId ( this . name , "copy-image" ) ,
action : _ => {
this . copyImage ( url ) ;
}
} ) ,
BDFDB . ContextMenuUtils . createItem ( BDFDB . LibraryComponents . MenuItems . MenuItem , {
2020-12-21 19:56:36 +01:00
label : this . labels . context _copyimagelink ,
2020-09-19 20:49:33 +02:00
id : BDFDB . ContextMenuUtils . createItemId ( this . name , "copy-src" ) ,
action : _ => {
BDFDB . LibraryRequires . electron . clipboard . write ( { text : url } ) ;
BDFDB . NotificationUtils . toast ( this . labels . toast _copyimagelink _success , { type : "success" } ) ;
}
} ) ,
! this . isSearchable ( url ) ? null : engineKeys . length == 1 ? BDFDB . ContextMenuUtils . createItem ( BDFDB . LibraryComponents . MenuItems . MenuItem , {
2020-12-21 19:56:36 +01:00
label : this . labels . context _reverseimagesearch . replace ( "..." , this . defaults . engines [ engineKeys [ 0 ] ] . name ) ,
2020-09-19 20:49:33 +02:00
id : BDFDB . ContextMenuUtils . createItemId ( this . name , "single-search" ) ,
2020-08-24 21:10:15 +02:00
persisting : true ,
action : event => {
if ( ! event . shiftKey ) BDFDB . ContextMenuUtils . close ( e . instance ) ;
2021-01-10 11:41:01 +01:00
BDFDB . DiscordUtils . openLink ( this . defaults . engines [ engineKeys [ 0 ] ] . url . replace ( imgUrlReplaceString , encodeURIComponent ( url ) ) , {
minimized : event . shiftKey
} ) ;
2020-08-24 21:10:15 +02:00
}
2020-09-19 20:49:33 +02:00
} ) : BDFDB . ContextMenuUtils . createItem ( BDFDB . LibraryComponents . MenuItems . MenuItem , {
2020-12-21 19:56:36 +01:00
label : this . labels . context _reverseimagesearch ,
2020-09-19 20:49:33 +02:00
id : BDFDB . ContextMenuUtils . createItemId ( this . name , "submenu-search" ) ,
children : ! engineKeys . length ? BDFDB . ContextMenuUtils . createItem ( BDFDB . LibraryComponents . MenuItems . MenuItem , {
2020-12-21 19:56:36 +01:00
label : this . labels . submenu _disabled ,
2020-09-19 20:49:33 +02:00
id : BDFDB . ContextMenuUtils . createItemId ( this . name , "disabled" ) ,
disabled : true
} ) : Object . keys ( enabledEngines ) . map ( key => BDFDB . ContextMenuUtils . createItem ( BDFDB . LibraryComponents . MenuItems . MenuItem , {
label : this . defaults . engines [ key ] . name ,
id : BDFDB . ContextMenuUtils . createItemId ( this . name , "search" , key ) ,
color : key == "_all" ? BDFDB . LibraryComponents . MenuItems . Colors . DANGER : BDFDB . LibraryComponents . MenuItems . Colors . DEFAULT ,
persisting : true ,
action : event => {
if ( ! event . shiftKey ) BDFDB . ContextMenuUtils . close ( e . instance ) ;
if ( key == "_all" ) {
2021-01-10 11:41:01 +01:00
for ( let key2 in enginesWithoutAll ) BDFDB . DiscordUtils . openLink ( this . defaults . engines [ key2 ] . url . replace ( imgUrlReplaceString , encodeURIComponent ( url ) ) , {
minimized : event . shiftKey
} ) ;
2020-08-14 14:37:10 +02:00
}
2021-01-10 11:41:01 +01:00
else BDFDB . DiscordUtils . openLink ( this . defaults . engines [ key ] . url . replace ( imgUrlReplaceString , encodeURIComponent ( url ) ) , {
minimized : event . shiftKey
} ) ;
2020-09-19 20:49:33 +02:00
}
} ) )
} )
] . filter ( n => n ) ;
}
processImageModal ( e ) {
if ( clickedImage ) e . instance . props . cachedImage = clickedImage ;
let url = e . instance . props . cachedImage && e . instance . props . cachedImage . src ? e . instance . props . cachedImage : e . instance . props . src ;
url = url . src || url ;
let messages = this . getMessageGroupOfImage ( url ) ;
if ( e . returnvalue ) {
let [ children , index ] = BDFDB . ReactUtils . findParent ( e . returnvalue , { props : [ [ "className" , BDFDB . disCN . downloadlink ] ] } ) ;
if ( index > - 1 ) {
children [ index ] . props . onClick = event => {
return event . shiftKey ;
} ;
let openContext = event => {
BDFDB . ContextMenuUtils . open ( this , event , BDFDB . ContextMenuUtils . createItem ( BDFDB . LibraryComponents . MenuItems . MenuGroup , {
children : Object . keys ( zoomSettings ) . map ( type => BDFDB . ContextMenuUtils . createItem ( BDFDB . LibraryComponents . MenuItems . MenuSliderItem , Object . assign ( {
id : BDFDB . ContextMenuUtils . createItemId ( this . name , type ) ,
value : zoomSettings [ type ] ,
renderLabel : value => {
return ( this . labels [ this . defaults . zoomSettings [ type ] . label ] || BDFDB . LanguageUtils . LanguageStrings [ this . defaults . zoomSettings [ type ] . label ] ) + ": " + value + this . defaults . zoomSettings [ type ] . unit ;
} ,
onValueRender : value => {
return value + this . defaults . zoomSettings [ type ] . unit ;
} ,
onValueChange : value => {
zoomSettings [ type ] = value ;
BDFDB . DataUtils . save ( zoomSettings , this , "zoomSettings" ) ;
2020-08-14 14:37:10 +02:00
}
2020-09-19 20:49:33 +02:00
} , BDFDB . ObjectUtils . extract ( this . defaults . zoomSettings [ type ] , "digits" , "minValue" , "maxValue" ) ) ) )
} ) ) ;
} ;
2020-11-19 16:51:14 +01:00
let isVideo = ( typeof e . instance . props . children == "function" && e . instance . props . children ( Object . assign ( { } , e . instance . props , { size : e . instance . props } ) ) || { type : { } } ) . type . displayName == "Video" ;
2020-09-19 20:49:33 +02:00
children [ index ] = BDFDB . ReactUtils . createElement ( "span" , {
className : BDFDB . disCN . _imageutilitiesoperations ,
children : [
children [ index ] ,
settings . enableSaveImg && ! isVideo && [
BDFDB . ReactUtils . createElement ( "span" , {
className : BDFDB . disCN . downloadlink ,
children : "|" ,
style : { margin : "0 5px" }
} ) ,
BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . Anchor , {
className : BDFDB . disCN . downloadlink ,
2020-12-21 19:56:36 +01:00
children : this . labels . context _saveimageas ,
2020-09-19 20:49:33 +02:00
onClick : event => {
BDFDB . ListenerUtils . stopEvent ( event ) ;
2020-12-15 15:03:09 +01:00
this . downloadImageAs ( url ) ;
} ,
onContextMenu : event => {
2020-12-16 10:58:13 +01:00
let locations = Object . keys ( ownLocations ) . filter ( n => ownLocations [ n ] . enabled ) ;
if ( locations . length ) BDFDB . ContextMenuUtils . open ( this , event , BDFDB . ContextMenuUtils . createItem ( BDFDB . LibraryComponents . MenuItems . MenuGroup , {
children : Object . keys ( locations ) . map ( ( name , i ) => BDFDB . ContextMenuUtils . createItem ( BDFDB . LibraryComponents . MenuItems . MenuItem , {
2020-12-15 15:03:09 +01:00
id : BDFDB . ContextMenuUtils . createItemId ( this . name , "download" , name , i ) ,
label : name ,
action : _ => {
2020-12-16 10:58:13 +01:00
this . downloadImage ( url , ownLocations [ name ] . location ) ;
2020-12-15 15:03:09 +01:00
}
} ) )
} ) ) ;
2020-09-19 20:49:33 +02:00
}
} )
] ,
settings . enableCopyImg && this . isCopyable ( url ) && ! isVideo && [
BDFDB . ReactUtils . createElement ( "span" , {
className : BDFDB . disCN . downloadlink ,
children : "|" ,
style : { margin : "0 5px" }
} ) ,
BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . Anchor , {
className : BDFDB . disCN . downloadlink ,
2020-12-21 19:56:36 +01:00
children : this . labels . context _copyimage ,
2020-09-19 20:49:33 +02:00
onClick : event => {
BDFDB . ListenerUtils . stopEvent ( event ) ;
this . copyImage ( url ) ;
}
} )
] ,
settings . enableZoom && ! isVideo && [
BDFDB . ReactUtils . createElement ( "span" , {
className : BDFDB . disCN . downloadlink ,
children : "|" ,
style : { margin : "0 5px" }
} ) ,
BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . Anchor , {
className : BDFDB . disCN . downloadlink ,
children : ` Zoom ${ BDFDB . LanguageUtils . LanguageStrings . SETTINGS } ` ,
onClick : openContext ,
onContextMenu : openContext
} )
]
] . flat ( 10 ) . filter ( n => n )
} ) ;
2020-08-14 14:37:10 +02:00
}
2020-09-19 20:49:33 +02:00
let imageIndex = 0 , amount = 1 ;
if ( messages . length ) {
2020-10-16 19:47:23 +02:00
let data = this . getSiblingsAndPosition ( url , messages ) ;
imageIndex = data . index ;
amount = data . amount ;
if ( data . previous ) {
2020-09-19 20:49:33 +02:00
if ( e . instance . previousRef ) e . returnvalue . props . children . push ( this . createImageWrapper ( e . instance , e . instance . previousRef , "previous" , BDFDB . LibraryComponents . SvgIcon . Names . LEFT _CARET ) ) ;
2020-10-16 19:47:23 +02:00
else this . loadImage ( e . instance , data . previous , "previous" ) ;
2020-09-19 20:49:33 +02:00
}
2020-10-16 19:47:23 +02:00
if ( data . next ) {
2020-09-19 20:49:33 +02:00
if ( e . instance . nextRef ) e . returnvalue . props . children . splice ( 1 , 0 , this . createImageWrapper ( e . instance , e . instance . nextRef , "next" , BDFDB . LibraryComponents . SvgIcon . Names . RIGHT _CARET ) ) ;
2020-10-16 19:47:23 +02:00
else this . loadImage ( e . instance , data . next , "next" ) ;
2020-09-19 20:49:33 +02:00
}
2020-08-14 14:37:10 +02:00
}
2020-09-19 20:49:33 +02:00
if ( settings . addDetails ) e . returnvalue . props . children . push ( BDFDB . ReactUtils . createElement ( "div" , {
className : BDFDB . disCN . _imageutilitiesdetailswrapper ,
2020-08-14 15:41:21 +02:00
children : [
2020-09-19 20:49:33 +02:00
{ label : "Source" , text : e . instance . props . src } ,
{ label : "Size" , text : ` ${ e . instance . props . width } x ${ e . instance . props . height } px ` } ,
{ label : "Image" , text : ` ${ imageIndex + 1 } of ${ amount } ` }
] . map ( data => BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . TextElement , {
className : BDFDB . disCN . _imageutilitiesdetails ,
children : [
BDFDB . ReactUtils . createElement ( "div" , {
className : BDFDB . disCN . _imageutilitiesdetailslabel ,
children : data . label + ":"
} ) ,
data . text
]
} ) )
} ) ) ;
}
if ( e . node ) {
let modal = BDFDB . DOMUtils . getParent ( BDFDB . dotCNC . modal + BDFDB . dotCN . layermodal , e . node ) ;
if ( modal ) {
modal . className = BDFDB . DOMUtils . formatClassName ( modal . className , messages . length && BDFDB . disCN . _imageutilitiesgallery , settings . addDetails && BDFDB . disCN . _imageutilitiesdetailsadded ) ;
this . cleanupListeners ( "Gallery" ) ;
if ( messages . length ) {
document . keydownImageUtilitiesGalleryListener = event => {
if ( ! document . contains ( e . node ) ) this . cleanupListeners ( "Gallery" ) ;
else if ( ! firedEvents . includes ( "Gallery" ) ) {
firedEvents . push ( "Gallery" ) ;
if ( event . keyCode == 37 ) this . switchImages ( e . instance , "previous" ) ;
else if ( event . keyCode == 39 ) this . switchImages ( e . instance , "next" ) ;
}
} ;
document . keyupImageUtilitiesGalleryListener = _ => {
BDFDB . ArrayUtils . remove ( firedEvents , "Gallery" , true ) ;
if ( ! document . contains ( e . node ) ) this . cleanupListeners ( "Gallery" ) ;
} ;
document . addEventListener ( "keydown" , document . keydownImageUtilitiesGalleryListener ) ;
document . addEventListener ( "keyup" , document . keyupImageUtilitiesGalleryListener ) ;
}
2020-08-14 14:37:10 +02:00
}
}
}
2020-09-19 20:49:33 +02:00
processLazyImage ( e ) {
if ( e . node ) {
2020-11-17 18:46:57 +01:00
if ( e . instance . props . resized ) e . instance . state . readyState = BDFDB . LibraryComponents . Image . ImageReadyStates . READY ;
2020-10-15 20:10:00 +02:00
if ( settings . enableZoom && ! e . node . querySelector ( "video" ) && ! BDFDB . DOMUtils . containsClass ( e . node . parentElement , BDFDB . disCN . _imageutilitiessibling ) && BDFDB . DOMUtils . getParent ( BDFDB . dotCN . imagemodal , e . node ) ) {
2020-09-19 20:49:33 +02:00
e . node . addEventListener ( "mousedown" , event => {
if ( event . which != 1 ) return ;
BDFDB . ListenerUtils . stopEvent ( event ) ;
2020-08-14 14:37:10 +02:00
2020-09-19 20:49:33 +02:00
let imgRects = BDFDB . DOMUtils . getRects ( e . node . firstElementChild ) ;
2020-08-14 14:37:10 +02:00
2020-11-29 20:18:28 +01:00
let lens = BDFDB . DOMUtils . create ( ` <div class=" ${ BDFDB . disCN . _imageutilitieslense } " style="border-radius: 50% !important; pointer-events: none !important; z-index: 10000 !important; width: ${ zoomSettings . lensesize } px !important; height: ${ zoomSettings . lensesize } px !important; position: fixed !important;"><div style="position: absolute !important; top: 0 !important; right: 0 !important; bottom: 0 !important; left: 0 !important;">< ${ e . node . firstElementChild . tagName } src=" ${ e . instance . props . src } " style="width: ${ imgRects . width * zoomSettings . zoomlevel } px; height: ${ imgRects . height * zoomSettings . zoomlevel } px; position: fixed !important;" ${ e . node . firstElementChild . tagName == "VIDEO" ? " loop autoplay" : "" } ></ ${ e . node . firstElementChild . tagName } ></div></div> ` ) ;
let pane = lens . firstElementChild . firstElementChild ;
2020-09-19 20:49:33 +02:00
let backdrop = BDFDB . DOMUtils . create ( ` <div class=" ${ BDFDB . disCN . _imageutilitieslensebackdrop } " style="background: rgba(0, 0, 0, 0.3) !important; position: absolute !important; top: 0 !important; right: 0 !important; bottom: 0 !important; left: 0 !important; pointer-events: none !important; z-index: 8000 !important;"></div> ` ) ;
let appMount = document . querySelector ( BDFDB . dotCN . appmount ) ;
2020-11-29 20:18:28 +01:00
appMount . appendChild ( lens ) ;
2020-09-19 20:49:33 +02:00
appMount . appendChild ( backdrop ) ;
2020-08-15 10:38:15 +02:00
2020-11-29 20:18:28 +01:00
let lensRects = BDFDB . DOMUtils . getRects ( lens ) ;
2020-09-19 20:49:33 +02:00
2020-11-29 20:18:28 +01:00
let halfW = lensRects . width / 2 , halfH = lensRects . height / 2 ;
2020-09-19 20:49:33 +02:00
let minX = imgRects . left , maxX = minX + imgRects . width ;
let minY = imgRects . top , maxY = minY + imgRects . height ;
2020-11-29 20:18:28 +01:00
lens . update = _ => {
2020-09-19 20:49:33 +02:00
let x = event . clientX > maxX ? maxX - halfW : event . clientX < minX ? minX - halfW : event . clientX - halfW ;
let y = event . clientY > maxY ? maxY - halfH : event . clientY < minY ? minY - halfH : event . clientY - halfH ;
2020-11-29 20:18:28 +01:00
lens . style . setProperty ( "left" , x + "px" , "important" ) ;
lens . style . setProperty ( "top" , y + "px" , "important" ) ;
lens . style . setProperty ( "width" , zoomSettings . lensesize + "px" , "important" ) ;
lens . style . setProperty ( "height" , zoomSettings . lensesize + "px" , "important" ) ;
lens . style . setProperty ( "clip-path" , ` circle( ${ ( zoomSettings . lensesize / 2 ) + 2 } px at center) ` , "important" ) ;
lens . firstElementChild . style . setProperty ( "clip-path" , ` circle( ${ zoomSettings . lensesize / 2 } px at center) ` , "important" ) ;
2020-09-19 20:49:33 +02:00
pane . style . setProperty ( "left" , imgRects . left + ( ( zoomSettings . zoomlevel - 1 ) * ( imgRects . left - x - halfW ) ) + "px" , "important" ) ;
pane . style . setProperty ( "top" , imgRects . top + ( ( zoomSettings . zoomlevel - 1 ) * ( imgRects . top - y - halfH ) ) + "px" , "important" ) ;
pane . style . setProperty ( "width" , imgRects . width * zoomSettings . zoomlevel + "px" , "important" ) ;
pane . style . setProperty ( "height" , imgRects . height * zoomSettings . zoomlevel + "px" , "important" ) ;
} ;
2020-11-29 20:18:28 +01:00
lens . update ( ) ;
2020-09-19 20:49:33 +02:00
let dragging = event2 => {
event = event2 ;
2020-11-29 20:18:28 +01:00
lens . update ( ) ;
2020-09-19 20:49:33 +02:00
} ;
let releasing = _ => {
this . cleanupListeners ( "Zoom" ) ;
document . removeEventListener ( "mousemove" , dragging ) ;
document . removeEventListener ( "mouseup" , releasing ) ;
2020-10-12 23:54:27 +02:00
if ( document . removeImageUtilitiesZoomObserver ) {
document . removeImageUtilitiesZoomObserver . disconnect ( ) ;
delete document . removeImageUtilitiesZoomObserver ;
}
2020-11-29 20:18:28 +01:00
BDFDB . DOMUtils . remove ( lens , backdrop ) ;
2020-09-19 20:49:33 +02:00
BDFDB . DataUtils . save ( zoomSettings , this , "zoomSettings" ) ;
} ;
document . addEventListener ( "mousemove" , dragging ) ;
document . addEventListener ( "mouseup" , releasing ) ;
2020-08-15 10:38:15 +02:00
this . cleanupListeners ( "Zoom" ) ;
2020-09-19 20:49:33 +02:00
document . wheelImageUtilitiesZoomListener = event2 => {
if ( ! document . contains ( e . node ) ) this . cleanupListeners ( "Zoom" ) ;
else {
if ( event2 . deltaY < 0 && ( zoomSettings . zoomlevel + 0.1 ) <= this . defaults . zoomSettings . zoomlevel . maxValue ) {
zoomSettings . zoomlevel += 0.1 ;
2020-11-29 20:18:28 +01:00
lens . update ( ) ;
2020-09-19 20:49:33 +02:00
}
else if ( event2 . deltaY > 0 && ( zoomSettings . zoomlevel - 0.1 ) >= this . defaults . zoomSettings . zoomlevel . minValue ) {
zoomSettings . zoomlevel -= 0.1 ;
2020-11-29 20:18:28 +01:00
lens . update ( ) ;
2020-09-19 20:49:33 +02:00
}
2020-08-15 10:38:15 +02:00
}
2020-09-19 20:49:33 +02:00
} ;
document . keydownImageUtilitiesZoomListener = event2 => {
if ( ! document . contains ( e . node ) ) this . cleanupListeners ( "Zoom" ) ;
else if ( ! firedEvents . includes ( "Zoom" ) ) {
firedEvents . push ( "Zoom" ) ;
if ( event2 . keyCode == 187 && ( zoomSettings . zoomlevel + 0.5 ) <= this . defaults . zoomSettings . zoomlevel . maxValue ) {
zoomSettings . zoomlevel += 0.5 ;
2020-11-29 20:18:28 +01:00
lens . update ( ) ;
2020-09-19 20:49:33 +02:00
}
else if ( event2 . keyCode == 189 && ( zoomSettings . zoomlevel - 0.5 ) >= this . defaults . zoomSettings . zoomlevel . minValue ) {
zoomSettings . zoomlevel -= 0.5 ;
2020-11-29 20:18:28 +01:00
lens . update ( ) ;
2020-09-19 20:49:33 +02:00
}
2020-08-15 10:38:15 +02:00
}
2020-09-19 20:49:33 +02:00
} ;
document . keyupImageUtilitiesZoomListener = _ => {
BDFDB . ArrayUtils . remove ( firedEvents , "Zoom" , true ) ;
if ( ! document . contains ( e . node ) ) this . cleanupListeners ( "Zoom" ) ;
} ;
document . addEventListener ( "wheel" , document . wheelImageUtilitiesZoomListener ) ;
document . addEventListener ( "keydown" , document . keydownImageUtilitiesZoomListener ) ;
document . addEventListener ( "keyup" , document . keyupImageUtilitiesZoomListener ) ;
document . removeImageUtilitiesZoomObserver = new MutationObserver ( changes => changes . forEach ( change => {
let nodes = Array . from ( change . removedNodes ) ;
if ( nodes . indexOf ( appMount ) > - 1 || nodes . some ( n => n . contains ( appMount ) ) || nodes . indexOf ( e . node ) > - 1 || nodes . some ( n => n . contains ( e . node ) ) ) {
releasing ( ) ;
2020-08-15 10:38:15 +02:00
}
2020-09-19 20:49:33 +02:00
} ) ) ;
2020-11-19 16:51:14 +01:00
document . removeImageUtilitiesZoomObserver . observe ( document . body , { subtree : true , childList : true } ) ;
2020-09-19 20:49:33 +02:00
} ) ;
}
}
else if ( e . returnvalue ) {
2020-11-19 16:45:36 +01:00
if ( settings . showOnHover && e . instance . props . original && e . instance . props . src . indexOf ( "https://media.discordapp.net/attachments" ) == 0 && typeof e . returnvalue . props . children == "function" ) {
2020-11-19 16:51:14 +01:00
let attachment = BDFDB . ReactUtils . findValue ( e . instance , "attachment" , { up : true } ) ;
2020-09-19 20:49:33 +02:00
if ( attachment ) {
let renderChildren = e . returnvalue . props . children ;
e . returnvalue . props . children = ( ... args ) => {
return BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . TooltipContainer , {
text : ` ${ attachment . filename } \n ${ BDFDB . NumberUtils . formatBytes ( attachment . size ) } \n ${ attachment . width } x ${ attachment . height } px ` ,
tooltipConfig : {
type : "right" ,
delay : amounts . hoverDelay
} ,
children : renderChildren ( ... args )
} ) ;
} ;
}
}
}
2020-10-16 19:47:23 +02:00
else {
2020-11-26 09:53:49 +01:00
if ( settings . resizeImage && e . instance . props . className && e . instance . props . className . indexOf ( BDFDB . disCN . imagemodalimage ) > - 1 && BDFDB . ReactUtils . findOwner ( BDFDB . ObjectUtils . get ( e , ` instance. ${ BDFDB . ReactUtils . instanceKey } ` ) , { name : "ImageModal" , up : true } ) ) {
2020-10-16 19:47:23 +02:00
let data = settings . enableGallery ? this . getSiblingsAndPosition ( e . instance . props . src , this . getMessageGroupOfImage ( e . instance . props . src ) ) : { } ;
let aRects = BDFDB . DOMUtils . getRects ( document . querySelector ( BDFDB . dotCN . appmount ) ) ;
let ratio = Math . min ( ( aRects . width * ( data . previous || data . next ? 0.8 : 1 ) - 20 ) / e . instance . props . width , ( aRects . height - ( settings . addDetails ? 310 : 100 ) ) / e . instance . props . height ) ;
let width = Math . round ( ratio * e . instance . props . width ) ;
let height = Math . round ( ratio * e . instance . props . height ) ;
e . instance . props . width = width ;
e . instance . props . maxWidth = width ;
e . instance . props . height = height ;
e . instance . props . maxHeight = height ;
e . instance . props . src = e . instance . props . src . replace ( /width=\d+/ , ` width= ${ width } ` ) . replace ( /height=\d+/ , ` height= ${ height } ` ) ;
2020-11-17 18:46:57 +01:00
e . instance . props . resized = true ;
2020-10-16 19:47:23 +02:00
}
}
2020-09-19 20:49:33 +02:00
}
injectImageDetails ( props , child ) {
if ( settings . showAsHeader ) {
props . detailsAdded = true ;
return BDFDB . ReactUtils . createElement ( "div" , {
className : BDFDB . disCN . embedwrapper ,
children : [
BDFDB . ReactUtils . createElement ( ImageDetails , {
original : props . original ,
attachment : {
height : 0 ,
width : 0 ,
filename : "unknown.png"
2020-08-15 10:38:15 +02:00
}
2020-09-19 20:49:33 +02:00
} ) ,
child
]
2020-08-14 15:26:54 +02:00
} ) ;
}
2020-09-19 20:49:33 +02:00
return child ;
2020-08-14 15:26:54 +02:00
}
2020-09-19 20:49:33 +02:00
isValidImg ( url ) {
const file = url && ( BDFDB . LibraryModules . URLParser . parse ( url ) . pathname || "" ) . toLowerCase ( ) ;
2020-11-19 16:45:36 +01:00
return file && ( url . startsWith ( "https://images-ext-2.discordapp.net/" ) || file . endsWith ( ".jpg" ) || file . endsWith ( ".jpeg" ) || file . endsWith ( ".png" ) || file . endsWith ( ".gif" ) || file . endsWith ( ".apng" ) || file . endsWith ( ".webp" ) || file . endsWith ( ".svg" ) ) ;
2020-08-14 15:26:54 +02:00
}
2020-09-19 20:49:33 +02:00
isCopyable ( url ) {
const file = url && ( BDFDB . LibraryModules . URLParser . parse ( url ) . pathname || "" ) . toLowerCase ( ) ;
2020-11-19 16:45:36 +01:00
return file && ( url . startsWith ( "https://images-ext-2.discordapp.net/" ) || file . endsWith ( ".jpg" ) || file . endsWith ( ".jpeg" ) || file . endsWith ( ".png" ) ) ;
2020-09-19 20:49:33 +02:00
}
isSearchable ( url ) {
const file = url && ( BDFDB . LibraryModules . URLParser . parse ( url ) . pathname || "" ) . toLowerCase ( ) ;
2020-11-19 16:45:36 +01:00
return file && ( url . startsWith ( "https://images-ext-2.discordapp.net/" ) || file . endsWith ( ".jpg" ) || file . endsWith ( ".jpeg" ) || file . endsWith ( ".png" ) || file . endsWith ( ".gif" ) || file . endsWith ( ".apng" ) || file . endsWith ( ".webp" ) ) ;
2020-09-19 20:49:33 +02:00
}
2020-12-15 15:03:09 +01:00
downloadImage ( url , path ) {
url = url . startsWith ( "/assets" ) ? ( window . location . origin + url ) : url ;
BDFDB . LibraryRequires . request ( url , { encoding : null } , ( error , response , body ) => {
if ( error ) BDFDB . NotificationUtils . toast ( this . labels . toast _saveimage _failed . replace ( "{{path}}" , path ) , { type : "error" } ) ;
else {
BDFDB . LibraryRequires . fs . writeFile ( this . getFileName ( path , url . split ( "/" ) . pop ( ) . split ( "." ) . slice ( 0 , - 1 ) . join ( "." ) , response . headers [ "content-type" ] . split ( "/" ) . pop ( ) . split ( "+" ) [ 0 ] , 0 ) , body , error => {
if ( error ) BDFDB . NotificationUtils . toast ( this . labels . toast _saveimage _failed . replace ( "{{path}}" , path ) , { type : "error" } ) ;
else BDFDB . NotificationUtils . toast ( this . labels . toast _saveimage _success . replace ( "{{path}}" , path ) , { type : "success" } ) ;
} ) ;
}
} ) ;
}
downloadImageAs ( url ) {
url = url . startsWith ( "/assets" ) ? ( window . location . origin + url ) : url ;
2020-09-19 20:49:33 +02:00
BDFDB . LibraryRequires . request ( url , { encoding : null } , ( error , response , body ) => {
let hrefURL = window . URL . createObjectURL ( new Blob ( [ body ] ) ) ;
let tempLink = document . createElement ( "a" ) ;
tempLink . href = hrefURL ;
tempLink . download = ` ${ url . split ( "/" ) . pop ( ) . split ( "." ) . slice ( 0 , - 1 ) . join ( "." ) } . ${ response . headers [ "content-type" ] . split ( "/" ) . pop ( ) . split ( "+" ) [ 0 ] } ` ;
tempLink . click ( ) ;
window . URL . revokeObjectURL ( hrefURL ) ;
2020-08-14 14:37:10 +02:00
} ) ;
}
2020-09-19 20:49:33 +02:00
copyImage ( url ) {
BDFDB . LibraryRequires . request ( url , { encoding : null } , ( error , response , buffer ) => {
if ( error ) BDFDB . NotificationUtils . toast ( this . labels . toast _copyimage _failed , { type : "error" } ) ;
else if ( buffer ) {
if ( BDFDB . LibraryRequires . process . platform === "win32" || BDFDB . LibraryRequires . process . platform === "darwin" ) {
BDFDB . LibraryRequires . electron . clipboard . write ( { image : BDFDB . LibraryRequires . electron . nativeImage . createFromBuffer ( buffer ) } ) ;
}
else {
let file = BDFDB . LibraryRequires . path . join ( BDFDB . LibraryRequires . process . env . HOME , "imageutilstempimg.png" ) ;
BDFDB . LibraryRequires . fs . writeFileSync ( file , buffer , { encoding : null } ) ;
BDFDB . LibraryRequires . electron . clipboard . write ( { image : file } ) ;
BDFDB . LibraryRequires . fs . unlinkSync ( file ) ;
}
BDFDB . NotificationUtils . toast ( this . labels . toast _copyimage _success , { type : "success" } ) ;
2020-08-14 14:37:10 +02:00
}
2020-09-19 20:49:33 +02:00
} ) ;
}
2021-01-06 12:38:36 +01:00
getDownloadLocation ( ) {
2020-12-15 15:03:09 +01:00
if ( downloadsFolder && BDFDB . LibraryRequires . fs . existsSync ( downloadsFolder ) ) return downloadsFolder ;
2020-09-19 20:49:33 +02:00
let homePath = BDFDB . LibraryRequires . process . env . USERPROFILE || BDFDB . LibraryRequires . process . env . HOMEPATH || BDFDB . LibraryRequires . process . env . HOME ;
let downloadPath = homePath && BDFDB . LibraryRequires . path . join ( homePath , "Downloads" ) ;
2020-12-15 15:03:09 +01:00
if ( downloadPath && BDFDB . LibraryRequires . fs . existsSync ( downloadPath ) ) return downloadsFolder = downloadPath ;
return downloadsFolder = BDFDB . BDUtils . getPluginsFolder ( ) ;
2020-09-19 20:49:33 +02:00
}
getFileName ( path , fileName , extension , i ) {
let wholePath = BDFDB . LibraryRequires . path . join ( path , i ? ` ${ fileName } ( ${ i } ). ${ extension } ` : ` ${ fileName } . ${ extension } ` ) ;
if ( BDFDB . LibraryRequires . fs . existsSync ( wholePath ) ) return this . getFileName ( path , fileName , extension , i + 1 ) ;
else return wholePath ;
}
2020-08-14 14:37:10 +02:00
2020-09-19 20:49:33 +02:00
getMessageGroupOfImage ( src ) {
if ( src && settings . enableGallery ) for ( let message of document . querySelectorAll ( BDFDB . dotCN . message ) ) for ( let img of message . querySelectorAll ( BDFDB . dotCNS . imagewrapper + "img" ) ) if ( this . isSameImage ( src , img ) ) {
let previousSiblings = [ ] , nextSiblings = [ ] ;
let previousSibling = message . previousSibling , nextSibling = message . nextSibling ;
if ( ! BDFDB . DOMUtils . containsClass ( message , BDFDB . disCN . messagegroupstart ) ) while ( previousSibling ) {
previousSiblings . push ( previousSibling ) ;
if ( BDFDB . DOMUtils . containsClass ( previousSibling , BDFDB . disCN . messagegroupstart ) ) previousSibling = null ;
else previousSibling = previousSibling . previousSibling ;
}
while ( nextSibling ) {
if ( ! BDFDB . DOMUtils . containsClass ( nextSibling , BDFDB . disCN . messagegroupstart ) ) {
nextSiblings . push ( nextSibling ) ;
nextSibling = nextSibling . nextSibling ;
}
else nextSibling = null ;
2020-08-14 14:37:10 +02:00
}
2020-09-19 20:49:33 +02:00
return [ ] . concat ( previousSiblings . reverse ( ) , message , nextSiblings ) . filter ( n => n && BDFDB . DOMUtils . containsClass ( n , BDFDB . disCN . message ) ) ;
2020-08-14 14:37:10 +02:00
}
2020-09-19 20:49:33 +02:00
return [ ] ;
}
2020-10-16 19:47:23 +02:00
getSiblingsAndPosition ( url , messages ) {
let images = messages . map ( n => Array . from ( n . querySelectorAll ( BDFDB . dotCNS . imagewrapper + "img" ) ) ) . flat ( ) . filter ( img => ! BDFDB . DOMUtils . getParent ( BDFDB . dotCN . spoilerhidden , img ) ) ;
let next , previous , index = 0 , amount = images . length ;
for ( let i = 0 ; i < amount ; i ++ ) if ( this . isSameImage ( url , images [ i ] ) ) {
index = i ;
previous = images [ i - 1 ] ;
next = images [ i + 1 ] ;
break ;
}
return { next , previous , index , amount } ;
}
2020-09-19 20:49:33 +02:00
isSameImage ( src , img ) {
return img . src && ( Node . prototype . isPrototypeOf ( src ) && img == src || ! Node . prototype . isPrototypeOf ( src ) && this . getImageSrc ( img ) == this . getImageSrc ( src ) ) ;
2020-08-14 14:37:10 +02:00
}
2020-09-19 20:49:33 +02:00
getImageSrc ( img ) {
if ( ! img ) return null ;
return ( typeof img == "string" ? img : ( img . src || ( img . querySelector ( "canvas" ) ? img . querySelector ( "canvas" ) . src : "" ) ) ) . split ( "?width=" ) [ 0 ] ;
}
createImageWrapper ( instance , imgRef , type , svgIcon ) {
return BDFDB . ReactUtils . createElement ( "div" , {
className : BDFDB . disCNS . _imageutilitiessibling + BDFDB . disCN [ ` _imageutilities ${ type } ` ] ,
onClick : _ => { this . switchImages ( instance , type ) ; } ,
children : [
imgRef ,
BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . SvgIcon , {
className : BDFDB . disCNS . _imageutilitiesswitchicon + BDFDB . disCN . svgicon ,
name : svgIcon
} )
]
2020-08-14 14:37:10 +02:00
} ) ;
2020-09-19 20:49:33 +02:00
}
loadImage ( instance , img , type ) {
let imageThrowaway = document . createElement ( "img" ) ;
let src = this . getImageSrc ( img ) ;
imageThrowaway . src = src ;
imageThrowaway . onload = _ => {
let arects = BDFDB . DOMUtils . getRects ( document . querySelector ( BDFDB . dotCN . appmount ) ) ;
let resizeY = ( arects . height / imageThrowaway . naturalHeight ) * 0.65 , resizeX = ( arects . width / imageThrowaway . naturalWidth ) * 0.8 ;
let resize = resizeX < resizeY ? resizeX : resizeY ;
let newHeight = imageThrowaway . naturalHeight * resize ;
let newWidth = imageThrowaway . naturalWidth * resize ;
instance [ type + "Img" ] = img ;
instance [ type + "Ref" ] = BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . LazyImage , {
src : src ,
height : imageThrowaway . naturalHeight ,
width : imageThrowaway . naturalWidth ,
maxHeight : newHeight ,
maxWidth : newWidth ,
} ) ;
BDFDB . ReactUtils . forceUpdate ( instance ) ;
} ;
}
switchImages ( instance , type ) {
let img = instance [ type + "Img" ] ;
let imgRef = instance [ type + "Ref" ] ;
if ( ! img || ! imgRef ) return ;
delete instance . previousRef ;
delete instance . nextRef ;
delete instance . previousImg ;
delete instance . nextImg ;
instance . props . original = imgRef . props . src ;
instance . props . placeholder = imgRef . props . src ;
instance . props . src = imgRef . props . src ;
instance . props . height = imgRef . props . height ;
instance . props . width = imgRef . props . width ;
instance . props . cachedImage = img ;
2020-08-14 14:37:10 +02:00
BDFDB . ReactUtils . forceUpdate ( instance ) ;
2020-08-15 10:38:15 +02:00
}
2020-08-14 14:37:10 +02:00
2020-09-19 20:49:33 +02:00
cleanupListeners ( type ) {
if ( ! type ) return ;
for ( let eventType of [ "wheel" , "keydown" , "keyup" ] ) {
document . removeEventListener ( "wheel" , document [ ` ${ eventType } ImageUtilities ${ type } Listener ` ] ) ;
delete document [ ` ${ eventType } ImageUtilities ${ type } Listener ` ] ;
}
2020-08-14 14:37:10 +02:00
}
2021-01-06 12:38:36 +01:00
setLabelsByLanguage ( ) {
2020-09-19 20:49:33 +02:00
switch ( BDFDB . LanguageUtils . getLanguage ( ) . id ) {
2020-12-21 19:56:36 +01:00
case "bg" : // Bulgarian
2020-09-19 20:49:33 +02:00
return {
2020-12-21 19:56:36 +01:00
context _copyimage : "Копирай изображение" ,
context _copyimagelink : "Копирайте Image Link" ,
context _lenssize : "Размер на обектива" ,
context _reverseimagesearch : "Търсене на изображение с ..." ,
context _saveimageas : "Запазете изображението като ..." ,
context _viewimage : "Преглед на изображението" ,
submenu _disabled : "Всички инвалиди" ,
toast _copyimage _failed : "Копирането на изображението в клипборда не б е успешно" ,
toast _copyimage _success : "Копирано изображение в клипборда" ,
toast _copyimagelink _success : "Копирана връзка към изображение в клипборда" ,
2020-12-21 20:30:41 +01:00
toast _saveimage _failed : "Запазването на изображението в '{{path}}' не б е успешно" ,
toast _saveimage _success : "Запазено изображение в '{{path}}'"
2020-09-19 20:49:33 +02:00
} ;
2020-12-21 19:56:36 +01:00
case "da" : // Danish
2020-09-19 20:49:33 +02:00
return {
2020-12-21 19:56:36 +01:00
context _copyimage : "Kopier billede" ,
context _copyimagelink : "Kopier billedlink" ,
context _lenssize : "Objektivstørrelse" ,
context _reverseimagesearch : "Søg i billede med ..." ,
context _saveimageas : "Gem billede som ..." ,
context _viewimage : "Se billede" ,
submenu _disabled : "Alle handicappede" ,
2020-09-19 20:49:33 +02:00
toast _copyimage _failed : "Kunne ikke kopiere billedet til udklipsholderen" ,
2020-12-21 19:56:36 +01:00
toast _copyimage _success : "Kopieret billede til udklipsholderen" ,
2020-09-19 20:49:33 +02:00
toast _copyimagelink _success : "Kopieret billedlink til udklipsholder" ,
toast _saveimage _failed : "Kunne ikke gemme billedet i '{{path}}'" ,
2020-12-21 19:56:36 +01:00
toast _saveimage _success : "Gemt billede i '{{path}}'"
2020-09-19 20:49:33 +02:00
} ;
2020-12-21 19:56:36 +01:00
case "de" : // German
2020-09-19 20:49:33 +02:00
return {
2020-12-21 19:56:36 +01:00
context _copyimage : "Bild kopieren" ,
context _copyimagelink : "Bildadresse kopieren" ,
context _lenssize : "Linsengröße" ,
context _reverseimagesearch : "Bild suchen mit ..." ,
context _saveimageas : "Bild speichern unter ..." ,
context _viewimage : "Bild ansehen" ,
submenu _disabled : "Alle deaktiviert" ,
2020-09-19 20:49:33 +02:00
toast _copyimage _failed : "Bild konnte nicht in die Zwischenablage kopiert werden" ,
2020-12-21 19:56:36 +01:00
toast _copyimage _success : "Kopiertes Bild in die Zwischenablage" ,
toast _copyimagelink _success : "Bildadresse in die Zwischenablage kopieren" ,
2020-09-19 20:49:33 +02:00
toast _saveimage _failed : "Bild konnte nicht in '{{path}}' gespeichert werden" ,
2020-12-21 19:56:36 +01:00
toast _saveimage _success : "Bild wurde in '{{path}}' gespeichert"
2020-09-19 20:49:33 +02:00
} ;
2020-12-21 19:56:36 +01:00
case "el" : // Greek
2020-09-19 20:49:33 +02:00
return {
2020-12-21 19:56:36 +01:00
context _copyimage : "Αντιγραφή εικόνας" ,
context _copyimagelink : "Αντιγραφή συνδέσμου εικόνας" ,
context _lenssize : "Μέγεθος φακού" ,
context _reverseimagesearch : "Αναζήτηση εικόνας με ..." ,
context _saveimageas : "Αποθήκευση εικόνας ως ..." ,
context _viewimage : "Προβολή εικόνας" ,
submenu _disabled : "Όλα τα άτομα με ειδικές ανάγκες" ,
toast _copyimage _failed : "Αποτυχία αντιγραφής εικόνας στο Πρόχειρο" ,
toast _copyimage _success : "Αντιγράφηκε η εικόνα στο Πρόχειρο" ,
toast _copyimagelink _success : "Αντιγράφηκε σύνδεσμος εικόνας στο Πρόχειρο" ,
2020-12-21 20:30:41 +01:00
toast _saveimage _failed : "Αποτυχία αποθήκευσης εικόνας στο '{{path}}'" ,
toast _saveimage _success : "Αποθηκευμένη εικόνα στο '{{path}}'"
2020-12-21 19:56:36 +01:00
} ;
case "es" : // Spanish
return {
context _copyimage : "Copiar imagen" ,
context _copyimagelink : "Copiar enlace de imagen" ,
context _lenssize : "Tamaño de la lente" ,
context _reverseimagesearch : "Buscar imagen con ..." ,
context _saveimageas : "Guardar imagen como ..." ,
context _viewimage : "Ver imagen" ,
submenu _disabled : "Todos discapacitados" ,
2020-09-19 20:49:33 +02:00
toast _copyimage _failed : "No se pudo copiar la imagen al portapapeles" ,
2020-12-21 19:56:36 +01:00
toast _copyimage _success : "Imagen copiada al portapapeles" ,
2020-09-19 20:49:33 +02:00
toast _copyimagelink _success : "Enlace de imagen copiado al portapapeles" ,
2020-12-21 20:30:41 +01:00
toast _saveimage _failed : "No se pudo guardar la imagen en '{{path}}'" ,
toast _saveimage _success : "Imagen guardada en '{{path}}'"
2020-09-19 20:49:33 +02:00
} ;
2020-12-21 19:56:36 +01:00
case "fi" : // Finnish
2020-09-19 20:49:33 +02:00
return {
2020-12-21 19:56:36 +01:00
context _copyimage : "Kopioi kuva" ,
context _copyimagelink : "Kopioi kuvalinkki" ,
context _lenssize : "Linssin koko" ,
context _reverseimagesearch : "Hae kuvaa ..." ,
context _saveimageas : "Tallenna kuva nimellä ..." ,
context _viewimage : "Näytä kuva" ,
submenu _disabled : "Kaikki vammaiset" ,
toast _copyimage _failed : "Kuvan kopioiminen leikepöydälle epäonnistui" ,
toast _copyimage _success : "Kopioitu kuva leikepöydälle" ,
toast _copyimagelink _success : "Kopioitu kuvalinkki leikepöydälle" ,
2020-12-21 20:30:41 +01:00
toast _saveimage _failed : "Kuvan tallentaminen kohteeseen '{{path}}' epäonnistui" ,
toast _saveimage _success : "Tallennettu kuva kansioon '{{path}}'"
2020-12-21 19:56:36 +01:00
} ;
case "fr" : // French
return {
context _copyimage : "Copier l'image" ,
context _copyimagelink : "Copier le lien de l'image" ,
context _lenssize : "Taille de l'objectif" ,
context _reverseimagesearch : "Rechercher une image avec ..." ,
context _saveimageas : "Enregistrer l'image sous ..." ,
context _viewimage : "Voir l'image" ,
submenu _disabled : "Tout désactivé" ,
2020-09-19 20:49:33 +02:00
toast _copyimage _failed : "Échec de la copie de l'image dans le presse-papiers" ,
2020-12-21 19:56:36 +01:00
toast _copyimage _success : "Image copiée dans le presse-papiers" ,
toast _copyimagelink _success : "Lien d'image copié vers le presse-papiers" ,
2020-12-21 20:30:41 +01:00
toast _saveimage _failed : "Échec de l'enregistrement de l'image dans '{{path}}'" ,
toast _saveimage _success : "Image enregistrée dans '{{path}}'"
2020-12-21 19:56:36 +01:00
} ;
case "hr" : // Croatian
return {
context _copyimage : "Kopiraj sliku" ,
context _copyimagelink : "Kopiraj vezu slike" ,
context _lenssize : "Veličina leće" ,
context _reverseimagesearch : "Traži sliku pomoću ..." ,
context _saveimageas : "Spremi sliku kao ..." ,
context _viewimage : "Pogledati sliku" ,
submenu _disabled : "Svi invalidi" ,
toast _copyimage _failed : "Kopiranje slike u međuspremnik nije uspjelo" ,
toast _copyimage _success : "Kopirana slika u međuspremnik" ,
toast _copyimagelink _success : "Veza slike kopirana je u međuspremnik" ,
2020-12-21 20:30:41 +01:00
toast _saveimage _failed : "Spremanje slike u '{{path}}' nije uspjelo" ,
toast _saveimage _success : "Spremljena slika na '{{path}}'"
2020-12-21 19:56:36 +01:00
} ;
case "hu" : // Hungarian
return {
context _copyimage : "Képmásolat" ,
context _copyimagelink : "Képlink másolása" ,
context _lenssize : "Lencse mérete" ,
context _reverseimagesearch : "Kép keresése a következővel:" ,
context _saveimageas : "Kép mentése másként ..." ,
context _viewimage : "Kép megtekintése" ,
submenu _disabled : "Minden fogyatékkal él" ,
toast _copyimage _failed : "Nem sikerült másolni a képet a vágólapra" ,
toast _copyimage _success : "Kép másolása a vágólapra" ,
toast _copyimagelink _success : "Képlink linkre másolva a vágólapra" ,
2020-12-21 20:30:41 +01:00
toast _saveimage _failed : "Nem sikerült menteni a képet a (z) '{{path}}” mappába" ,
toast _saveimage _success : "Mentett kép itt: '{{path}}”"
2020-12-21 19:56:36 +01:00
} ;
case "it" : // Italian
return {
context _copyimage : "Copia l'immagine" ,
context _copyimagelink : "Copia link immagine" ,
context _lenssize : "Dimensione della lente" ,
context _reverseimagesearch : "Cerca immagine con ..." ,
context _saveimageas : "Salva l'immagine come ..." ,
context _viewimage : "Guarda l'immagine" ,
submenu _disabled : "Tutti disabilitati" ,
toast _copyimage _failed : "Impossibile copiare l'immagine negli Appunti" ,
toast _copyimage _success : "Immagine copiata negli Appunti" ,
toast _copyimagelink _success : "Collegamento immagine copiato negli Appunti" ,
2020-12-21 20:30:41 +01:00
toast _saveimage _failed : "Impossibile salvare l'immagine in '{{path}}'" ,
toast _saveimage _success : "Immagine salvata in '{{path}}'"
2020-12-21 19:56:36 +01:00
} ;
case "ja" : // Japanese
return {
context _copyimage : "画像をコピーする" ,
context _copyimagelink : "画像リンクをコピー" ,
context _lenssize : "レンズサイズ" ,
context _reverseimagesearch : "で画像を検索..." ,
context _saveimageas : "画像を保存します ..." ,
context _viewimage : "画像を見る" ,
submenu _disabled : "すべて無効" ,
toast _copyimage _failed : "画像をクリップボードにコピーできませんでした" ,
toast _copyimage _success : "画像をクリップボードにコピー" ,
toast _copyimagelink _success : "クリップボードへのコピーされた画像リンク" ,
toast _saveimage _failed : "'{{path}}'に画像を保存できませんでした" ,
toast _saveimage _success : "'{{path}}'に保存された画像"
} ;
case "ko" : // Korean
return {
context _copyimage : "복사 이미지" ,
context _copyimagelink : "이미지 링크 복사" ,
context _lenssize : "렌즈 크기" ,
context _reverseimagesearch : "이미지 검색 ..." ,
context _saveimageas : "다른 이름으로 이미지 저장 ..." ,
context _viewimage : "이미지보기" ,
submenu _disabled : "모두 비활성화 됨" ,
toast _copyimage _failed : "이미지를 클립 보드로 복사하지 못했습니다." ,
toast _copyimage _success : "클립 보드에 복사 된 이미지" ,
toast _copyimagelink _success : "클립 보드에 복사 된 이미지 링크" ,
toast _saveimage _failed : "'{{path}}'에 이미지를 저장하지 못했습니다." ,
toast _saveimage _success : "'{{path}}'에 저장된 이미지"
2020-09-19 20:49:33 +02:00
} ;
2020-12-21 19:56:36 +01:00
case "lt" : // Lithuanian
2020-09-19 20:49:33 +02:00
return {
2020-12-21 19:56:36 +01:00
context _copyimage : "Kopijuoti paveiksliuką" ,
context _copyimagelink : "Kopijuoti vaizdo nuorodą" ,
context _lenssize : "Objektyvo dydis" ,
context _reverseimagesearch : "Ieškoti vaizde su ..." ,
context _saveimageas : "Išsaugoti paveikslėlį kaip ..." ,
context _viewimage : "Peržiūrėti Nuotrauka" ,
submenu _disabled : "Visi neįgalūs" ,
toast _copyimage _failed : "Nepavyko nukopijuoti vaizdo į iškarpinę" ,
toast _copyimage _success : "Nukopijuotas vaizdas į mainų sritį" ,
toast _copyimagelink _success : "Nukopijuota vaizdo nuoroda į iškarpinę" ,
2020-12-21 20:30:41 +01:00
toast _saveimage _failed : "Nepavyko išsaugoti vaizdo '{{path}}'" ,
toast _saveimage _success : "Išsaugotas vaizdas '{{path}}'"
2020-09-19 20:49:33 +02:00
} ;
2020-12-21 19:56:36 +01:00
case "nl" : // Dutch
2020-09-19 20:49:33 +02:00
return {
2020-12-21 19:56:36 +01:00
context _copyimage : "Kopieer afbeelding" ,
context _copyimagelink : "Kopieer afbeeldingslink" ,
context _lenssize : "Lens Maat" ,
context _reverseimagesearch : "Zoek afbeelding met ..." ,
context _saveimageas : "Sla afbeelding op als ..." ,
context _viewimage : "Bekijk afbeelding" ,
submenu _disabled : "Allemaal uitgeschakeld" ,
toast _copyimage _failed : "Het kopiëren van de afbeelding naar het klembord is mislukt" ,
2020-09-19 20:49:33 +02:00
toast _copyimage _success : "Gekopieerde afbeelding naar klembord" ,
2020-12-21 19:56:36 +01:00
toast _copyimagelink _success : "Gekopieerde afbeeldingslink naar het klembord" ,
2020-09-19 20:49:33 +02:00
toast _saveimage _failed : "Kan afbeelding niet opslaan in '{{path}}'" ,
2020-12-21 19:56:36 +01:00
toast _saveimage _success : "Opgeslagen afbeelding in '{{path}}'"
2020-09-19 20:49:33 +02:00
} ;
2020-12-21 19:56:36 +01:00
case "no" : // Norwegian
2020-09-19 20:49:33 +02:00
return {
2020-12-21 19:56:36 +01:00
context _copyimage : "Kopier bilde" ,
context _copyimagelink : "Kopier bildelink" ,
context _lenssize : "Linsestørrelse" ,
context _reverseimagesearch : "Søk i bilde med ..." ,
context _saveimageas : "Lagre bildet som ..." ,
context _viewimage : "Vis bilde" ,
submenu _disabled : "Alle funksjonshemmede" ,
2020-09-19 20:49:33 +02:00
toast _copyimage _failed : "Kunne ikke kopiere bildet til utklippstavlen" ,
2020-12-21 19:56:36 +01:00
toast _copyimage _success : "Kopiert bilde til utklippstavlen" ,
toast _copyimagelink _success : "Kopiert bildekobling til utklippstavlen" ,
2020-09-19 20:49:33 +02:00
toast _saveimage _failed : "Kunne ikke lagre bildet i '{{path}}'" ,
2020-12-21 19:56:36 +01:00
toast _saveimage _success : "Lagret bilde i '{{path}}'"
2020-09-19 20:49:33 +02:00
} ;
2020-12-21 19:56:36 +01:00
case "pl" : // Polish
2020-09-19 20:49:33 +02:00
return {
2020-12-21 19:56:36 +01:00
context _copyimage : "Skopiuj obraz" ,
context _copyimagelink : "Kopiuj łącze do obrazu" ,
context _lenssize : "Rozmiar soczewki" ,
context _reverseimagesearch : "Szukaj obrazu za pomocą ..." ,
context _saveimageas : "Zapisz obraz jako ..." ,
context _viewimage : "Zobacz obrazek" ,
submenu _disabled : "Wszystkie wyłączone" ,
2020-09-19 20:49:33 +02:00
toast _copyimage _failed : "Nie udało się skopiować obrazu do schowka" ,
2020-12-21 19:56:36 +01:00
toast _copyimage _success : "Skopiowany obraz do schowka" ,
2020-09-19 20:49:33 +02:00
toast _copyimagelink _success : "Link do skopiowanego obrazu do schowka" ,
2020-12-21 20:30:41 +01:00
toast _saveimage _failed : "Nie udało się zapisać obrazu w '{{path}}”" ,
toast _saveimage _success : "Zapisany obraz w '{{path}}”"
2020-09-19 20:49:33 +02:00
} ;
2020-12-21 19:56:36 +01:00
case "pt-BR" : // Portuguese (Brazil)
2020-09-19 20:49:33 +02:00
return {
2020-12-21 19:56:36 +01:00
context _copyimage : "Copiar imagem" ,
context _copyimagelink : "Copiar link da imagem" ,
context _lenssize : "Tamanho da lente" ,
context _reverseimagesearch : "Pesquisar imagem com ..." ,
context _saveimageas : "Salvar imagem como ..." ,
context _viewimage : "Ver imagem" ,
submenu _disabled : "Todos desativados" ,
toast _copyimage _failed : "Falha ao copiar a imagem para a área de transferência" ,
2020-09-19 20:49:33 +02:00
toast _copyimage _success : "Imagem copiada para a área de transferência" ,
toast _copyimagelink _success : "Link da imagem copiada para a área de transferência" ,
2020-12-21 19:56:36 +01:00
toast _saveimage _failed : "Falha ao salvar a imagem em '{{path}}'" ,
toast _saveimage _success : "Imagem salva em '{{path}}'"
2020-09-19 20:49:33 +02:00
} ;
2020-12-21 19:56:36 +01:00
case "ro" : // Romanian
2020-09-19 20:49:33 +02:00
return {
2020-12-21 19:56:36 +01:00
context _copyimage : "Copiază imaginea" ,
context _copyimagelink : "Copiați linkul de imagine" ,
context _lenssize : "Dimensiunea obiectivului" ,
context _reverseimagesearch : "Căutați imaginea cu ..." ,
context _saveimageas : "Salveaza imaginea ca ..." ,
context _viewimage : "Vezi imaginea" ,
submenu _disabled : "Toate sunt dezactivate" ,
toast _copyimage _failed : "Copierea imaginii în clipboard nu a reușit" ,
toast _copyimage _success : "Copiat imaginea în Clipboard" ,
toast _copyimagelink _success : "Link copiat pentru imagine în Clipboard" ,
2020-12-21 20:30:41 +01:00
toast _saveimage _failed : "Salvarea imaginii în '{{path}}” nu a reușit" ,
toast _saveimage _success : "Imagine salvată în '{{path}}”"
2020-09-19 20:49:33 +02:00
} ;
2020-12-21 19:56:36 +01:00
case "ru" : // Russian
2020-09-19 20:49:33 +02:00
return {
2020-12-21 19:56:36 +01:00
context _copyimage : "Копировать изображение" ,
context _copyimagelink : "Копировать ссылку на изображение" ,
context _lenssize : "Размер линзы" ,
context _reverseimagesearch : "Искать изображение с помощью ..." ,
context _saveimageas : "Сохранить изображение как ..." ,
context _viewimage : "Просмотр изображения" ,
submenu _disabled : "В с е отключены" ,
toast _copyimage _failed : "Н е удалось скопировать изображение в буфер обмена" ,
toast _copyimage _success : "Изображение скопировано в буфер обмена" ,
toast _copyimagelink _success : "Ссылка на скопированное изображение в буфер обмена" ,
toast _saveimage _failed : "Н е удалось сохранить изображение в '{{path}}'" ,
toast _saveimage _success : "Сохраненное изображение в '{{path}}'"
2020-09-19 20:49:33 +02:00
} ;
2020-12-21 19:56:36 +01:00
case "sv" : // Swedish
2020-09-19 20:49:33 +02:00
return {
2020-12-21 19:56:36 +01:00
context _copyimage : "Kopiera bild" ,
context _copyimagelink : "Kopiera bildlänk" ,
context _lenssize : "Linsstorlek" ,
context _reverseimagesearch : "Sök bild med ..." ,
context _saveimageas : "Spara bild som ..." ,
context _viewimage : "Se bild" ,
submenu _disabled : "Alla funktionshindrade" ,
toast _copyimage _failed : "Det gick inte att kopiera bilden till Urklipp" ,
toast _copyimage _success : "Kopierad bild till Urklipp" ,
toast _copyimagelink _success : "Kopierad bildlänk till Urklipp" ,
2020-12-21 20:30:41 +01:00
toast _saveimage _failed : "Det gick inte att spara bilden i '{{path}}'" ,
toast _saveimage _success : "Sparad bild i '{{path}}'"
2020-09-19 20:49:33 +02:00
} ;
2020-12-21 19:56:36 +01:00
case "th" : // Thai
2020-09-19 20:49:33 +02:00
return {
2020-12-21 19:56:36 +01:00
context _copyimage : "คัดลอกรูปภาพ" ,
context _copyimagelink : "คัดลอกลิงค์รูปภาพ" ,
context _lenssize : "ขนาดเลนส์" ,
context _reverseimagesearch : "ค้นหาภาพด้วย ..." ,
context _saveimageas : "บันทึกภาพเป็น ..." ,
context _viewimage : "ดูภาพ" ,
submenu _disabled : "ปิดใช้งานทั้งหมด" ,
toast _copyimage _failed : "คัดลอกรูปภาพไปยังคลิปบอร์ดไม่สำเร็จ" ,
toast _copyimage _success : "คัดลอกรูปภาพไปยังคลิปบอร์ดแล้ว" ,
toast _copyimagelink _success : "ลิงก์รูปภาพที่คัดลอกไปยังคลิปบอร์ด" ,
2020-12-21 20:30:41 +01:00
toast _saveimage _failed : "บันทึกภาพใน '{{path}}' ไม่สำเร็จ" ,
toast _saveimage _success : "ภาพที่บันทึกไว้ใน '{{path}}'"
2020-09-19 20:49:33 +02:00
} ;
2020-12-21 19:56:36 +01:00
case "tr" : // Turkish
2020-09-19 20:49:33 +02:00
return {
2020-12-21 19:56:36 +01:00
context _copyimage : "Resmi kopyala" ,
context _copyimagelink : "Resim Bağlantı sı nı Kopyala" ,
context _lenssize : "Lens Boyutu" ,
context _reverseimagesearch : "Şununla Resim Ara ..." ,
context _saveimageas : "Resmi farklı kaydet ..." ,
context _viewimage : "Görseli göster" ,
submenu _disabled : "Hepsi devre dı şı " ,
toast _copyimage _failed : "Görüntü Panoya kopyalanamadı " ,
toast _copyimage _success : "Görüntü panoya kopyalandı " ,
toast _copyimagelink _success : "Görüntü bağlantı sı panoya kopyalandı " ,
toast _saveimage _failed : "Resim '{{yol}}' içine kaydedilemedi" ,
toast _saveimage _success : "Resim '{{yol}}' içine kaydedildi"
2020-09-19 20:49:33 +02:00
} ;
2020-12-21 19:56:36 +01:00
case "uk" : // Ukrainian
2020-09-19 20:49:33 +02:00
return {
2020-12-21 19:56:36 +01:00
context _copyimage : "Скопіювати зображення" ,
context _copyimagelink : "Скопіювати посилання на зображення" ,
context _lenssize : "Розмір лінзи" ,
context _reverseimagesearch : "Шукати зображення за допомогою ..." ,
context _saveimageas : "Зберегти зображення як ..." ,
context _viewimage : "Переглянути зображення" ,
submenu _disabled : "В с і інваліди" ,
toast _copyimage _failed : "Н е вдалося скопіювати зображення в буфер обміну" ,
toast _copyimage _success : "Скопійовано зображення в буфер обміну" ,
toast _copyimagelink _success : "Скопійовано посилання на зображення в буфер обміну" ,
2020-12-21 20:30:41 +01:00
toast _saveimage _failed : "Н е вдалося зберегти зображення у '{{path}}'" ,
toast _saveimage _success : "Збережене зображення у '{{path}}'"
2020-09-19 20:49:33 +02:00
} ;
2020-12-21 19:56:36 +01:00
case "vi" : // Vietnamese
2020-09-19 20:49:33 +02:00
return {
2020-12-21 19:56:36 +01:00
context _copyimage : "Sao chép hình ảnh" ,
context _copyimagelink : "Sao chép liên kết hình ảnh" ,
context _lenssize : "Kích thước ống kính" ,
context _reverseimagesearch : "Tìm kiếm Hình ảnh bằng ..." ,
context _saveimageas : "Lưu ảnh dưới dạng ..." ,
context _viewimage : "Xem hình ảnh" ,
submenu _disabled : "Tất cả đã bị vô hiệu hóa" ,
toast _copyimage _failed : "Không sao chép được hình ảnh vào Clipboard" ,
toast _copyimage _success : "Đã sao chép hình ảnh vào Clipboard" ,
toast _copyimagelink _success : "Liên kết hình ảnh được sao chép vào Clipboard" ,
toast _saveimage _failed : "Không lưu được Hình ảnh trong '{{path}}'" ,
toast _saveimage _success : "Hình ảnh đã Lưu trong '{{path}}'"
2020-09-19 20:49:33 +02:00
} ;
2020-12-21 19:56:36 +01:00
case "zh" : // Chinese
2020-09-19 20:49:33 +02:00
return {
2020-12-21 19:56:36 +01:00
context _copyimage : "复制图片" ,
context _copyimagelink : "复制图像链接" ,
context _lenssize : "镜片尺寸" ,
context _reverseimagesearch : "用...搜索图像" ,
context _saveimageas : "将图像另存为..." ,
context _viewimage : "看图" ,
submenu _disabled : "全部禁用" ,
toast _copyimage _failed : "无法将图像复制到剪贴板" ,
toast _copyimage _success : "复制到剪贴板的图像" ,
toast _copyimagelink _success : "复制的图像链接到剪贴板" ,
2021-01-10 11:41:01 +01:00
toast _saveimage _failed : "无法将图片保存到'{{path}}'中" ,
toast _saveimage _success : "已将图像保存在'{{path}}'中"
2020-09-19 20:49:33 +02:00
} ;
2020-12-21 19:56:36 +01:00
case "zh-TW" : // Chinese (Traditional)
2020-09-19 20:49:33 +02:00
return {
2020-12-21 19:56:36 +01:00
context _copyimage : "複製圖片" ,
context _copyimagelink : "複製圖像鏈接" ,
context _lenssize : "鏡片尺寸" ,
context _reverseimagesearch : "用...搜索圖像" ,
context _saveimageas : "將圖像另存為..." ,
context _viewimage : "看圖" ,
submenu _disabled : "全部禁用" ,
2020-09-19 20:49:33 +02:00
toast _copyimage _failed : "無法將圖像複製到剪貼板" ,
2020-12-21 19:56:36 +01:00
toast _copyimage _success : "複製到剪貼板的圖像" ,
2020-09-19 20:49:33 +02:00
toast _copyimagelink _success : "複製的圖像鏈接到剪貼板" ,
2021-01-10 11:41:01 +01:00
toast _saveimage _failed : "無法將圖片保存到'{{path}}'中" ,
toast _saveimage _success : "已將圖像保存在'{{path}}'中"
2020-09-19 20:49:33 +02:00
} ;
2020-12-21 19:56:36 +01:00
default : // English
2020-09-19 20:49:33 +02:00
return {
2020-12-21 19:56:36 +01:00
context _copyimage : "Copy Image" ,
context _copyimagelink : "Copy Image Link" ,
context _lenssize : "Lens Size" ,
context _reverseimagesearch : "Search Image with ..." ,
context _saveimageas : "Save Image as ..." ,
context _viewimage : "View Image" ,
submenu _disabled : "All disabled" ,
toast _copyimage _failed : "Failed to copy image to Clipboard" ,
toast _copyimage _success : "Copied image to Clipboard" ,
toast _copyimagelink _success : "Copied image link to Clipboard" ,
toast _saveimage _failed : "Failed to save Image in '{{path}}'" ,
toast _saveimage _success : "Saved Image in '{{path}}'"
2020-09-19 20:49:33 +02:00
} ;
}
}
} ;
2020-10-09 21:09:35 +02:00
} ) ( window . BDFDB _Global . PluginUtils . buildPlugin ( config ) ) ;
2020-11-29 20:18:28 +01:00
} ) ( ) ;