Menu Editor Fixed! (Console).

Menu Editor

Tento skript by nemal byť nainštalovaný priamo. Je to knižnica pre ďalšie skripty, ktorú by mali používať cez meta príkaz // @require https://update.greatest.deepsurf.us/scripts/467900/1200001/Menu%20Editor%20Fixed%21%20%28Console%29.js

  1. // ==UserScript==
  2. // @name Menu Editor Fixed! (Console).
  3. // @version 0.3
  4. // @description Menu Editor
  5. // @author Zpayer./.AMiNE.
  6. // @match http://*/*
  7. // @match https://*/*
  8. // @grant none
  9. // @run-at document-start
  10. // ==/UserScript==
  11.  
  12. const SetEditor=(ConfigColor='#9598c5',ConfigFont='monospace')=>{
  13. function GetSelected(k) {
  14. return k.options[k.selectedIndex].text
  15. }
  16. let make=(cl)=>top.document.createElement(cl);
  17. let html=(id)=>top.document.getElementById(id);
  18. var Editor = {
  19. addCate:(name='unknown',clss='unknown')=>{
  20. let el=make('div');
  21. el.id=name+'_cate';
  22. el.textContent=name;
  23. el.className='_cate';
  24. el.style=`
  25. border-bottom:2px solid ${ConfigColor};
  26. width:98%;
  27. cursor:default;
  28. padding:4px;
  29. color:${ConfigColor};
  30. margin:10px 2px 2px 4px;
  31. transition: 0.5s;
  32. `;
  33. clss.appendChild(el);
  34.  
  35. return el;
  36. },
  37. addButton:(name='unknown',clss='unknown',func=()=>{},long=false)=>{
  38. let el=make('input');
  39. el.id='_button';
  40. el.button_name=name;
  41. el.value=name;
  42. el.className=clss+'_element';
  43. el.type='button';
  44. el.style=`color:#aaa;background-color:#4f545c;border-radius:5px;border:none;height:23px;width:${long?'98.5%':'49%'};margin:1px;`;
  45. el.addEventListener('click',func);
  46. clss.appendChild(el);
  47. return el;
  48. },
  49. }
  50. Editor={
  51. addRange:(text,clss,value,Min,Max,func)=>{
  52. let div = document.createElement("div")
  53. div.className = "CheatRangeDiv"
  54. div.style= ` width: 100%;`
  55. let txt = document.createElement("div")
  56. txt.style = `
  57. font-family: ${ConfigFont};
  58. display: inline-block;
  59. width: 7%;
  60. font-size: 16px;
  61. left: 0%;
  62. color: rgb(219, 220, 220);
  63. position: relative;
  64. margin-right: 5%;
  65. text-align: left;
  66. `
  67. txt.textContent = text
  68. let el=document.createElement('input');
  69. el.id=text+'slider';
  70. el.value=value;
  71. el.className='slider';
  72. el.type='range';
  73. el.max = Max
  74. el.min = Min
  75. el.style=``;
  76. let num=make('input');
  77. num.value = value
  78. num.id=text+' num';
  79. num.type='number';
  80. num.max = Max
  81. num.min = Min
  82. num.style=`
  83. color:${ConfigColor};
  84. background-color: rgba(255, 255, 255, 0.06);
  85. border-radius: 1px;
  86. border: 1px solid;
  87. height: 25px;
  88. width: 35%;
  89. right: 0%;
  90. position: relative;
  91. display: inline;
  92. margin: 0px 1px;
  93. text-align: center;
  94. `;
  95. num.addEventListener('input',function(){
  96. el.value = num.value
  97. func()
  98. });
  99. el.addEventListener("input",function(){
  100. num.value = el.value
  101. func()
  102. });
  103. div.appendChild(txt);
  104. div.appendChild(el);
  105. div.appendChild(num);
  106. clss.appendChild(div);
  107. return {Number:num,Range:el,}
  108. },
  109. addField:(name='unknown',clss='unknown',n,Height=100,Width=95,top='l')=>{
  110. let field = document.createElement("fieldset")
  111. field.id = n+'field_box'
  112. field.className = 'scroller'
  113. field.style=`
  114. width:${Width}%;
  115. top: ${top}%;
  116. height:${Height}%;
  117. position: relative;
  118. background: transparent;
  119. border: 1px solid rgb(255 255 255 / 86%);
  120. display: inline-block;
  121. `
  122. clss.appendChild(field);
  123. let leg=make('legend');
  124. leg.id=name+'legend';
  125. leg.textContent =name
  126. leg.className='legend';
  127. leg.style=`
  128. font-size: 15px;
  129. font-weight: bold;
  130. text-align: left;
  131. text-transform: uppercase;
  132. padding: 3px;
  133. font-family:${ConfigFont};
  134. cursor: default;
  135. color:rgb(255 255 255 / 86%);
  136. width: 23%;
  137. `;
  138. field.appendChild(leg);
  139. return field
  140. },
  141. addToggle:(name='unknown',clss='unknown',func2=()=>{},func1=()=>{},check=false)=>{
  142. let div = document.createElement("div")
  143. div.className = "CheatRangeDiv"
  144.  
  145. let txt = document.createElement("h2")
  146. txt.style = `
  147. font-family: ${ConfigFont};
  148. display: inline-block;
  149. font-size: 16px;
  150. position: relative;
  151. text-align: left;
  152. /* left: -22%; */
  153. margin-left: -54%;
  154. }`
  155. txt.textContent = name
  156. let el=make('label');
  157. el.className = 'switcher'
  158. let checkbox=make('input');
  159. checkbox.type = 'checkbox'
  160. checkbox.checked=check
  161. checkbox.id = name+'_Switcher'
  162. el.onclick=()=>{
  163. if(checkbox.checked){
  164. func2()
  165. checkbox.checked=false;
  166. }else{
  167. func1()
  168. checkbox.checked=true;
  169. }
  170.  
  171. }
  172. el.appendChild(checkbox);
  173.  
  174. let slider=make('span');
  175. slider.className = 'toggle'
  176. el.appendChild(slider);
  177.  
  178. div.appendChild(txt);
  179. div.appendChild(el);
  180. clss.appendChild(div);
  181.  
  182. },
  183. addSelect:(txt, options, tab, confirm)=>{
  184. let div = document.createElement("div")
  185. div.className = "CheatSelectDiv"
  186. let select = document.createElement("select")
  187. select.className = "CheatSelect"
  188. select.defaultState = function(){
  189. select.options[0].selected = true
  190. }
  191. select.updateOptions = function(options){
  192. select.options.length = 0
  193. let option = document.createElement("option")
  194. option.textContent = txt
  195. option.disabled = true
  196. option.selected = true
  197. select.appendChild(option)
  198. options.forEach((opt)=>{
  199. let option = document.createElement("option")
  200. option.textContent = opt
  201. select.appendChild(option)
  202. })
  203. }
  204. let option = document.createElement("option")
  205. option.selected = true
  206. option.disabled = true
  207. option.textContent = txt
  208. select.appendChild(option)
  209. options.forEach((opt) => {
  210. let option = document.createElement("option")
  211. option.textContent = opt
  212. select.appendChild(option)
  213. })
  214. let input = document.createElement("input")
  215. input.className = "CheatButton"
  216. input.style = `
  217. height: 40px;
  218. width: 40px;
  219. margin-left: 10px;
  220. `
  221. input.type = "button"
  222. input.value = "✓"
  223. input.onclick = confirm
  224. div.appendChild(select)
  225. div.appendChild(input)
  226. tab.appendChild(div)
  227. return select
  228. },
  229. addPlaceHolder:(txt,clss,id,func=()=>{})=>{//----------------------------------------- super "All" Chat
  230. let el= make('input');
  231. el.id=id;
  232. el.type='placeholder';
  233. el.style=`
  234. color: rgb(219, 220, 220);
  235. background-color: rgba(163, 165, 167, 0.07);
  236. border-radius: 1px;
  237. border: 1px solid;
  238. height: 30px;
  239. width: 95%;
  240. margin: 1px 11px;`;
  241. el.placeholder = txt;
  242. el.addEventListener("keydown", function(e) {
  243. if (e.key == "Enter") {
  244. func()
  245. el.value = "";
  246. }
  247. });
  248. clss.appendChild(el);
  249. return el
  250. },
  251. addLister:(txt,options,tab,func)=>{
  252. let div = document.createElement("div")
  253. let div2_ = document.createElement("div")
  254. var divslist=[]
  255. //var ListOfSelected=[]
  256. var ListerSelector = Editor.addSelect(txt,options,tab,()=>{
  257. const Selected=GetSelected(ListerSelector)
  258. ListerSelector.Lister.push(Selected)
  259. let div2 = document.createElement("div")
  260. var tt = Editor.addButton(Selected,div2,()=>{})
  261. tt.style.width='80%'
  262. var yoptov= Editor.addButton("X",div2,()=>{
  263. const index = ListerSelector.Lister.indexOf(Selected);
  264. if (index > -1) { // only splice array when item is found
  265. ListerSelector.Lister.splice(index, 1); // 2nd parameter means remove one item only
  266. }
  267. div2.remove()
  268. })
  269. yoptov.style.width='15%'
  270. div2_.appendChild(div2);
  271. divslist.push(div2)
  272. })
  273. ListerSelector.Lister=[]
  274. div.appendChild(div2_);
  275. var ApplyButton=Editor.addButton('Apply',div,()=>{
  276. func()
  277. ListerSelector.Lister=[]
  278. divslist.forEach(k=>k.remove())
  279. },true)
  280. tab.appendChild(div);
  281. return ListerSelector
  282. },
  283. addBB:(name='unknown',menu,bar,id='unknown',choosen=0)=>{
  284. let el=make('div');
  285. var jo = el
  286. el.className='scroller'
  287. el.id='something? ;-;';
  288. el.style=`
  289. position:absolute;
  290. display:${choosen?'block':'none'};
  291. width:75%;height:90%;
  292. top:10%;
  293. right:0px;
  294. `;
  295. menu.appendChild(el);
  296. el=make('div');
  297. el.id='console_bar_'+id;
  298. el.className='bar_element bar_element_'+(choosen?'on':'off');
  299. el.textContent=name;
  300. el.addEventListener('click',function(e){
  301. if(this!=bar.cur){
  302. jo.style.display='block';
  303. menu.cur.style.display='none';
  304. menu.cur=jo;
  305. this.className='bar_element bar_element_on';
  306. bar.cur.className='bar_element bar_element_off';
  307. bar.cur=this;
  308. }
  309. });
  310. bar.appendChild(el);
  311. return jo
  312. },
  313. addColorPicker:(clss='unknown',value)=>{
  314. let el=make('input');
  315. el.className='color'+clss;
  316. el.value = value
  317. el.type='color';
  318. el.style=`
  319. background-color: rgb(192 192 192);
  320. border-radius: 2px;
  321. border: none;
  322. height: 37%;
  323. width: 40%;
  324. `;
  325. clss.appendChild(el);
  326. return el;
  327. },
  328. addFile:(clss='unknown')=>{
  329. let el=make('input');
  330. el.className='fileClass';
  331. el.type='file';
  332. el.id = 'fileu'
  333. el.style = 'position: fixed;right: 20000000000000%;'
  334. clss.appendChild(el);
  335. let button=make('input');
  336. button.className='NewfileClass';
  337. button.type='button';
  338. button.id = 'filebutton';
  339. button.value = 'Choose image';
  340. button.onclick = function(){el.click()}
  341. button.style = `
  342. color: ${ConfigColor};
  343. background-color: rgb(35 35 35);
  344. border-radius: 5px;
  345. border: 1px solid ${ConfigColor};
  346. height: 25px;
  347. width: 25%;
  348. margin: 1px;`
  349. clss.appendChild(button);
  350. return el;
  351. },
  352. addSwitcher:(name='unknown',clss='unknown',state=[],func=[],funcint=[],time=0,vehicle='')=>{
  353. let a=make('div');
  354. a.id=vehicle+name+'_switcher_settings';
  355. a.style=`
  356. display:flex;
  357. justify-content:center;
  358. align-items:center;
  359. margin:3px 0;
  360. `;
  361. clss.appendChild(a);
  362. let elm=make('div');
  363. elm.id=vehicle+name+'_switcher_attribute';
  364. elm.style=`
  365. color:#aaa;
  366. width:49%;
  367. display:flex;
  368. align-items:center;
  369. justify-content:center;
  370. margin:1px 11px;
  371. `;
  372. elm.textContent=name;
  373. a.appendChild(elm);
  374. var el=make('input');
  375. var switchinterval=0;
  376. var i=0;
  377. el.id=vehicle+name+'_switcher';
  378. el.button_name=vehicle+name;
  379. el.value=state[0];
  380. el.className=clss+'_element';
  381. el.type='button';
  382. el.style=`
  383. color:#aaa;
  384. background-color:#4f545c;
  385. border-radius:5px;
  386. border:none;
  387. height:23px;
  388. width:49%;
  389. margin:1px 11px;
  390. `;
  391. el.addEventListener('click',function(){
  392. if(i)clearInterval(switchinterval);
  393. i=++i%(state.length);
  394. el.value=state[i];
  395. if(func[i])func[i]();
  396. if(i&&funcint[i])switchinterval=setInterval(funcint[i],time);
  397. });
  398. a.appendChild(el);
  399. return a;
  400. },
  401. addList:(name,clss,list=[],func=[],Lists)=>{
  402. let edl=make('div');
  403. edl.id=name+'_list';
  404. edl.className='scroller'
  405. edl.setAttribute('style', `
  406. display:none;
  407. position: absolute;
  408. top: 0;
  409. left: 0;
  410. width: 100%;
  411. height: 100%;
  412. background-color: rgb(35 35 35 / 94%);
  413. direction: rtl;
  414. border: 1px solid rgb(54, 57, 63);
  415. `);
  416. clss.appendChild(edl);
  417. Editor.addCate(name,edl)
  418. edl.CurrentButtons=[]
  419. /*edl.UpdateFunctions=function(NewFunc){
  420. edl.CurrentButtons.forEach(m=>m.remove())
  421. edl.CurrentButtons=[]
  422. for (var i=0;i>=Math.min(list.length,func.length); i++) {
  423. var CB = addButton(list[i],edl,()=>{edl.style.display='none';NewFunc[i]();})
  424. edl.CurrentButtons.push(CB)
  425. }
  426. }
  427. edl.UpdateList=function(NewList){
  428. edl.CurrentButtons.forEach(m=>m.remove())
  429. edl.CurrentButtons=[]
  430. for (var i=0;i>=Math.min(list.length,func.length); i++) {
  431. var CB = addButton(NewList[i],edl,()=>{edl.style.display='none';func[i]();})
  432. edl.CurrentButtons.push(CB)
  433. }
  434. }*/
  435. edl.UpdateAll=function(NewList,NewFunc,time=10){
  436. if(Math.min(NewList.length,NewFunc.length)!=0){
  437. var i = 0
  438. var ButtonMakerInter = setInterval(()=>{
  439. if(i>=Math.min(NewList.length,NewFunc.length)){
  440. clearInterval(ButtonMakerInter);ButtonMakerInter=0;
  441. }else{
  442. i++
  443. var CB = addButton(NewList[i],edl,()=>{edl.style.display='none';NewFunc[i]();})
  444. edl.CurrentButtons.push(CB)
  445. }
  446. },time)
  447. }
  448. }
  449. if(Lists.Lists[name]==undefined){
  450. Lists.Lists[name]=[]
  451. }
  452. Lists.Lists[name].push(edl)
  453. if(Math.min(list.length,func.length)!=0){
  454. var i = 0
  455. var ButtonMakerInter = setInterval(()=>{
  456. if(i>=Math.min(list.length,func.length)){
  457. clearInterval(ButtonMakerInter);ButtonMakerInter=0;
  458. }else{
  459. i++
  460. var CB = addButton(list[i],edl,()=>{edl.style.display='none';func[i]();})
  461. edl.CurrentButtons.push(CB)
  462. }
  463. },10)
  464. }
  465. return edl
  466. },
  467. }
  468. var sheet=top.document.head.appendChild(make('style')).sheet;
  469. sheet.insertRules=rules=>rules.replace(/\}/g,'}^').split('^').map(r=>(r.indexOf('{')+1)&&sheet.insertRule(r));
  470. sheet.insertRules(`
  471. .scroller{overflow-y:auto;}
  472. .scroller::-webkit-scrollbar{
  473. width:10px;
  474. }
  475. .scroller::-webkit-scrollbar-thumb{
  476. background-color:rgba(0,0,0,.4);
  477. -webkit-box-shadow:inset 0 0 2px rgba(0,0,0,.5);
  478. box-shadow:inset 0 0 2px rgba(0,0,0,.5);
  479. }
  480. .scroller::-webkit-scrollbar-track{
  481. background-color:rgba(0,0,0,.3);
  482. }
  483. .scroller::-webkit-scrollbar-thumb{
  484. background:#000;
  485. }
  486. .bar_element:hover{
  487. opacity:0.9;
  488. background:#40444bAA;
  489. transition-duration: 0.3s;
  490. }
  491. .bar_element{
  492. color:#FFF;
  493. line-height: 200%;
  494. cursor:pointer;
  495. height:10%;
  496. width:100%;
  497. }
  498. .cheat_element:hover{
  499. color:#FFF !important;
  500. }
  501. .bar_element_off{
  502. opacity:0.5;
  503. background:#0000;
  504. }
  505. .bar_element_on{
  506. opacity:1;
  507. background:#40444b;
  508. }
  509. .CheatSelect {
  510. background-color: rgb(38 38 38 / 0%);
  511. color: rgb(219 220 220);
  512. height: 40px;
  513. box-sizing: border-box;
  514. border: 1px solid;
  515. width: 61%;
  516. opacity: 0.7;
  517. transition: all 0.5s ease 0s;
  518. display: inline-block;
  519. font-family: ${ConfigFont};
  520. }
  521. .CheatSelect:hover {
  522. opacity: 1;
  523. }
  524. .CheatButton {
  525. background-color: rgb(38 38 38 / 0%);
  526. color: rgb(219, 220, 220);
  527. height: 40px;
  528. width: 140px;
  529. text-align: center;
  530. box-sizing: border-box;
  531. border: 1px solid;
  532. outline: none;
  533. opacity: 0.7;
  534. transition: all 0.5s ease 0s;
  535. }
  536. .CheatButton:hover {
  537. opacity: 1;
  538. }
  539. .slider {
  540. appearance: none;
  541. width: 46%;
  542. height: 5px;
  543. background: rgb(219, 220, 220);
  544. outline: none;
  545. opacity: 0.7;
  546. transition: opacity 0.2s ease 0s;
  547. display: inline;
  548. margin: 6px;
  549. }
  550. .slider:hover {
  551. opacity: 1;
  552. }
  553. .slider::-webkit-slider-thumb {
  554. -webkit-appearance: none;
  555. appearance: none;
  556. width: 7px;
  557. height: 15px;
  558. background:${ConfigColor};
  559. cursor: pointer;
  560. }
  561. .switch {
  562. position: relative;
  563. display: inline-block;
  564. width: 60px;
  565. height: 34px;
  566. }
  567.  
  568. .switch input {
  569. opacity: 0;
  570. width: 0;
  571. height: 0;
  572. }
  573. .switcher {
  574. position: absolute;
  575. display: inline-block;
  576. width: 57px;
  577. height: 23px;
  578. left: 74%;
  579.  
  580. }
  581.  
  582. .switcher input {
  583. opacity: 0;
  584. width: 0;
  585. height: 0;
  586. }
  587. .toggle {
  588. position: absolute;
  589. cursor: pointer;
  590. top: 0;
  591. left: 0;
  592. right: 0;
  593. bottom: 0;
  594. background-color: #ccc;
  595. -webkit-transition: .4s;
  596. transition: .4s;
  597. }
  598.  
  599. .toggle:before {
  600. position: absolute;
  601. content: "";
  602. height: 21px;
  603. width: 20px;
  604. left: 8px;
  605. border-radius: 4px;
  606. bottom: 1px;
  607. background-color: white;
  608. transition: all 0.4s ease 0s;
  609. }
  610.  
  611. input:checked + .toggle {
  612. background-color:${ConfigColor};
  613. }
  614.  
  615. input:focus + .toggle {
  616. box-shadow: 0 0 1px #2196F3;
  617. }
  618.  
  619. input:checked + .toggle:before {
  620. -webkit-transform: translateX(26px);
  621. -ms-transform: translateX(26px);
  622. transform: translateX(26px);
  623. }
  624. `);
  625. return Editor
  626. }