2019-09-20 22:32:52 +02:00
//META{"name":"StalkerNotifications","website":"https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/StalkerNotifications","source":"https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/StalkerNotifications/StalkerNotifications.plugin.js"}*//
2018-10-11 10:21:26 +02:00
class StalkerNotifications {
2019-01-15 12:34:38 +01:00
getName ( ) { return "StalkerNotifications" ; }
2019-08-22 16:17:21 +02:00
getVersion ( ) { return "9.9.9" ; }
2019-01-15 12:34:38 +01:00
getAuthor ( ) { return "DevilBro" ; }
2019-08-22 16:17:21 +02:00
getDescription ( ) { return "DISCONTINUED." ; }
2019-01-26 22:45:19 +01:00
2019-09-04 12:34:02 +02:00
constructor ( ) {
2019-08-22 16:17:21 +02:00
this . changelog = {
"improved" : [ [ "Merged FriendNotifications and StalkerNotifications" , "Since both of these plugins now work the same, I decided to merge them. FriendNotifications will be continued and StalkerNotifications will be disconntinued. You can find the old StalkerNotifications settings in the FriendNotifications settings. <i style='color:rgb(200, 100, 100); font-weight: 800;'>All old configurations of FriendNotifications and StalkerNotifications should have been merged</i>" ] ]
2019-02-26 12:16:08 +01:00
} ;
2019-08-22 16:17:21 +02:00
}
2019-01-26 22:45:19 +01:00
2019-08-22 16:17:21 +02:00
//legacy
load ( ) { }
2019-01-26 22:45:19 +01:00
2019-08-22 16:17:21 +02:00
start ( ) {
if ( ! global . BDFDB ) global . BDFDB = { myPlugins : { } } ;
if ( global . BDFDB && global . BDFDB . myPlugins && typeof global . BDFDB . myPlugins == "object" ) global . BDFDB . myPlugins [ this . getName ( ) ] = this ;
var libraryScript = document . querySelector ( 'head script#BDFDBLibraryScript' ) ;
if ( ! libraryScript || ( performance . now ( ) - libraryScript . getAttribute ( "date" ) ) > 600000 ) {
if ( libraryScript ) libraryScript . remove ( ) ;
libraryScript = document . createElement ( "script" ) ;
libraryScript . setAttribute ( "id" , "BDFDBLibraryScript" ) ;
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-08-22 16:17:21 +02:00
libraryScript . setAttribute ( "date" , performance . now ( ) ) ;
libraryScript . addEventListener ( "load" , ( ) => { this . initialize ( ) ; } ) ;
document . head . appendChild ( libraryScript ) ;
this . libLoadTimeout = setTimeout ( ( ) => {
libraryScript . remove ( ) ;
2019-10-18 10:56:41 +02:00
require ( "request" ) ( "https://mwittrien.github.io/BetterDiscordAddons/Plugins/BDFDB.min.js" , ( error , response , body ) => {
2019-08-22 16:17:21 +02:00
if ( body ) {
libraryScript = document . createElement ( "script" ) ;
libraryScript . setAttribute ( "id" , "BDFDBLibraryScript" ) ;
libraryScript . setAttribute ( "type" , "text/javascript" ) ;
libraryScript . setAttribute ( "date" , performance . now ( ) ) ;
libraryScript . innerText = body ;
document . head . appendChild ( libraryScript ) ;
}
this . initialize ( ) ;
} ) ;
} , 15000 ) ;
}
else if ( global . BDFDB && typeof BDFDB === "object" && BDFDB . loaded ) this . initialize ( ) ;
this . startTimeout = setTimeout ( ( ) => { this . initialize ( ) ; } , 30000 ) ;
2018-10-11 10:21:26 +02:00
}
2019-01-26 22:45:19 +01:00
2019-08-22 16:17:21 +02:00
initialize ( ) {
if ( global . BDFDB && typeof BDFDB === "object" && BDFDB . loaded ) {
if ( this . started ) return ;
2019-10-22 18:55:25 +02:00
BDFDB . PluginUtils . init ( this ) ;
2019-08-22 16:17:21 +02:00
BDFDB . openConfirmModal ( this , "StalkerNotifications has been discontinued and was merged with FriendNotifications. To download FriendNotifications click the 'OK' button bellow. This will delete StalkerNotifications and download FriendNotifications." , "Update Notification" , ( ) => {
require ( "request" ) ( "https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/FriendNotifications/FriendNotifications.plugin.js" , ( error , response , body ) => {
2019-10-22 18:55:25 +02:00
if ( error ) BDFDB . NotificationUtils . toast ( ` Unable to download FriendNotifications.plugin.js. ` , { type : "error" } ) ;
2019-08-22 16:17:21 +02:00
else {
2019-10-23 11:10:01 +02:00
require ( "fs" ) . writeFile ( require ( "path" ) . join ( BDFDB . BDUtils . getPluginsFolder ( ) , "FriendNotifications.plugin.js" ) , body , ( error ) => {
2019-08-22 16:17:21 +02:00
if ( ! error ) {
2019-10-22 18:55:25 +02:00
BDFDB . NotificationUtils . toast ( ` Successfully downloaded FriendNotifications.plugin.js. ` , { type : "success" } ) ;
2019-10-23 11:10:01 +02:00
require ( "fs" ) . unlinkSync ( require ( "path" ) . join ( BDFDB . BDUtils . getPluginsFolder ( ) , "StalkerNotifications.plugin.js" ) ) ;
2019-08-22 16:17:21 +02:00
}
} ) ;
2018-11-23 14:37:30 +01:00
}
2019-08-22 16:17:21 +02:00
} ) ;
2018-11-23 14:37:30 +01:00
} ) ;
}
2019-10-22 18:55:25 +02:00
else console . error ( ` %c[ ${ this . getName ( ) } ]%c ` , 'color: #3a71c1; font-weight: 700;' , '' , 'Fatal Error: Could not load BD functions!' ) ;
2018-11-23 14:37:30 +01:00
}
2019-01-26 22:45:19 +01:00
2019-08-22 16:17:21 +02:00
stop ( ) {
if ( global . BDFDB && typeof BDFDB === "object" && BDFDB . loaded ) {
2019-10-22 11:37:23 +02:00
this . stopping = true ;
2019-10-22 18:55:25 +02:00
BDFDB . PluginUtils . clear ( this ) ;
2019-02-26 12:16:08 +01:00
}
}
2019-01-26 22:45:19 +01:00
2019-08-22 16:17:21 +02:00
// begin of own functions
2019-01-03 10:22:21 +01:00
}