n3k4a

from this to this

Aug 29th, 2020
265
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.28 KB | None | 0 0
  1. from this var a=['version','app_version','https://onedash.net/app_reg/get/update','data','content','data_a','electron-store','uuid/v4','sha1','device_id','set','electron','request','has','get','join','favicon.ico','Auto\x20Registrator','#7287D8','file://','/auth.html','show','closed','type','loadURL','once','new','then','/index.html?dark=','quit','close','GET','user_token','statusCode','parse'];(function(c,d){var e=function(f){while(--f){c['push'](c['shift']());}};e(++d);}(a,0x164));var b=function(c,d){c=c-0x0;var e=a[c];return e;};const Store=require(b('0x0'));const store=new Store();const uuid=require(b('0x1'));const md5=require(b('0x2'));const crypto=require('crypto');if(!store['has'](b('0x3')))store[b('0x4')](b('0x3'),uuid());const {app,BrowserWindow}=require(b('0x5'));const path=require('path');const req=require(b('0x6'));let window=null;var check_restart=![];function check_dark(){return new Promise((c,d)=>{if(!store[b('0x7')]('dark_theme_enabler'))return c(![]);return c(store[b('0x8')]('dark_theme_enabler'));});}function start_window(){window=new BrowserWindow({'icon':path[b('0x9')](__dirname,b('0xa')),'title':b('0xb'),'width':0x4b0,'height':0x320,'minWidth':0x1f4,'minHeight':0x28a,'webPreferences':{'devTools':!1,'backgroundThrottling':![],'webSecurity':![],'allowRunningInsecureContent':!![],'nativeWindowOpen':!![],'nodeIntegration':!![]},'backgroundColor':b('0xc'),'show':![]});if(store.has('last_data_window')){var datawindow = store.get('last_data_window');window.setSize(datawindow.size[0], datawindow.size[1]);window.setPosition(datawindow.position[0],
  2. to this
  3.  
  4. const Store = require('electron-store');
  5. const store = new Store();
  6. const uuid = require('uuid/v4');
  7. const md5 = require('sha1');
  8. const crypto = require('crypto');
  9. if (!store.has('device_id')) store.set('device_id', uuid());
  10. const {
  11. app,
  12. BrowserWindow
  13. } = require('electron');
  14. const path = require('path');
  15. const req = require('request');
  16. let window = null;
  17. var check_restart = false;
  18.  
  19. function check_dark() {
  20. return new Promise((c, d) => {
  21. if (!store.has('dark_theme_enabler')) return c(false);
  22. return c(store.get('dark_theme_enabler'));
  23. });
  24. }
  25.  
  26. function start_window() {
  27. window = new BrowserWindow({
  28. 'icon': path.join(__dirname, 'favicon.ico'),
  29. 'title': 'Auto Registrator',
  30. 'width': 1200,
  31. 'height': 800,
  32. 'minWidth': 500,
  33. 'minHeight': 650,
  34. 'webPreferences': {
  35. 'devTools': false,
  36. 'backgroundThrottling': false,
  37. 'webSecurity': false,
  38. 'allowRunningInsecureContent': true,
  39. 'nativeWindowOpen': true,
  40. 'nodeIntegration': true
  41. },
  42. 'backgroundColor': '#7287D8',
  43. 'show': false
  44. });
  45. if (store.has('last_data_window')) {
  46. var datawindow = store.get('last_data_window');
  47. window.setSize(datawindow.size[0], datawindow.size[1]);
  48. window.setPosition(datawindow.position[0], datawindow.position[1]);
  49. }
  50. if (!store.has('user_token')) {
  51. window.loadURL('file://' + __dirname + '/auth.html');
  52. window.once('ready-to-show', () => {
  53. window.show();
  54. });
  55. window.on('closed', function () {
  56. window = null;
  57. });
  58. } else {
  59. check_token().then(e => {
  60. if (!e.type) {
  61. window.loadURL('file://' + __dirname + '/auth.html');
  62. window.once('ready-to-show', () => {
  63. window.show();
  64. });
  65. window.on('close', function () {
  66. var size = window.getSize();
  67. var position = window.getPosition();
  68. store.set('last_data_window', {
  69. size: size,
  70. position: position
  71. })
  72. });
  73. window.on('closed', function () {
  74. window = null;
  75. });
  76. } else {
  77. if (e.v.new) {
  78. get_update().then(() => {
  79. check_dark().then(e => {
  80. window.loadURL('file://' + __dirname + '/index.html?dark=' + e);
  81. window.once('ready-to-show', () => {
  82. window.show();
  83. });
  84. window.on('closed', function () {
  85. window = null;
  86. });
  87. });
  88. });
  89. } else {
  90. check_dark().then(e => {
  91. window.loadURL('file://' + __dirname + '/index.html?dark=' + e);
  92. window.once('ready-to-show', () => {
  93. window.show();
  94. });
  95. window.on('closed', function () {
  96. window = null;
  97. });
  98. });
  99. }
  100. }
  101. });
  102. }
  103. window.on("close", function () {
  104. var o = window.getSize(),
  105. i = window.getPosition();
  106. store.set("last_data_window", {
  107. size: o,
  108. position: i
  109. })
  110. });
  111. }
  112. app.once('ready', () => {
  113. start_window();
  114. });
  115. app.on('window-all-closed', () => {
  116. if (!check_restart) app.quit();
  117. });
  118.  
  119. function close_window() {
  120. window.close();
  121. }
  122.  
  123. function check_token() {
  124. return new Promise((h, i) => {
  125. if (!store.has('user_token')) return h({
  126. 'type': false
  127. });
  128. var j = {
  129. 'method': 'GET',
  130. 'headers': {
  131. 'token': store.get('user_token')
  132. },
  133. 'url': 'https://onedash.net/app_reg/check'
  134. };
  135. req(j, (k, l, m) => {
  136. if (!l || !m || m == '' || k || l.statusCode != 200) return h({
  137. 'type': false
  138. });
  139. m = JSON.parse(m);
  140. if (!m.type) return h({
  141. 'type': false
  142. });
  143. var n = m.version;
  144. var o = false;
  145. if (!store.has('app_version')) {
  146. store.set('app_version', n);
  147. o = true;
  148. } else if (store.get('app_version') != n) {
  149. o = true;
  150. store.set('app_version', n);
  151. }
  152. return h({
  153. 'type': m.type,
  154. 'v': {
  155. 'new': o,
  156. 'version': n
  157. }
  158. });
  159. });
  160. });
  161. }
  162.  
  163. function get_update() {
  164. return new Promise((p, q) => {
  165. var r = {
  166. 'method': 'GET',
  167. 'headers': {
  168. 'token': store.get('user_token'),
  169. 'deviceid': store.get('device_id')
  170. },
  171. 'url': 'https://onedash.net/app_reg/get/update'
  172. };
  173. req(r, function (s, t, u) {
  174. if (!t || !u || u == '' || s || t.statusCode != 200) return p({
  175. 'type': false
  176. });
  177. var v = JSON.parse(u).data.content;
  178. var w = md5(store.get('user_token') + ':' + store.get('device_id'));
  179. store.set('data_a', v);
  180. return p({
  181. 'type': true
  182. });
  183. });
  184. });
  185. }
Add Comment
Please, Sign In to add comment