update settingsapi

This commit is contained in:
Cynthia Foxwell 2018-05-22 11:17:17 -06:00
parent 6ea8342f94
commit 4dbde490cf
1 changed files with 30 additions and 6 deletions

View File

@ -1,18 +1,18 @@
/*
EndPwn3 System (settings UI)
Copyright 2018 EndPwn Project
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
DO NOT EDIT THIS FILE! Your bootstrap may overwrite changes to it, and you will lose your work!
EndPwn3 users: You can prevent this by creating a file in the same directory named DONTUPDATE
https://github.com/endpwn/
*/
@ -24,6 +24,10 @@ exports = {
name: "Settings Page + Settings API",
description: "Hijacking the settings pages.",
replacements: [
{
signature:/section:"logout",onClick:function\(\){(.)\.default\.push\(function\((.)\){return (.)\.createElement\((.)\.default,(.)\((.+),(.)\),(.)\((.)\.default,{size:(.)\.default\.Sizes\.MEDIUM,color:(.)\.default\.Colors\.PRIMARY},void 0,((.)\.default\.Messages\.USER_SETTINGS_CONFIRM_LOGOUT)\)\)}\)}/,
payload:'section:"logout",onClick:window.__fancyDialog=function(data=$6,txt=$12){$1.default.push(function($2){return $3.createElement($4.default,$5(data,$7),$8($9.default,{size:$10.default.Sizes.MEDIUM,color:$11.default.Colors.PRIMARY},void 0,txt))})}'
},
{signature:'/function (.)\\(\\){return\\[{(.+)}]}/',payload:'window.$settingsapi={sections:[{$2}]};function $1(){return window.$settingsapi.sections;}'}
],
loadAfter: ["system"]
@ -45,6 +49,9 @@ exports = {
var panels2 = $api.util.findFuncExports('errorMessage-', 'inputWrapper');
let sections = window.$settingsapi.sections;
let dialog = window.__fancyDialog;
delete window.__fancyDialog;
window.$settingsapi = {
sections: sections,
@ -71,6 +78,7 @@ exports = {
$settingsapi.ourSections.push({section:"HEADER",label:label});
$settingsapi.sections.splice($settingsapi.sections.length-4,0,{section:"HEADER",label:label});
},
fancyDialog: dialog,
//All of these allow us to use Discord's elements.
elements: {
createVerticalPanel: function() {
@ -323,7 +331,23 @@ exports = {
em.createWarnButton("Restart in safe mode")
.modify(x => x.onclick = endpwn.safemode),
em.createDangerButton("Uninstall EndPwn")
.modify(x => x.onclick = endpwn.uninstall)
.modify(x => x.onclick = function () {
$settingsapi.fancyDialog({
header: 'EndPwn: confirm uninstallation',
confirmText: 'Yes', cancelText: 'No',
onConfirm: () => {
var data = $api.data;
$api.settings.set('WEBAPP_ENDPOINT');
$api.settings.set('WEBAPP_PATH');
reload();
}
},'Are you sure you want to remove EndPwn from your client? You can reinstall it at any time.');
})
)
.appendTo(content);