mirror of
				https://github.com/EndPwnArchive/endpwn3.2-lambda.git
				synced 2024-08-14 23:49:56 +00:00 
			
		
		
		
	rework epapi for dependency/priority loading + plugin list plugin
This commit is contained in:
		
							parent
							
								
									048f2858e1
								
							
						
					
					
						commit
						b3829e311c
					
				
					 7 changed files with 179 additions and 17 deletions
				
			
		
							
								
								
									
										110
									
								
								plugin/plugins.js
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										110
									
								
								plugin/plugins.js
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,110 @@
 | 
			
		|||
exports = {
 | 
			
		||||
    manifest: {
 | 
			
		||||
        author: "Cynosphere",
 | 
			
		||||
        name: "Plugins Page",
 | 
			
		||||
        description: "Shows what plugins you have",
 | 
			
		||||
        loadAfter:["settings"]
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    start:function(){
 | 
			
		||||
        let em = $settingsapi.elements;
 | 
			
		||||
        let int = em.internal;
 | 
			
		||||
 | 
			
		||||
        var createPlugin = function(id,data){
 | 
			
		||||
            var info = {};
 | 
			
		||||
            info.name = data.name ? data.name : (id ? id : "<unnamed plugin???>");
 | 
			
		||||
            info.description = data.description ? data.description : "Manifest is missing for this plugin.";
 | 
			
		||||
            info.author = data.author ? data.author : "Unknown";
 | 
			
		||||
            info.loadAfter = data.loadAfter ? data.loadAfter : [];
 | 
			
		||||
            info.priority = data.priority ? data.priority : 0;
 | 
			
		||||
            info.replacements = data.replacements ? data.replacements : [];
 | 
			
		||||
 | 
			
		||||
            var cont = em.createVerticalPanel();
 | 
			
		||||
 | 
			
		||||
            var head = em.createHorizontalPanel()
 | 
			
		||||
            .appendTo(cont);
 | 
			
		||||
 | 
			
		||||
            var title = createElement("h3")
 | 
			
		||||
            .withClass(
 | 
			
		||||
                int.headers.h3,
 | 
			
		||||
                int.headers.title,
 | 
			
		||||
                int.headers.size16,
 | 
			
		||||
                int.headers.height20,
 | 
			
		||||
                int.headers.defaultColor
 | 
			
		||||
            )
 | 
			
		||||
            .withText(info.name)
 | 
			
		||||
            .appendTo(head);
 | 
			
		||||
 | 
			
		||||
            em.createH5('By '+info.author)
 | 
			
		||||
            .appendTo(title);
 | 
			
		||||
 | 
			
		||||
            em.createSwitch(() => { }, true)
 | 
			
		||||
            .appendTo(head);
 | 
			
		||||
 | 
			
		||||
            createElement("div")
 | 
			
		||||
            .withClass(
 | 
			
		||||
                int.misc3.description,
 | 
			
		||||
                int.misc3.formText,
 | 
			
		||||
                int.misc3.modeDefault
 | 
			
		||||
            )
 | 
			
		||||
            .withText(info.description)
 | 
			
		||||
            .appendTo(cont);
 | 
			
		||||
 | 
			
		||||
            var body = em.createHorizontalPanel()
 | 
			
		||||
            .appendTo(cont);
 | 
			
		||||
 | 
			
		||||
            createElement("div")
 | 
			
		||||
            .withClass(
 | 
			
		||||
                int.misc3.description,
 | 
			
		||||
                int.misc3.formText,
 | 
			
		||||
                int.misc3.modeDefault
 | 
			
		||||
            )
 | 
			
		||||
            .withText(`Replacements: ${info.replacements.length}`)
 | 
			
		||||
            .appendTo(body);
 | 
			
		||||
 | 
			
		||||
            createElement("div")
 | 
			
		||||
            .withClass(
 | 
			
		||||
                int.misc3.description,
 | 
			
		||||
                int.misc3.formText,
 | 
			
		||||
                int.misc3.modeDefault
 | 
			
		||||
            )
 | 
			
		||||
            .modify(x=>x.style.marginLeft = "8px")
 | 
			
		||||
            .withText(`Priority: ${info.priority}`)
 | 
			
		||||
            .appendTo(body);
 | 
			
		||||
 | 
			
		||||
            createElement("div")
 | 
			
		||||
            .withClass(
 | 
			
		||||
                int.misc3.description,
 | 
			
		||||
                int.misc3.formText,
 | 
			
		||||
                int.misc3.modeDefault
 | 
			
		||||
            )
 | 
			
		||||
            .modify(x=>x.style.marginLeft = "8px")
 | 
			
		||||
            .withText(info.loadAfter.length > 0 ? `Depends on: ${info.loadAfter.join(", ")}` : "No dependencies")
 | 
			
		||||
            .appendTo(body);
 | 
			
		||||
 | 
			
		||||
            createElement("div")
 | 
			
		||||
            .withClass(em.internal.dividers.divider)
 | 
			
		||||
            .appendTo(cont);
 | 
			
		||||
 | 
			
		||||
            return cont;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        $settingsapi.addSection("Plugins","Plugins",null,function(pnl){
 | 
			
		||||
            em.createH2("Plugins")
 | 
			
		||||
            .appendTo(pnl);
 | 
			
		||||
 | 
			
		||||
            let plugins = {}
 | 
			
		||||
 | 
			
		||||
            Object.keys($pluginStore).forEach(x=>{
 | 
			
		||||
                console.log(x);
 | 
			
		||||
                plugins[x] = {id:x,data:$pluginStore[x]};
 | 
			
		||||
            });
 | 
			
		||||
 | 
			
		||||
            Object.keys(plugins).forEach(x=>{
 | 
			
		||||
                let d = plugins[x];
 | 
			
		||||
                createPlugin(d.id,d.data)
 | 
			
		||||
                .appendTo(pnl);
 | 
			
		||||
            });
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -25,7 +25,8 @@ exports = {
 | 
			
		|||
        description: "Hijacking the settings pages.",
 | 
			
		||||
        replacements: [
 | 
			
		||||
            {signature:'/function z\\(\\){return\\[{(.+)}]}/',payload:'window.$settingsapi={sections:[{$1}]};function z(){return window.$settingsapi.sections;}'}
 | 
			
		||||
        ]
 | 
			
		||||
        ],
 | 
			
		||||
        loadAfter: ["system"]
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    init: function () {
 | 
			
		||||
| 
						 | 
				
			
			@ -36,6 +37,7 @@ exports = {
 | 
			
		|||
        var checkboxes = $api.util.findFuncExports('checkboxEnabled');
 | 
			
		||||
        var misc = $api.util.findFuncExports('statusRed-', 'inputDefault');
 | 
			
		||||
        var misc2 = $api.util.findFuncExports('multiInputField');
 | 
			
		||||
        var misc3 = $api.util.findFuncExports('formText-','formText');
 | 
			
		||||
        var headers = $api.util.findFuncExports('h5-', 'h5');
 | 
			
		||||
        var dividers = wc.findFunc('divider-')[0].exports;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -203,6 +205,7 @@ exports = {
 | 
			
		|||
                    checkboxes:checkboxes,
 | 
			
		||||
                    misc:misc,
 | 
			
		||||
                    misc2:misc2,
 | 
			
		||||
                    misc3:misc3,
 | 
			
		||||
                    headers:headers,
 | 
			
		||||
                    dividers:dividers
 | 
			
		||||
                }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -117,16 +117,21 @@ exports = {
 | 
			
		|||
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    replacements: {
 | 
			
		||||
 | 
			
		||||
        // changelog injection
 | 
			
		||||
        'key:"changeLog",get:function(){return E}':
 | 
			
		||||
            'key:"changeLog",get:function(){if(!E.injected){E.injected=1;E.date=E.date<=window.endpwn.changelog.date?window.endpwn.changelog.date:E.date;E.body=window.endpwn.changelog.body+"\\n\\n"+E.body}return E}',
 | 
			
		||||
 | 
			
		||||
        // crash screen hijack
 | 
			
		||||
        'var e=o("div",{},void 0,o("p",{},void 0,a.default.Messages.ERRORS_UNEXPECTED_CRASH),o("p",{},void 0,a.default.Messages.ERRORS_ACTION_TO_TAKE)),t=o(c.default,{size:l.ButtonSizes.LARGE,onClick:this._handleSubmitReport},void 0,a.default.Messages.ERRORS_RELOAD);return o(u.default,{theme:this.props.theme,title:a.default.Messages.UNSUPPORTED_BROWSER_TITLE,':
 | 
			
		||||
            `var e=o("div",{},void 0,o("p",{},void 0,"Something has gone very, very wrong, and Discord has crashed."),o("p",{},void 0,"If this is the first time you've seen this error screen, reload and hope for the best. If this screen appears again, follow these steps:"),o("p",{},void 0,"Try removing any new plugins and restarting again. If this solves the problem there may be a bug in a plugin or a conflict."),o("p",{},void 0,"If problems continue, it's likely that there is a bug in EndPwn or Discord."),o("p",{},void 0,"If you need help, join the EndPwn Discord server (https://discord.gg/wXdPNf2)"),o("p",{},void 0,"Details may be available in the console (Ctrl+Shift+I), but at this level of crash we can't be certain.")),t=o("div",{},void 0,o(c.default,{size:l.ButtonSizes.LARGE,onClick:()=>window.electron.getCurrentWindow().reload()},void 0,"Reload"),o(c.default,{size:l.ButtonSizes.LARGE,onClick:()=>{window.$api.localStorage.set('safemode',1);window.electron.getCurrentWindow().reload()}},void 0,"Reload in safe mode"));return o(u.default,{theme:this.props.theme,title:"Discord: Fatal Error",`
 | 
			
		||||
    manifest: {
 | 
			
		||||
        replacements: [
 | 
			
		||||
            // changelog injection
 | 
			
		||||
            {
 | 
			
		||||
                signature:'key:"changeLog",get:function(){return E}',
 | 
			
		||||
                payload:'key:"changeLog",get:function(){if(!E.injected){E.injected=1;E.date=E.date<=window.endpwn.changelog.date?window.endpwn.changelog.date:E.date;E.body=window.endpwn.changelog.body+"\\n\\n"+E.body}return E}'
 | 
			
		||||
            },
 | 
			
		||||
 | 
			
		||||
            // crash screen hijack
 | 
			
		||||
            {
 | 
			
		||||
                signature:'var e=o("div",{},void 0,o("p",{},void 0,a.default.Messages.ERRORS_UNEXPECTED_CRASH),o("p",{},void 0,a.default.Messages.ERRORS_ACTION_TO_TAKE)),t=o(c.default,{size:l.ButtonSizes.LARGE,onClick:this._handleSubmitReport},void 0,a.default.Messages.ERRORS_RELOAD);return o(u.default,{theme:this.props.theme,title:a.default.Messages.UNSUPPORTED_BROWSER_TITLE,',
 | 
			
		||||
                payload:`var e=o("div",{},void 0,o("p",{},void 0,"Something has gone very, very wrong, and Discord has crashed."),o("p",{},void 0,"If this is the first time you've seen this error screen, reload and hope for the best. If this screen appears again, follow these steps:"),o("p",{},void 0,"Try removing any new plugins and restarting again. If this solves the problem there may be a bug in a plugin or a conflict."),o("p",{},void 0,"If problems continue, it's likely that there is a bug in EndPwn or Discord."),o("p",{},void 0,"If you need help, join the EndPwn Discord server (https://discord.gg/wXdPNf2)"),o("p",{},void 0,"Details may be available in the console (Ctrl+Shift+I), but at this level of crash we can't be certain.")),t=o("div",{},void 0,o(c.default,{size:l.ButtonSizes.LARGE,onClick:()=>window.electron.getCurrentWindow().reload()},void 0,"Reload"),o(c.default,{size:l.ButtonSizes.LARGE,onClick:()=>{window.$api.localStorage.set('safemode',1);window.electron.getCurrentWindow().reload()}},void 0,"Reload in safe mode"));return o(u.default,{theme:this.props.theme,title:"Discord: Fatal Error",`
 | 
			
		||||
            }
 | 
			
		||||
        ],
 | 
			
		||||
        priority: 9999
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    start: function () {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue