Change the scope to survev.io, surviv.io, suroi.io, suroi.fpsgo.net and zombsroyale.io

Сhange the scope in the game survev.io, surviv.io, suroi.io, suroi.fpsgo.net and zombsroyale.io

  1. // ==UserScript==
  2. // @name Change the scope to survev.io, surviv.io, suroi.io, suroi.fpsgo.net and zombsroyale.io
  3. // @name:ru Изменить прицел в survev.io, surviv.io, suroi.io, suroi.fpsgo.net и zombsroyale.io
  4. // @namespace https://github.com/AlekPet/
  5. // @version 0.0.8.3.8
  6. // @description Сhange the scope in the game survev.io, surviv.io, suroi.io, suroi.fpsgo.net and zombsroyale.io
  7. // @description:ru Изменяет прицел в игре survev.io, surviv.io, suroi.io, suroi.fpsgo.net и zombsroyale.io
  8. // @copyright 2018, AlekPet (https://github.com/AlekPet)
  9. // @author AlekPet
  10. // @license MIT; https://opensource.org/licenses/MIT
  11. // @match *://surviv.io/*
  12. // @match *://survev.io/*
  13. // @match *://surviv2.io/*
  14. // @match *://suroi.io/*
  15. // @match *://suroi.fpsgo.net/*
  16. // @match *://2dbattleroyale.com/*
  17. // @match *://zombsroyale.io/*
  18. // @icon data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBwgHBgkIBwgKCgkLDRYPDQwMDRsUFRAWIB0iIiAdHx8kKDQsJCYxJx8fLT0tMTU3Ojo6Iys/RD84QzQ5OjcBCgoKDQwNGg8PGjclHyU3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3N//AABEIAIIAggMBEQACEQEDEQH/xAAbAAADAAMBAQAAAAAAAAAAAAACAwYBBAUAB//EADwQAAIBAwEEBwUGBQQDAAAAAAECAwAEEQUGEiExIkFRYXGRoRMygbHBFCNCUmLRM0NywuEkgvDxNFNj/8QAGQEAAgMBAAAAAAAAAAAAAAAAAAECAwQF/8QAKxEAAgIBBAEDAwMFAAAAAAAAAAECAxEEEiExQRMiUTJhcRRC0SNDUoGh/9oAD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BitEoRs5RsqvlBcdHQl2y6H3Vjh/1y8PlUFp/ll71fxE5Crf7QXft52O4OBcjCIOxR/wA76sbjUsIyWWuTzJlLFGkEKQxDEaDdUVlby8sy5yCxoGBmgDympMBitURDFakAuWxs523prWF2PWU41JSkumPLG29vb23/AI8EcR7UUA+dRk2+2DbZsBqiIzmgRnNID29QBgtTGYLUAKmSOZdyaNJF7HGRUk2ugXBqDTrBG3ls4M96ZqW+T8j3MeSAABgADAAqIhbGmMWxpoAM0wPKaADDUAMDVEQYagAw1IAg1AGc0gM5pYA9mngDBagDBamAJagACaYAFqBi2amAsmmMHepgeFIGGKBDBQwDFREEKQBCgAhSAzQB6gDxoAA0wBNAAtzpgAaBi2qQANTGBQB//9k=
  19. // @run-at document-end
  20. // @grant GM_setValue
  21. // @grant GM_getValue
  22. // @grant GM_addStyle
  23. // @grant GM_getResourceText
  24. // @require https://code.jquery.com/jquery-3.1.0.min.js
  25. // @resource scopes https://raw.githubusercontent.com/AlekPet/Change-the-scope-to-games/master/assets/json/scopes.json
  26. // ==/UserScript==
  27.  
  28. GM_addStyle(`
  29. .mPanel_cur {
  30. position: fixed;
  31. top: 5%;
  32. left: 50%;
  33. background: #dadada;
  34. max-width: 650px;
  35. width: 650px;
  36. z-index: 50;
  37. border: 1px solid silver;
  38. box-shadow: 2px 2px 5px #847b7b;
  39. margin-left: -325px;
  40. text-align: center;
  41. display: none;
  42. }
  43. .mPanel_cur_title {
  44. background: silver;
  45. font: bold 1em monospace;
  46. padding: 5px;
  47. color: white;
  48. text-shadow: 1px 1px 3px darkblue;
  49. border-bottom: 1px dotted white;
  50. user-select: none;
  51. }
  52. .mPanel_cur_title > div{
  53. float:right;
  54. }
  55. .mPanel_cur_title > div:hover {
  56. color: #d1fffb;
  57. }
  58. .table_box{
  59. display: table
  60. }
  61. .table_box > div{
  62. display: table-cell
  63. }
  64. .rightPanel_options{
  65. text-shadow: 1px 1px 3px darkgreen;
  66. background: linear-gradient(to right, #62a965,#0e2f0e);
  67. color: #ffffff;
  68. border-left: 1px dotted white;
  69. padding: 5px;
  70. }
  71. .rightPanel_options_title {
  72. background: linear-gradient(#69e815,#3f7703);
  73. color: white;
  74. padding: 2px 0;
  75. user-select: none;
  76. }
  77. .rightPanel_options_inside {
  78. border: 1px solid;
  79. width: 150px;
  80. overflow-y: auto;
  81. }
  82. .mPanel_cur_list_box {
  83. background: #ffffff;
  84. width: 80%;
  85. }
  86. .optionFiels {
  87. border-top: 1px dotted;
  88. }
  89. ul.list_cur {
  90. padding: 0;
  91. margin: 0;
  92. height: 550px;
  93. width: 480px;
  94. overflow-y: auto;
  95. display: flex;
  96. flex-direction: row;
  97. flex-wrap: wrap;
  98. }
  99. .list_cur > li {
  100. /*min-width: 88px;
  101. min-height: 88px;
  102. max-height: 120px;
  103. width: 88px;
  104. height: 88px;
  105. overflow: hidden;*/
  106. }
  107. .list_cur > .element_cur_cont {
  108. list-style: none;
  109. display: inline-block;
  110. padding: 5px;
  111. text-align: center;
  112. border: 1px dotted silver;
  113. margin: 5px;
  114. cursor: pointer;
  115. vertical-align: top;
  116. background: linear-gradient(to right bottom, silver,white);
  117. flex: 1 0 88px;
  118. }
  119. .element_cur_cont:hover {
  120. background: linear-gradient(#00ffff75,#dbff005c);
  121. }
  122. .acive_cursor{
  123. background: linear-gradient(#00ffff75,#dbff005c) !important;
  124. }
  125. .element_cur_title {
  126. color: black;
  127. text-shadow: 1px 1px 3px darkgrey;
  128. word-wrap: break-word;
  129. font-size: 0.8em;
  130. }
  131. .mPanel_cur_foot {
  132. background: #757574;
  133. padding: 3px;
  134. border-top: 1px dotted white;
  135. color: antiquewhite;
  136. text-shadow: 1px 1px 3px darkgreen;
  137. }
  138. .infoBlock {
  139. float: right;
  140. }
  141. .infoBlock>a{
  142. font-size: 0.6em;
  143. margin-top: 4px;
  144. padding: 2px;
  145. text-decoration:none;
  146. }
  147. .cur_sel_button_box {
  148. display: inline-block;
  149. }
  150. .cur_button {
  151. border: 1px solid silver;
  152. padding: 3px;
  153. font-size: 0.7em;
  154. cursor: pointer;
  155. user-select: none;
  156. display: inline-block;
  157. margin-left:10px;
  158. }
  159. .add_cur{
  160. background: linear-gradient(#b3b766,#07b994);
  161. color:white
  162. }
  163. .add_cur:hover{
  164. background: linear-gradient(#e7f134,#00ffca);
  165. color: #424242;
  166. }
  167. .create_cur {
  168. background: linear-gradient(#b3b766,#07b994);
  169. color: white;
  170. }
  171. .create_cur {
  172. background: linear-gradient(#ff8a00,#ff6161);
  173. color: white;
  174. }
  175. .del_cur{
  176. display:none;
  177. background:linear-gradient(#b76666,#b90776);
  178. }
  179. .del_cur:hover{
  180. background: linear-gradient(#c12b2b,#d89cc1) !important;
  181. color: white;
  182. }
  183. .checkbox_del_cur {
  184. }
  185. .checkbox_edit_cur {
  186. font-size: 0.6em;
  187. vertical-align: text-top;
  188. background: limegreen;
  189. border: 0;
  190. color: white;
  191. border-radius: 4px;
  192. text-shadow: 1px 1px 3px black;
  193. cursor:pointer;
  194. }
  195. .checkbox_edit_cur:hover {
  196. background: #ff9b00;
  197. }
  198. .zomb_btn-red {
  199. background: rgb(175, 80, 80);
  200. border-bottom: 2px solid rgb(122, 56, 56);
  201. box-shadow: rgb(122, 56, 56) 0px -2px inset;
  202. color: #fff;
  203. cursor: pointer;
  204. font-size: 12px;
  205. position: fixed;
  206. text-shadow: 0 1px 2px rgba(0,0,0,.25);
  207. top: 50%;
  208. right: 0;
  209. display: block;
  210. opacity: 0.7;
  211. transform: translate(0, -20px) rotateZ(-90deg);
  212. transform-origin: bottom right;
  213. height: 25px;
  214. width: 105px;
  215. line-height: 20px;
  216. border: 0;
  217. border-radius: 5px;
  218. box-sizing: border-box;
  219. margin-bottom: 8px;
  220. text-align: center;
  221. text-decoration: none;
  222. z-index:999;
  223. }
  224. .zomb_btn-darken:active, .zomb_btn-darken:hover {
  225. color: inherit;
  226. -webkit-filter: brightness(80%);
  227. filter: brightness(80%);
  228. transition: all .25s ease;
  229. }
  230. .makeCursor_form {
  231. position: fixed;
  232. top: 20%;
  233. left: 50%;
  234. width: 350px;
  235. margin-left: -180px;
  236. border: 1px solid silver;
  237. background: #dadada;
  238. display: none;
  239. box-shadow: 3px 3px 5px silver;
  240. z-index: 5;
  241. }
  242. .makeCursor_form_title {
  243. background: darkgrey;
  244. color: white;
  245. text-shadow: 1px 1px 3px darkolivegreen;
  246. padding: 3px;
  247. border-bottom: 1px dotted;
  248. font: bold 1em monospace;
  249. }
  250. .makeCursor_form_title > div {
  251. float: right;
  252. cursor: pointer;
  253. }
  254. .makeCursor_form_title > div:hover {
  255. color: #d1fffb;
  256. }
  257. .maleCursor_form_body input {
  258. width: 80%;
  259. margin: 5px;
  260. padding: 2px;
  261. border: 1px dotted #04fbc6;
  262. }
  263. .maleCursor_form_body > .form_field{
  264.  
  265. }
  266. .maleCursor_form_body span {
  267. color: #635e5e;
  268. font: normal 1em monospace;
  269. }
  270. .maleCursor_form_foot {
  271. padding: 5px;
  272. background: whitesmoke;
  273. }
  274. .cur_preview {
  275. border: 1px dotted #0d6b57;
  276. width: 50%;
  277. margin: 10px auto;
  278. padding: 5px;
  279. background: floralwhite;
  280. }
  281. .cur_preview > p {
  282. background: #b7b2b2;
  283. padding: 0px;
  284. margin: 0;
  285. color: white;
  286. }
  287. .cur_preview > img {
  288. margin: 10px;
  289. }
  290. .drawSelf {
  291. font-size: 0.9em;
  292. padding: 3px;
  293. background: #b5c5c3;
  294. }
  295. .drawSelf > a{
  296. font-size: 0.9em;
  297. }
  298. .cur_overlay {
  299. background: #000000cc;
  300. position: fixed;
  301. top: 0;
  302. left: 0;
  303. width: 100%;
  304. height: 100%;
  305. z-index: 5;
  306. display:none;
  307. }
  308. img#image_aim {
  309. position: absolute;
  310. z-index: 6;
  311. }
  312. .colorchange_cur {
  313. width: 20px;
  314. height: 20px;
  315. background: radial-gradient(red,orange,yellow,green,cyan,blue,purple);
  316. border-radius: 10px;
  317. display: inline-block;
  318. margin-right: 2px;
  319. transition: 1s all;
  320. }
  321. .colorchange_cur:hover {
  322. background: radial-gradient(purple,blue,cyan,green,yellow,orange,red);
  323. }
  324. .colorChangeButtons{
  325. width: 70px;
  326. margin: 2px;
  327. }
  328. #setChangeColor {
  329. background: linear-gradient(#669ab7,#0773b9);
  330. margin-top: 10px;
  331. }
  332. #setChangeColor:hover {
  333. background: linear-gradient(#00a4ff,#043656);
  334. }
  335. #setDefaultChangeColor {
  336. background: linear-gradient(#b76666,#b90707);
  337. }
  338. #setDefaultChangeColor:hover {
  339. background: linear-gradient(#ff0000,#5f0303);
  340. }
  341. .canvasColor{
  342. width: 128px;
  343. height: 128px;
  344. border: 1px dotted;
  345. margin: 0 auto;
  346. display: table;
  347. }
  348. .canvasColor>div{
  349. display: table-cell;
  350. vertical-align: middle;
  351. }
  352. .font_8{
  353. font-size: 0.8em;
  354. }
  355. .font_7{
  356. font-size: 0.7em;
  357. }
  358. .font_6{
  359. font-size: 0.6em;
  360. }
  361. .rightPanel_options input[type=range]::-webkit-slider-thumb {
  362. background: #f3f3f3;
  363. }
  364. .rightPanel_options input[type=range] {
  365. background: #ff7500;
  366. border: 1px solid black;
  367. border-radius: 6px;
  368. }
  369. .makeCursor_form input {
  370. color: black;
  371. }
  372. `);
  373.  
  374. (function() {
  375. 'use strict';
  376. const cursorList = JSON.parse(GM_getResourceText('scopes')).scopes || [{name:"Scope 1",cururl:"http://www.rw-designer.com/cursor-view/101646.png",active:false},
  377. {name:"Scope 2",cururl:"http://www.rw-designer.com/cursor-view/111928.png",active:false},
  378. {name:"Scope 3",cururl:"http://www.rw-designer.com/cursor-view/111937.png",active:false},
  379. {name:"Scope 4",cururl:"http://www.rw-designer.com/cursor-view/78056.png",active:false},
  380. {name:"Scope 5",cururl:"http://www.rw-designer.com/cursor-view/97540.gif",active:false},
  381. {name:"Scope 6",cururl:"https://image.flaticon.com/icons/png/128/487/487009.png",active:false}],
  382. lang = {
  383. ru:{
  384. form_title: "Выбор прицела",
  385. addCrosshair: "Добавить прицел",
  386. editCrosshair: "Правка",
  387. editComplete: "Прицел был отредактирован!",
  388. editEditApply: "Применить изменения",
  389. delCrosshair: "Удалить прицел(ы)?",
  390. delComplete: "Прицел(ы) были удалены!",
  391. selectCrosshair: "Выбрать: ",
  392. scopeName: "Название прицела (необяз.)",
  393. scopeLink: "Ссылка прицела (png,gif,jpg,cur,base64)",
  394. errorName: "Внимание:\nПоле имени не задано, будет использовано случайное название!\nНазвание: ",
  395. errorLinkEmpty: "Поле ссылки пустое!",
  396. errorLink: "Поле ссылки указано неверно!",
  397. errorImage: "Размер изображения больше 128x128 px, или равно 0x0 px, или не определенно!",
  398. errorAdd: "Сообщение:\nПрицел не был добавлен из-за неверно заданных параметров!",
  399. addComplete: "Сообщение:\nПрицел был успешно добавлен!",
  400. name: "Название: ",
  401. link: "Ссылка: ",
  402. preview: "Предпросмотр",
  403. drawSelf: "Нарисовать свой ",
  404. drawSelfInstructions: "File > New\nSet size <= 128px\nРисуем прицел\nSave as data URL\nКопиуем код и вставляем в поле Ссылки",
  405. scopeSite: "Еще прицелы",
  406. createScope: "Создать прицел",
  407. alertMesImage: ["Внимание:\nРазмер изображения ","Максимально допустимый размер изображения 128x128px!\nИначе работать не будет!\nПроверить прицел можно, если навести на рисунок..."],
  408. selectScope: "Выбрать прицел",
  409. form_close: "Закрыть",
  410. resetDefault: "Загрузить стандартные",
  411. resetDefaultCompete: "Стандартные прицелы были загружены!",
  412. resetQuestion: "Вы действительно хотите загрузить стандартные прицелы?\nВсе ваши добавленные прицелы, буду удалены?",
  413. resetQuestionFisrt: "Загрузить стандартный набор прицелов?",
  414. laserColor: "Цвет луча:\nПо умолчанию: red",
  415. laserWidth: "Толщина луча:\nПо умолчанию: 2",
  416. laserParmDotted: "Параметры пунктира:\nПо умолчанию: 5,15",
  417. laserDottedOn: "Включить пунктир?",
  418. rightOptionsTitle: "Опции",
  419. selectAll: "Выбрать все",
  420. deselectAll: "Убрать выделение",
  421. buttonInGame: "Кнопка в игре",
  422. buttonInGameInfo: "Показывать кнопку \"Выбрать прицел\" в игре",
  423. laserSaveSetting:"Сохранить настройки лазера?",
  424. laser: "Лазер",
  425. paletteColor: "Палитра цветов:",
  426. changeColor: "Изменить цвет/размер",
  427. applyColor: "Применить",
  428. applyColorHint: "Применить выбранный цвет и размер",
  429. resetColor: "Сбросить",
  430. resetColorHint: "Установить значение по умолчанию",
  431. resetColorAnswer:"Сбросить настройки цвета и размера?",
  432. not_selected: "Не выбран",
  433. input_colors: ["Красный","Зеленый","Синий"],
  434. error_ChangeColor: "Выберите прицел, для редактирования цвета и размера!\nНажмите на радужный кружок, возле прицелов!",
  435. scopeSize: "Размер",
  436. donate: ["Поддержка","Поддержать автора"]
  437. },
  438. en:{
  439. form_title: "Select scope",
  440. addCrosshair: "Add scope",
  441. editCrosshair: "Edit",
  442. editComplete: "The scope was edited!",
  443. editEditApply: "Apply changes",
  444. delCrosshair: "Remove scope(s)?",
  445. delComplete: "The scope(s) have been removed!",
  446. selectCrosshair: "Select: ",
  447. scopeName: "Name for the sight (opt.)",
  448. scopeLink: "Sight link (png,gif,jpg,cur,base64)",
  449. errorName: "Warning:\nthe name field is not set, a random name will be used!\nName: ",
  450. errorLinkEmpty: "The link Field is empty!",
  451. errorLink: "The link Field is incorrect!",
  452. errorImage: "The image Size is greater than 128x128 px, or equal to 0x0 px, or indefinite!",
  453. errorAdd: "Message:\nThe sight was not added due to incorrect parameters!",
  454. addComplete: "Message:\nSight was successfully added!",
  455. name: "Name: ",
  456. link: "Link: ",
  457. preview: "Preview",
  458. drawSelf: "Draw your own ",
  459. drawSelfInstructions: "File > New\nSet size <= 128px\nPaint on canvas\nSave as data URL\nCopy code and past in the Link",
  460. scopeSite: "More sights",
  461. createScope: "Create sight",
  462. alertMesImage: ["Attention:\nImage Size", "The maximum image size is 128x128px!\nOtherwise it will not work!\nIt is possible to check the sight if you look at the picture ..."],
  463. selectScope: "Select scope",
  464. form_close: "Close",
  465. resetDefault: "Load default",
  466. resetDefaultCompete: "Standard scopes have been loaded!",
  467. resetQuestion: "Do you really want to load standard scopes?\nAll your added scopes will be deleted?",
  468. resetQuestionFisrt: "Download the standard set of sights?",
  469. laserColor: "Beam color:\nDefault: red",
  470. laserWidth: "Beam width:\nDefault: 2",
  471. laserParmDotted: "Dashed Parameters:\nDefault: 5,15",
  472. laserDottedOn: "Enable dotted line?",
  473. rightOptionsTitle: "Options",
  474. selectAll: "Select All",
  475. deselectAll: "Deselect All",
  476. buttonInGame: "Button in the game",
  477. buttonInGameInfo: "Show the \"Select Sight\" button in the game",
  478. laserSaveSetting: "Save laser settings?",
  479. laser: "Laser",
  480. paletteColor: "Color palette:",
  481. changeColor: "Change color/size",
  482. applyColor: "Apply",
  483. applyColorHint: "Apply selected color and size",
  484. resetColor: "Reset",
  485. resetColorHint: "Reset to default",
  486. resetColorAnswer:"Do you want to reset the color and size settings?",
  487. not_selected: "Not selected",
  488. input_colors: ["Red", "Green", "Blue"],
  489. error_ChangeColor: "Select the scope, to edit the color and size!\nClick on the rainbow circle, near the scopes!",
  490. scopeSize: "Size",
  491. donate: ["Donate","Donate to the author"]
  492. }
  493. },
  494.  
  495. debug = false,
  496.  
  497. myVersion = GM_info.script.version,
  498.  
  499. defaultCursorImage = "https://github.com/AlekPet/Change-the-scope-to-surviv.io/raw/master/assets/images/default.png",
  500.  
  501. nav_platform = window.navigator.platform.toLowerCase(),
  502. os_var = nav_platform.indexOf("win") > -1 ? "win" : nav_platform.indexOf("mac") ? "mac" : "other"
  503.  
  504. var ObjSaveCursors = null, language = 'en-US',
  505. selLang = lang.en,
  506.  
  507. current_game = location.href.includes("zombsroyale.io")?"zombsroyale":"surviv",
  508.  
  509. game_support = {
  510. "surviv":{
  511. laser : true
  512. },
  513. "zombsroyale":{
  514. laser : false // not correct work!
  515. }
  516. }
  517.  
  518. language = window.navigator.userLanguage || window.navigator.language
  519.  
  520. if(language.includes("ru")) selLang = lang.ru
  521. if(debug) console.log("Язык:", language, selLang)
  522.  
  523. // Functions
  524. function backdec(c) {
  525. var rgbal = [],
  526. dd = c,
  527. fou = "";
  528.  
  529. if (dd.length == 7) {
  530. for (var i = 0; i < 3; i++) {
  531. var fl = [];
  532. switch (i) {
  533. case 0:
  534. fou = dd.slice(1, 3);
  535. break;
  536. case 1:
  537. fou = dd.slice(3, 5);
  538. break;
  539. case 2:
  540. fou = dd.slice(5, 7);
  541. break;
  542. }
  543. fou = fou.toLowerCase()
  544. let ris = "";
  545. for (var u = 0; u < 2; u++) {
  546. var gi = fou.charAt(u)
  547. if (gi.search(/[a-f]/ig) != -1) {
  548. switch (gi) {
  549. case "a":
  550. ris = 10;
  551. break;
  552. case "b":
  553. ris = 11;
  554. break;
  555. case "c":
  556. ris = 12;
  557. break;
  558. case "d":
  559. ris = 13;
  560. break;
  561. case "e":
  562. ris = 14;
  563. break;
  564. case "f":
  565. ris = 15;
  566. break;
  567. }
  568. } else {
  569. ris = gi
  570. }
  571. fl.push(ris)
  572. }
  573. let f = (fl[0] * Math.pow(16, 1)) + (fl[1] * Math.pow(16, 0))
  574. rgbal.push(f)
  575. }
  576. }
  577. return rgbal
  578. }
  579.  
  580. function hex(r=0,g=0,b=0) {
  581. let gf = "",
  582. hexv = "0123456789ABCDEF",
  583. rc = (typeof r == "number" && r<256 && r>=0)?Number(r):0,
  584. gc = (typeof g == "number" && g<256 && g>=0)?Number(g):0,
  585. bc = (typeof b == "number" && b<256 && b>=0)?Number(b):0,
  586. valhex = "",
  587. ff = [rc, gc, bc];
  588. for (var i = 0; i < 3; i++) {
  589. let del = ff[i] % 16,
  590. di = Math.floor(ff[i] / 16);
  591. if (ff[i] >= 255) {
  592. valhex += "FF";
  593. } else if (ff[i] <= 0) {
  594. valhex += "00";
  595. } else {
  596. valhex += hexv.charAt(di) + hexv.charAt(del);
  597. }
  598. }
  599. gf = "#" + valhex;
  600.  
  601. return gf;
  602. }
  603. // Functions end
  604.  
  605. function loadStorage(){
  606. let ObjSaveCursors_tmp = GM_getValue('ObjSaveCursors');
  607.  
  608. ObjSaveCursors = (ObjSaveCursors_tmp) ? JSON.parse(GM_getValue('ObjSaveCursors')) : {
  609. options: {
  610. firstRun: true,
  611. buttonShow: true,
  612. laserSetting:{enabled:false, color:"red", width: 2, dotted: {enabled: false, lines:"5,15"}}
  613. },
  614. cursorList:{},
  615. currentActive:null
  616. };
  617. // Доп. поля опций, если нет
  618. if(ObjSaveCursors.hasOwnProperty("options")){
  619. if(!ObjSaveCursors.options.hasOwnProperty("buttonShow")) ObjSaveCursors.options.buttonShow = true
  620. if(!ObjSaveCursors.options.hasOwnProperty("laserSetting")){
  621. ObjSaveCursors.options.laserSetting = {enabled:false, color:"red", width: 2, dotted: {enabled: false, lines:"5,15"}}
  622. }
  623. }
  624.  
  625. if(debug) console.log(ObjSaveCursors)
  626. return (ObjSaveCursors.hasOwnProperty("options") && ObjSaveCursors.options.firstRun)?true:false
  627. }
  628.  
  629. function saveToStorage(){
  630. try{
  631. var save_data = JSON.stringify(ObjSaveCursors);
  632.  
  633. if(save_data.length>0 && save_data !== null && save_data !=="" && save_data !== undefined){
  634. GM_setValue('ObjSaveCursors', save_data);
  635. if(debug) console.log("Сохраненно: ",ObjSaveCursors);
  636. }
  637. }catch(e){
  638. console.log(e);
  639. }
  640. }
  641.  
  642. function imageSizes(imgCur){
  643. let img = $("<img>")
  644. .one('load', function(){
  645. return {x:this.naturalWidth/2, y: this.naturalHeight/2}
  646. })
  647. .one('error', function(){
  648. return null
  649. }).attr('src',imgCur)
  650. }
  651.  
  652. function setGameCursor(urlCur){
  653. if(current_game == "zombsroyale"){
  654. // zombsroyale.io
  655. let x = document.getElementById("#canvas"),
  656. las = document.getElementById("linebetas")
  657. $(x).css({cursor:urlCur,transform:"scale(1.42857) !important"})
  658. $(las).css({cursor:urlCur,transform:"scale(1.42857) !important",position:"absolute",top:0,left:0})
  659. } else {
  660. // surviv.io
  661. let surv_config = detectSurviv()
  662. $(surv_config.containerGame).css({'cursor': urlCur})
  663. $(".zomb_menu-option").show()
  664. }
  665. }
  666.  
  667. function setCursor(cur = "crosshair", imgInside = null){
  668. if(debug) console.log(cur,imgInside)
  669.  
  670. let urlCur = null
  671. if(cur == "crosshair" || imgInside == null){
  672. if(debug) console.log('Равен: ', cur)
  673. urlCur = cur
  674. } else {
  675. let x = imgInside.naturalWidth/2,
  676. y = imgInside.naturalHeight/2,
  677.  
  678. set_cursor = cur.change_color && cur.change_color.src_new ? cur.change_color.src_new : cur.cururl
  679.  
  680. urlCur = 'url("'+set_cursor+'") '+x+' '+y+', crosshair'
  681.  
  682. if(debug) console.log('Применяем:', urlCur)
  683. }
  684. setGameCursor(urlCur)
  685. }
  686.  
  687. function imageCursorAim(){
  688. if(this.checked){
  689. let imagecheckActive = returnActive(),
  690. imagesrc = imagecheckActive != null && imagecheckActive.length ? imagecheckActive[0].cururl: defaultCursorImage,
  691. $img = $("<img>").one('load', function(){
  692.  
  693. $(this).data('coord',{x:this.width/2, y: this.height/2})
  694.  
  695. }).attr({'src':imagesrc,'id':'image_aim'})
  696. $("body").append($img)
  697.  
  698. $(document).mousemove(function(event) {
  699. let imgData = $img.data('coord')
  700. if(typeof imgData.x == 'number'){
  701. let x=event.pageX+1,//-imgData.x-1,
  702. y=event.pageY+1//-imgData.y-1
  703.  
  704. $img.css({
  705. "top": y + "px",
  706. "left": x +"px"
  707. });
  708. }
  709. })
  710.  
  711. } else {
  712. $(document).off('mousemove')
  713. $("#image_aim").remove()
  714. $(document).mousemove = null
  715. }
  716. }
  717.  
  718. function loadDefaultScopes(firststart = false){
  719. if(confirm(!firststart?selLang.resetQuestion:selLang.resetQuestionFisrt)){
  720. let fileScopes = GM_getResourceText('scopes')
  721. if(fileScopes.length){
  722. let convertJSON = JSON.parse(fileScopes).scopes
  723. if(ObjSaveCursors.hasOwnProperty("cursorList")){
  724. ObjSaveCursors.cursorList = convertJSON;
  725. saveToStorage()
  726. alert(selLang.resetDefaultCompete)
  727. updatePanel()
  728. }
  729. }
  730. }
  731. }
  732.  
  733. function makeCnavas(canv){
  734. if(current_game == "surviv"){
  735. let $canvas = $("#linebetas"),
  736. $cvs = $(canv),
  737. ctx
  738. if($canvas.length == 0){
  739. $canvas = $('<canvas>').
  740. css({
  741. position: 'absolute',
  742. top: 0,
  743. left: 0
  744. })
  745. .attr({
  746. id:'linebetas',
  747. width: parseInt($cvs.attr('width'),10),
  748. height: parseInt($cvs.attr('height'),10)
  749. })
  750.  
  751. $canvas.click(null)
  752. $canvas.insertAfter($cvs)
  753. }
  754. if($canvas.get(0).getContext('2d')){
  755. $canvas = $canvas.get(0)
  756. ctx = $canvas.getContext('2d')
  757. $cvs = $cvs.get(0)
  758. return {ctx: ctx, canvas: $canvas, cvs: $cvs}
  759. }
  760. } else {
  761. let canvas = document.getElementById("linebetas"),
  762. cvs = document.getElementById("#canvas"),
  763. ctx
  764. if(!canvas){
  765. canvas = document.createElement('canvas')
  766. canvas.setAttribute("style", "display:none;position:absolute;top:0;left:0;transform:scale(1.42857) !important;")
  767. canvas.id="linebetas"
  768. canvas.width=1920
  769. canvas.height=531
  770. cvs.parentNode.insertBefore(canvas, cvs.nextSibling)
  771. }
  772. if(canvas.getContext('2d')){
  773. ctx = canvas.getContext('2d')
  774. return {ctx: ctx, canvas: canvas, cvs: cvs}
  775. }
  776. }
  777. return null
  778. }
  779.  
  780. var mouse_pos = {x:0, y:0}, ticker_frame
  781. $(document).mousemove(function(event){
  782. mouse_pos = {x:event.pageX, y:event.pageY}
  783. })
  784.  
  785. function laserUpdate(params, color, widthLine, dotted){
  786. let w = params.canvas.width,
  787. h = params.canvas.height
  788. $(params.canvas).attr({'width': params.cvs.width, 'height': params.cvs.height})
  789. params.ctx.beginPath()
  790. if(dotted != null) params.ctx.setLineDash(dotted);
  791. params.ctx.strokeStyle=color
  792. params.ctx.lineWidth=widthLine
  793. params.ctx.moveTo(w/2,h/2)
  794.  
  795. let posXY = current_game == "zombsroyale" ? {x:mouse_pos.x/1.42857, y:mouse_pos.y/1.42857} : {x:mouse_pos.x, y:mouse_pos.y}
  796.  
  797. os_var == "win" ? params.ctx.lineTo(posXY.x, posXY.y) : os_var == "mac" ? params.ctx.lineTo(2*posXY.x, 2*posXY.y) : params.ctx.lineTo(posXY.x, posXY.y)
  798. params.ctx.stroke();
  799.  
  800. let surv_conf = detectSurviv()
  801. if(current_game == 'surviv' && ticker_frame.work && ['surviv.io', 'suroi.io', 'survev.io','suroi.fpsgo.net'].includes(surv_conf.game)) {
  802.  
  803. ticker_frame(function(){
  804. laserUpdate(params, color, widthLine, dotted)
  805. });
  806. }
  807.  
  808. // Engine not PIXI JS
  809. if(current_game != 'surviv' && ticker_frame.work) {
  810. ticker_frame(function(){
  811. laserUpdate(params, color, widthLine, dotted)
  812. });
  813. }
  814. }
  815.  
  816. function stop_ticker(){
  817. if(debug) console.log("Timer stop!", "Ticker:", ticker_frame, "Laser support:", game_support[current_game].laser)
  818. if(ticker_frame && game_support[current_game].laser){
  819.  
  820. if(current_game == 'surviv'){
  821. ticker_frame.stop();
  822. } else {
  823. const cancel_ticket = window.cancelAnimationFrame || window.mozCancelAnimationFrame
  824. ticker_frame.work = false
  825. cancel_ticket(ticker_frame)
  826. }
  827. }
  828. }
  829.  
  830. function betaLine(color = "red", widthLine = 2, dotted = null){
  831. let surv_config = detectSurviv(),
  832. params = makeCnavas(surv_config.canvas_game)
  833. if(['suroi.io','suroi.fpsgo.net'].includes(surv_config.game)) params.canvas.style.zIndex = 1
  834.  
  835. if(params){
  836. if(current_game == 'surviv' && surv_config.game == 'surviv.io'){ // surviv PIXI JS
  837. ticker_frame = new PIXI.ticker.Ticker();
  838. ticker_frame.stop();
  839. ticker_frame.add(function(deltaTime){
  840. laserUpdate(params, color, widthLine, dotted)
  841. });
  842. ticker_frame.start();
  843. } else { // zombsroyale Unity and suroi.io
  844. ticker_frame = window.requestAnimationFrame || window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame || window.msRequestAnimationFrame;
  845. ticker_frame.work = true;
  846. ticker_frame(function(){
  847. laserUpdate(params, color, widthLine, dotted)
  848. });
  849. /* Old version update mouse move
  850. $(document).mousemove(function(event){
  851. let w = params.canvas.width,
  852. h = params.canvas.height
  853. $(params.canvas).attr({'width': params.cvs.width, 'height': params.cvs.height})
  854. params.ctx.beginPath()
  855. if(dotted != null) params.ctx.setLineDash(dotted);
  856. params.ctx.strokeStyle=color
  857. params.ctx.lineWidth=widthLine
  858. params.ctx.moveTo(w/2,h/2)
  859.  
  860. let posXY = current_game == "zombsroyale" ? {x:event.pageX/1.42857, y:event.pageY/1.42857} : {x:event.pageX, y:event.pageY}
  861.  
  862. os_var == "win" ? params.ctx.lineTo(posXY.x, posXY.y) : os_var == "mac" ? params.ctx.lineTo(2*posXY.x, 2*posXY.y) : params.ctx.lineTo(posXY.x, posXY.y)
  863. params.ctx.stroke();
  864. })*/
  865. }
  866. }
  867. }
  868.  
  869. function selectAllScopes(){
  870. let selectedClass = this.className == 'selectedall' ? true : false
  871.  
  872. this.innerText = selectedClass ? selLang.deselectAll : selLang.selectAll
  873.  
  874. $(".list_cur input.checkbox_del_cur").each(function(){
  875. this.checked = selectedClass
  876. })
  877. $(".checkbox_del_cur:checked").length ? $(".del_cur").fadeIn('slow').css("display","inline-block").text(`Удалить [${$(".checkbox_del_cur:checked").length}]`):$(".del_cur").fadeOut('slow')
  878. }
  879.  
  880. // zombsroyale.io
  881. function checkCursorStartup(){
  882. if(debug) console.log("Game state:",game.currentGameState)
  883. //if(document.getElementsByTagName("canvas")[0].style.cursor.indexOf("data:image/cur") != -1){
  884. let states = ["MainMenu","Dead","loading","UiLoadingOverlay","UiGameOver","UiSpectator","UiPatchNotesOverlay","UiLoginOverlay","UiSettingsOverlay","UiConfirmOverlay","UiMapOverlay","UiSeasonOverlay","UiChallengesOverlay","UiLeaveOverlay","VideoAd","Profile","Cosmetics","Shop","Friends","Leaderboards"]
  885. if(game_support[current_game].laser && game.currentGameState && states.indexOf(game.currentGameState)<0){
  886. $("#linebetas").show()
  887. // $(".zomb_btn-red").show()
  888. } else {
  889. $("#linebetas").hide()
  890. }
  891. }
  892.  
  893. function detectSurviv(){
  894. const default_surviv = {
  895. containerGame: "#game-area-wrapper",
  896. containerMenu: ".btn-battle-container",
  897. game: "surviv.io",
  898. canvas_game: "#cvs",
  899. buttonStyleGame: {
  900. "font-size": "0.7em",
  901. "position": "fixed",
  902. "top": "0",
  903. "left": "5px",
  904. "width": "80px",
  905. "height": "20px",
  906. "line-height": "1.5",
  907. "opacity": "0.7",
  908. "z-index": "5",
  909. "display": ObjSaveCursors.options.buttonShow ? "block" : "none"
  910. }}
  911.  
  912. let surviv_conf = default_surviv
  913.  
  914. if(['suroi.io', 'suroi.fpsgo.net'].includes(location.host)){
  915. Object.assign(surviv_conf, {
  916. containerGame: "#game-ui",
  917. containerMenu:"#splash-ui",
  918. game: location.host,
  919. canvas_game: 'canvas:not(#canvasChangeColor)',
  920. buttonStyleGame: {
  921. "font-size": "0.7em",
  922. "position": "fixed",
  923. "top": "0",
  924. "left": "0",
  925. "height": "20px",
  926. "line-height": "1.5",
  927. "opacity": "0.7",
  928. "z-index": "50",
  929. "padding:": "2px",
  930. "text-decoration": "none",
  931. "color":"white",
  932. "margin-top": "0",
  933. "cursor":"pointer",
  934. "display": ObjSaveCursors.options.buttonShow ? "block" : "none"
  935. }})
  936. }
  937.  
  938. if(location.host == 'survev.io'){
  939. Object.assign(surviv_conf, {
  940. containerGame: "#game-area-wrapper",
  941. containerMenu:".play-button-container",
  942. game: "survev.io",
  943. canvas_game: "#cvs",
  944. buttonStyleGame: {
  945. "font-size": "0.7em",
  946. "position": "fixed",
  947. "top": "0",
  948. "left": "5px",
  949. "width": "100px",
  950. "height": "20px",
  951. "line-height": "1.5",
  952. "opacity": "0.7",
  953. "z-index": "5",
  954. "display": ObjSaveCursors.options.buttonShow ? "block" : "none"
  955. }})
  956. }
  957. return surviv_conf
  958. }
  959.  
  960. function setZindex(){
  961. ["#server-select-container","#skin-container","#left-joystick-container","#right-joystick-container","#top-left-container","#scopes-container","#action-container","#weapon-ammo-container","#adrenaline-bar-container","#health-bar-container","#killstreak-indicator-container","#spectating-buttons-container","#items-container","#healing-items-container","#ammo-container","#equipment-container","#weapons-container","#settings-tabs-container","#customize-tabs-container","#settings-menu","#game-ui","#splash-ui"].forEach((selector, indx)=>{
  962. $(selector).css("z-index", indx+2)
  963. })
  964. }
  965.  
  966. function makeMenuButton(firststart = false){
  967. let $openSelectCur = null
  968.  
  969. if(current_game == "zombsroyale"){
  970. // zombsroyale.io
  971. $openSelectCur = $('<a class="zomb_btn-red zomb_btn-darken zomb_menu-option">'+selLang.selectScope+'</a>').click(function(){
  972. if(firststart && ObjSaveCursors.options.firstRun) {
  973. if(debug) console.log("Прицелы не найдены, загрузить стандартные!")
  974. loadDefaultScopes(firststart)
  975.  
  976. ObjSaveCursors.options.firstRun = false
  977. saveToStorage()
  978. }
  979. $(".mPanel_cur").fadeToggle('slow')
  980. })
  981. $openSelectCur.insertAfter(".canvas-loading")
  982. setInterval(checkCursorStartup, 1000);
  983. } else {
  984. // surviv.io
  985. let surv_config = detectSurviv()
  986.  
  987. $openSelectCur = $('<a class="btn-green btn-darken menu-option">'+selLang.selectScope+'</a>')
  988. .css({
  989. "background": "#af5050",
  990. "border-bottom": "2px solid #7a3838",
  991. "box-shadow": "inset 0 -2px #7a3838",
  992. "margin-top": "15px"
  993. })
  994. .click(function(){
  995. if(firststart && ObjSaveCursors.options.firstRun) {
  996. if(debug) console.log("Прицелы не найдены, загрузить стандартные!")
  997. loadDefaultScopes(firststart)
  998. ObjSaveCursors.options.firstRun = false
  999. saveToStorage()
  1000. }
  1001.  
  1002. $(".mPanel_cur").fadeToggle('slow')
  1003. })
  1004. //$openSelectCur.insertAfter("#btn-start-mode-0")
  1005. $openSelectCur.insertAfter(surv_config.containerMenu)
  1006. if(surv_config.game = 'suroi.io'){
  1007. $openSelectCur.css(surv_config.buttonStyleGame)
  1008. setZindex()
  1009. }
  1010.  
  1011. $(surv_config.containerGame).append($openSelectCur.clone(true).css(surv_config.buttonStyleGame).attr("id","buttonInGame"))
  1012.  
  1013. $(".menu-block").css("max-height", "375px")
  1014. }
  1015. }
  1016.  
  1017. function makePanel(firststart){
  1018. let $mPanel = $("<div class='mPanel_cur'>"+
  1019. "<div class='mPanel_cur_title'>"+selLang.form_title+" v"+myVersion+"<div style='cursor:pointer;' title='"+selLang.form_close+"'>X</div></div>"+
  1020. "<div class='table_box'>"+
  1021. "<div class='mPanel_cur_list_box'><ul class='list_cur'></ul></div>"+
  1022. "<div class='rightPanel_options'>"+
  1023. "<div class='rightPanel_options_inside'>"+
  1024. "<div class='rightPanel_options_title'>"+selLang.rightOptionsTitle+"</div>"+
  1025. "<div class='optionFiels'><a href='javascript:void(0)' title='"+selLang.selectAll+"' id='selectAlltScopes' style='color: cyan !important;font-size: 0.6em;text-decoration: none;'>"+selLang.selectAll+"</a></div>"+
  1026. "<div class='optionFiels'><a href='javascript:void(0)' title='"+selLang.resetDefault+"' id='resetDefaultScopes' style='color: cyan !important;font-size: 0.6em;text-decoration: none;'>"+selLang.resetDefault+"</a></div>"+
  1027. "<div class='optionFiels font_7'>"+selLang.buttonInGame+": <input type='checkbox'"+(ObjSaveCursors.options.buttonShow?"checked":"")+" title='"+selLang.buttonInGameInfo+"' id='buttin_scope_in_game'></div>"+
  1028. "<div class='optionFiels'>"+selLang.laser+": <input type='checkbox' title='"+selLang.laser+"' id='LineLaser' "+(game_support[current_game].laser && ObjSaveCursors.options.laserSetting.enabled?"checked":"")+ "></div>"+
  1029. "<div class='optionFiels' style='margin-top: 20%;'><div class='font_8'>"+selLang.changeColor+"</div>"+
  1030. "<div class='colorRange'>"+
  1031. "<div class='canvasColor'><div><canvas id='canvasChangeColor' style='width:auto;height:auto;'></canvas></div></div>"+
  1032. "<div style='padding:2px;'>"+selLang.paletteColor+" <input style='border: 0;background: #ffffff00;' type='color' value='' id='colorInput'></div>"+
  1033. "<span style='color:red;'>"+selLang.input_colors[0].charAt(0)+"</span>:<input type='range' max='255' min='0' class='rangeColors' style='width: 100px;' value='0' title='"+selLang.input_colors[0]+"'><br>"+
  1034. "<span style='color:green;'>"+selLang.input_colors[1].charAt(0)+"</span>:<input type='range' max='255' min='0' class='rangeColors' style='width: 100px;' value='0' title='"+selLang.input_colors[1]+"'><br>"+
  1035. "<span style='color:blue;'>"+selLang.input_colors[2].charAt(0)+"</span>:<input type='range' max='255' min='0' class='rangeColors' style='width: 100px;' value='0' title='"+selLang.input_colors[2]+"'><br>"+
  1036. "<div>"+
  1037. "<span style='color:pink;'>"+selLang.scopeSize+":</span><br><input type='range' id='rangeSize' max='128' min='1' step='1' style='width: 100px;' value='0' title='Size scope'><br><span id='rangeSizeValue'>0x0</span>"+
  1038. "</div>"+
  1039. "<div id='setChangeColor' class='cur_button colorChangeButtons' title='"+selLang.applyColorHint+"'>"+selLang.applyColor+"</div>"+
  1040. "<div id='setDefaultChangeColor' class='cur_button colorChangeButtons' title='"+selLang.resetColorHint+"'>"+selLang.resetColor+"</div>"+
  1041. "</div>"+
  1042. "</div>"+
  1043. "<div class='optionFiels'><span style='display: none'>Image aim:<input type='checkbox' id='mouseimgaim' /></span></div>"+
  1044. "</div>"+
  1045. "</div>"+
  1046. "</div>"+
  1047. "<div class='mPanel_cur_foot'>"+
  1048. "<div class='cur_sel_button_box'></div>"+
  1049. "<div class='infoBlock'>"+
  1050. "<a href='https://docs.google.com/document/d/1XTnSJoJHyQdqxPfmMYoBSyToXHKEW4QnQDAVsL9tcgU' target='_blank' style='color: yellow !important;' title='"+selLang.donate[1]+"'>"+selLang.donate[0]+"</a>"+
  1051. "<a href='https://github.com/AlekPet' target='_blank' title='AlekPet Guthub ^_^' style=''color: #56fff1 !important;''>AlekPet 2018</a>"+
  1052. "</div>"+
  1053. "</div>"+
  1054. "</div>"),
  1055. $cur_overlay = $("<div class='cur_overlay'>"),
  1056. closeX = $($mPanel).find(".mPanel_cur_title > div").click(function(){
  1057. $mPanel.fadeOut()
  1058. }),
  1059. bInG = $($mPanel).find("#buttin_scope_in_game").change(function(){
  1060. if(ObjSaveCursors.hasOwnProperty("options") && ObjSaveCursors.options.hasOwnProperty("buttonShow")){
  1061. ObjSaveCursors.options.buttonShow = this.checked
  1062. saveToStorage();
  1063. if(debug) console.log('Показывать кнопку в игре:',this.checked)
  1064. $("#buttonInGame").css("display", this.checked ? "block" : "none")
  1065. }
  1066. }),
  1067. $LineLaser = $($mPanel).find("#LineLaser").change(function(){
  1068. if(game_support[current_game].laser){
  1069. if(this.checked){
  1070. let laserSetting = ObjSaveCursors.options.laserSetting,
  1071. ls_color = laserSetting.color || "red",
  1072. ls_width = laserSetting.width || "2",
  1073. ls_dotted_lines = laserSetting.dotted.lines || "5,15",
  1074.  
  1075. color = prompt(selLang.laserColor, ls_color),
  1076. widthLine = prompt(selLang.laserWidth, ls_width),
  1077. dotted_enabled = false,
  1078. dotted = (dotted_enabled = confirm(selLang.laserDottedOn)) ? prompt(selLang.laserParmDotted, ls_dotted_lines) : null
  1079.  
  1080. // Save setting
  1081. if(confirm(selLang.laserSaveSetting)){
  1082. if(ObjSaveCursors.hasOwnProperty("options") && ObjSaveCursors.options.hasOwnProperty("laserSetting")){
  1083. ObjSaveCursors.options.laserSetting = {enabled:this.checked, color:color, width: widthLine, dotted: {enabled: dotted_enabled, lines:dotted}}
  1084. saveToStorage();
  1085. }
  1086. }
  1087.  
  1088. if(dotted != null) dotted = dotted.split(',')
  1089.  
  1090. betaLine(color,widthLine,dotted)
  1091. } else {
  1092. ObjSaveCursors.options.laserSetting.enabled = this.checked
  1093. saveToStorage();
  1094. stop_ticker();
  1095. $("#linebetas").remove()
  1096. }
  1097. } else {
  1098. this.checked = false
  1099. alert("Laser for zombsroyale is being finalized...")
  1100. }
  1101. }),
  1102. // All events click scope delegate
  1103. ListBox = $($mPanel).find(".mPanel_cur_list_box > ul").click(function(event){
  1104. var target = event.target,
  1105. elem = target
  1106.  
  1107. while(elem !== this){
  1108.  
  1109. let datas = $(elem).data("el_val") ? $(elem).data("el_val") : null
  1110.  
  1111. // Change scope
  1112. if(elem.className.includes("element_cur_cont")){
  1113. if(elem.title === "Default"){
  1114. checkActive(null)
  1115. setCursor("crosshair")
  1116. } else {
  1117. let imgInside = $(elem).find("img").get(0)
  1118. checkActive(datas)
  1119. setCursor(datas, imgInside)
  1120. }
  1121. $(".list_cur > li.acive_cursor").removeClass("acive_cursor")
  1122. $(elem).addClass("acive_cursor")
  1123. saveToStorage()
  1124. break;
  1125. }
  1126.  
  1127. // Change color scope
  1128. if(elem.className.includes("colorchange_cur")){
  1129. event.stopPropagation();
  1130. changeColor(datas)
  1131. break;
  1132. }
  1133.  
  1134. // Edit scope
  1135. if(elem.className.includes("checkbox_edit_cur")){
  1136. event.stopPropagation();
  1137. makeFormAddCursor(false, datas)
  1138. break;
  1139. }
  1140.  
  1141. elem = elem.parentNode
  1142. }
  1143. }),
  1144. $selectAll = $($mPanel).find("#selectAlltScopes").click(function(){
  1145. $(this).toggleClass("selectedall")
  1146. selectAllScopes.call(this);
  1147. }),
  1148. resetDefaultScopes = $($mPanel).find("#resetDefaultScopes").click(loadDefaultScopes),
  1149. $addCursor = $("<div class='cur_button add_cur'>").attr('title',selLang.addCrosshair).text(selLang.addCrosshair).click(makeFormAddCursor),
  1150. $delCursor = $("<div class='cur_button del_cur'>").attr('title',selLang.delCrosshair).text(selLang.addCrosshair).click(delCursor),
  1151. $cur_sel_button_box = $($mPanel).find(".cur_sel_button_box").append($addCursor,$delCursor),
  1152. $mouseimgaim = $($mPanel).find("#mouseimgaim").change(function(){
  1153. imageCursorAim.call(this)
  1154. })
  1155.  
  1156. if($LineLaser.is(":checked")){
  1157. if(game_support[current_game].laser){
  1158. let laserSetting = ObjSaveCursors.options.laserSetting,
  1159. ls_color = laserSetting.color || "red",
  1160. ls_width = laserSetting.width || "2",
  1161. ls_dotted_enabled = laserSetting.dotted.enabled || false,
  1162. ls_dotted_lines = laserSetting.dotted.lines || "5,15"
  1163.  
  1164. ls_dotted_lines =(ls_dotted_enabled && ls_dotted_lines != null)?ls_dotted_lines.split(','):null
  1165.  
  1166. betaLine(ls_color,ls_width,ls_dotted_lines)
  1167. } else {
  1168. $LineLaser.checked = false
  1169. }
  1170. }
  1171.  
  1172. $mPanel.append($cur_overlay);
  1173. $("body").append($mPanel)
  1174. }
  1175.  
  1176. function updatePanel(firststart = false){
  1177. let ListBox = $(".mPanel_cur_list_box > ul").empty(),
  1178. activeTrue = false,
  1179.  
  1180. divDef = $("<li class='element_cur_cont'>").attr('title',"Default"),
  1181. divDefTitle = $("<span class='element_cur_title'>").text("Default"),
  1182. divDefImg = $("<img width='48'>").attr("src", defaultCursorImage),
  1183. divDefImgBox = $("<div class='element_cur_title'>").append(divDefImg)
  1184.  
  1185. divDef.append(divDefImgBox,divDefTitle)
  1186. $(ListBox).append(divDef)
  1187.  
  1188. $.each(ObjSaveCursors.cursorList, function(index, el){
  1189. let self = el,
  1190. divCont = $("<li class='element_cur_cont'>").attr('title',selLang.selectCrosshair+self.name).data("el_val", self),
  1191. divTitle = $("<span class='element_cur_title'>").text(self.name.length>15?self.name.substr(0,12)+"...":self.name),
  1192. divImg = $("<img width='48'>").one('load',function(){
  1193. $(this).css("cursor","url("+this.src+")"+this.naturalWidth/2+" "+this.naturalHeight/2+", default")
  1194. }).attr("src", self.change_color ? self.change_color.src_new : self.cururl),
  1195. divImgBox = $("<div class='element_cur_title'>").append(divImg),
  1196. delCheck = $("<input class='checkbox_del_cur' type='checkbox' title='Удаление'>").click(function(event){
  1197. event.stopPropagation();
  1198. }),
  1199. editButton = $("<input type='button' class='checkbox_edit_cur' value='"+selLang.editCrosshair+"' title='"+selLang.editCrosshair+"'>").data("el_val", {element: self, index: index})
  1200.  
  1201. if(/^data:image/i.test(self.cururl)){
  1202. let colorChange = $("<div class='colorchange_cur' title='"+selLang.changeColor+"'>").data("el_val", {element: self, img: divImg, index: index})
  1203. divCont.append($("<p style='margin: 0;padding: 0;border-bottom: 1px dotted silver;'>").append(colorChange,editButton,delCheck),divImgBox,divTitle)
  1204. } else {
  1205. divCont.append($("<p style='margin: 0;padding: 0;border-bottom: 1px dotted silver;'>").append(editButton,delCheck),divImgBox,divTitle)
  1206. }
  1207. $(ListBox).append(divCont)
  1208.  
  1209. if(self.active){
  1210. activeTrue = true
  1211. $(divCont).addClass("acive_cursor")
  1212.  
  1213. divImg.one('load', function(){
  1214. setCursor(self, this)
  1215. }).one('error', function(){
  1216. setCursor()
  1217. })
  1218. }
  1219. })
  1220.  
  1221. if(firststart || !activeTrue){
  1222. $(".element_cur_cont:eq(0)").addClass("acive_cursor")
  1223. setCursor("crosshair")
  1224. }
  1225.  
  1226. $(".checkbox_del_cur").on("change",function(){
  1227. $(".checkbox_del_cur:checked").length ? $(".del_cur").fadeIn('slow').css("display","inline-block").text(`Удалить [${$(".checkbox_del_cur:checked").length}]`):$(".del_cur").fadeOut('slow')
  1228. })
  1229. }
  1230.  
  1231. function defaultValueForm(elem){
  1232. $(elem).find("#name_scope,#link_scope,#previewName,#previewImg").each(function(){
  1233. switch(this.id){
  1234. case 'name_scope':
  1235. case 'link_scope': this.value = ''
  1236. break;
  1237. case 'previewName': this.innerText='Default'
  1238. break;
  1239. case 'previewImg': this.src = defaultCursorImage
  1240. break;
  1241. }
  1242. })
  1243. $(".cur_preview").css('cursor','crosshair')
  1244. }
  1245.  
  1246. function ImgSizeData(img, val){
  1247. $(img).one('load', function(){
  1248. const w = this.naturalWidth,
  1249. h = this.naturalHeight
  1250. if(w>128 || h>128) alert(selLang.alertMesImage[0]+w+"px x "+h+"px!\n"+selLang.alertMesImage[1])
  1251. $(".cur_preview").css('cursor','url('+this.src+'), not-allowed')
  1252. if(this.src !== defaultCursorImage) $(this).data("sizes", {w:w, h:h});
  1253. else $(this).data("sizes", {w:null, h:null})
  1254. }).one('error', function(){
  1255. this.src = defaultCursorImage
  1256. $(".cur_preview").css('cursor','crosshair')
  1257. }).attr('src', val)
  1258. }
  1259.  
  1260. function makeFormAddCursor(editmake = false, params = null){
  1261. let $makeCurForm = $(".makeCursor_form"),
  1262. $cur_overlay = $(".cur_overlay")
  1263.  
  1264. if($makeCurForm.length == 0){
  1265. $makeCurForm = $("<div class='makeCursor_form'>")
  1266. let htmlInner = "<div class='makeCursor_form_title'><span>"+selLang.addCrosshair+"</span><div title='"+selLang.form_close+"'>X</div></div>"+
  1267. "<div class='maleCursor_form_body'>"+
  1268. "<div class='form_field'><span>"+selLang.name+"</span><input type='text' id='name_scope' value='' maxlength='100' placeholder='"+selLang.scopeName+"'></div>"+
  1269. "<div class='form_field'><span>"+selLang.link+"</span><input type='text' id='link_scope' value='' placeholder='"+selLang.scopeLink+"'></div>"+
  1270. "<div class='cur_preview'><p>"+selLang.preview+"</p><img id='previewImg' src='"+defaultCursorImage+"' width='45'><div style='word-break: break-all;' id='previewName'>Default</div></div>"+
  1271. "<div class='drawSelf' title='"+selLang.drawSelfInstructions+"'>"+selLang.drawSelf+"<a target='_blank' href='http://viliusle.github.io/miniPaint/' style='color:blue'>miniPaint</a><br>"+
  1272. "<a target='_blank' title='"+selLang.scopeSite+"' style='color:red' href='https://thenounproject.com/search/?q=crosshairs'>"+selLang.scopeSite+"</a></div>"+
  1273. "</div>"+
  1274. "<div class='maleCursor_form_foot'>"+
  1275. "<div class='cur_button create_cur' id='createCursor' title='"+selLang.createScope+"'>"+selLang.createScope+"</div>"+
  1276. "</div>"
  1277.  
  1278. $makeCurForm.html(htmlInner)
  1279.  
  1280. $(".mPanel_cur").append($makeCurForm)
  1281.  
  1282. $(".makeCursor_form_title > div").click(function(){
  1283. $makeCurForm.fadeOut('slow', function(){
  1284. $cur_overlay.fadeOut('slow', function(){
  1285. defaultValueForm($makeCurForm)
  1286. })
  1287. })
  1288. })
  1289.  
  1290. $("#name_scope").on('input', function(){
  1291. $("#previewName").text($(this).val())
  1292. })
  1293. $("#link_scope").on('input', function(){
  1294. let val = $(this).val().trim()
  1295. ImgSizeData("#previewImg", val)
  1296. })
  1297. }
  1298. // Show form
  1299. $cur_overlay.fadeIn('slow', function(){
  1300. if(editmake){
  1301. $(".makeCursor_form_title > span").text(selLang.addCrosshair)
  1302. $("#createCursor").text(selLang.createScope).off().click(function(){
  1303. add_edit_Cursor()
  1304. })
  1305. } else {
  1306. $(".makeCursor_form_title > span").text(selLang.editCrosshair)
  1307.  
  1308. $makeCurForm.find("#name_scope").val(params.element.name)
  1309. $makeCurForm.find("#link_scope").val(params.element.cururl)
  1310. ImgSizeData("#previewImg", params.element.cururl)
  1311.  
  1312. $("#createCursor").text(selLang.editEditApply).off().click(function(){
  1313. if(params !== null && Object.keys(params).length) add_edit_Cursor(params)
  1314. })
  1315. }
  1316. $makeCurForm.fadeIn('fast')
  1317. })
  1318. }
  1319.  
  1320. function add_edit_Cursor(parametri = null){
  1321. let $makeCurForm = $(".makeCursor_form"),
  1322. $cursorName = $makeCurForm.find("#name_scope"),
  1323. $cursorUrl = $makeCurForm.find("#link_scope"),
  1324. $cur_overlay = $(".cur_overlay"),
  1325.  
  1326. $previewImg = $makeCurForm.find("#previewImg")
  1327.  
  1328. let cursorNameVal = $cursorName.val(),
  1329. cursorUrlVal = $cursorUrl.val(),
  1330. errors = false
  1331.  
  1332. if(/^\s*$/i.test(cursorNameVal)){
  1333. cursorNameVal="Croshair_"+Math.floor(Math.random()*10000)
  1334. $cursorName.val(cursorNameVal)
  1335. alert(selLang.errorName+cursorNameVal)
  1336. }
  1337.  
  1338. if(/^\s*$/i.test(cursorUrlVal)){
  1339. alert(selLang.errorLinkEmpty)
  1340. errors = true
  1341. }
  1342.  
  1343. if(!/(?:^https?:\/\/.*\.(?:png|jpg|jpeg|gif|cur|tiff)$|^data:image)/i.test(cursorUrlVal)){
  1344. alert(selLang.errorLink)
  1345. errors = true
  1346. }
  1347.  
  1348. if(!errors){
  1349. const w = $previewImg.data("sizes").w || 0,
  1350. h = $previewImg.data("sizes").h || 0
  1351.  
  1352. if(w>128 || h>128 || w == 0 || h == 0 || w == null || h == null){
  1353. alert(selLang.errorImage)
  1354. errors = true
  1355. }
  1356. }
  1357.  
  1358. if(errors){
  1359. alert(selLang.errorAdd)
  1360. return
  1361. }
  1362.  
  1363. if(ObjSaveCursors.hasOwnProperty("cursorList")){
  1364. let ovetMessage = selLang.addComplete
  1365. if(parametri == null){
  1366. ObjSaveCursors.cursorList.push({name:cursorNameVal, cururl:cursorUrlVal, active:false})
  1367. } else {
  1368. if(Object.keys(ObjSaveCursors.cursorList).length && Object.keys(parametri).length){
  1369. ObjSaveCursors.cursorList[parametri.index] = {name:cursorNameVal, cururl:cursorUrlVal, active:false}
  1370. ovetMessage = selLang.editComplete
  1371. } else return
  1372. }
  1373.  
  1374. saveToStorage()
  1375.  
  1376. $makeCurForm.fadeOut('slow', function(){
  1377. $cur_overlay.fadeOut('slow', function(){
  1378. defaultValueForm($makeCurForm)
  1379. })
  1380. })
  1381.  
  1382. updatePanel()
  1383. alert(ovetMessage)
  1384.  
  1385. }
  1386. }
  1387.  
  1388. function returnActive(){
  1389. let activetrue = null
  1390. if(ObjSaveCursors.hasOwnProperty("cursorList") && Object.keys(ObjSaveCursors.cursorList).length){
  1391. activetrue = ObjSaveCursors.cursorList.filter((ix,elem)=>{
  1392. return ix.active == true
  1393. })
  1394. return activetrue
  1395. }
  1396. }
  1397.  
  1398. function checkActive(el){
  1399. if(ObjSaveCursors.hasOwnProperty("cursorList") && Object.keys(ObjSaveCursors.cursorList).length){
  1400. ObjSaveCursors.cursorList.map((ix,elem)=>{
  1401. ix.active = false
  1402. return ix.active
  1403. })
  1404. if(el !== null ) el.active = true
  1405. }
  1406. }
  1407.  
  1408. function delCursor(){
  1409. if(confirm(selLang.delCrosshair)){
  1410. let arr_delete_cursors = []
  1411. $(".list_cur").find("input[type=checkbox]").each(function(index,eleme){
  1412. if($(this).is(':checked')){
  1413. arr_delete_cursors.push(index);
  1414. }
  1415. });
  1416. arr_delete_cursors = arr_delete_cursors.reverse();
  1417. for(var k in arr_delete_cursors){
  1418. ObjSaveCursors.cursorList.splice(arr_delete_cursors[k],1);
  1419. }
  1420. saveToStorage()
  1421. $(".del_cur").fadeOut('slow')
  1422. updatePanel()
  1423. alert(selLang.delComplete)
  1424. }
  1425. }
  1426.  
  1427. function resize(valS){
  1428. let canvas = document.getElementById("canvasChangeColor"),
  1429. ctx = canvas.getContext("2d")
  1430.  
  1431. $("<img>").one("load", function() {
  1432. var oc = document.createElement('canvas'),
  1433. octx = oc.getContext('2d');
  1434.  
  1435. if(this.naturalWidth >= this.naturalHeight){
  1436. canvas.width = valS;
  1437. canvas.height = canvas.width * this.naturalHeight / this.naturalWidth;
  1438. } else if(this.naturalWidth < this.naturalHeight){
  1439. canvas.width = canvas.height * this.naturalWidth / this.naturalHeight;
  1440. canvas.height = valS;
  1441. }
  1442. ctx.drawImage(this, 0, 0, canvas.width, canvas.height);
  1443. $("#rangeSizeValue").text(canvas.width+"x"+canvas.height)
  1444. }).attr('src', $("#canvasChangeColor").data("imagesrc"))
  1445. }
  1446.  
  1447. function setSizeParams(can){
  1448. $("#rangeSize").val(can.width >= can.height ? can.width : can.height)
  1449. $("#rangeSizeValue").text(can.width+"x"+can.height)
  1450. }
  1451.  
  1452. function setColorsScope(){
  1453. let can = document.getElementById("canvasChangeColor"),
  1454. ctx = can.getContext("2d"),
  1455. imgData = ctx.getImageData(0, 0, can.width, can.height),
  1456. eli = document.getElementsByClassName("rangeColors"),
  1457. r = parseInt(eli[0].value),
  1458. g = parseInt(eli[1].value),
  1459. b = parseInt(eli[2].value),
  1460. a = 255
  1461.  
  1462. document.getElementById("colorInput").value = hex(r,g,b)
  1463.  
  1464. for (var i = 0; i < imgData.data.length; i += 4) {
  1465.  
  1466. imgData.data[i] = r; //r
  1467. imgData.data[i + 1] = g; //g
  1468. imgData.data[i + 2] = b; //b
  1469. //imgData.data[i + 3] = a; // alpha
  1470. }
  1471. ctx.putImageData(imgData, 0, 0);
  1472. $.data(can, "imagesrc", can.toDataURL("image/png"))
  1473. }
  1474.  
  1475. function setChangeColor(params){
  1476. const eli = document.getElementsByClassName("rangeColors"),
  1477. size = parseInt(document.getElementById("rangeSize").value),
  1478. r=parseInt(eli[0].value),
  1479. g=parseInt(eli[1].value),
  1480. b=parseInt(eli[2].value),
  1481. a = 255,
  1482. canvas = document.getElementById("canvasChangeColor")
  1483.  
  1484. if(Object.keys(ObjSaveCursors.cursorList[params.index]).length && canvas){
  1485. if(!ObjSaveCursors.cursorList[params.index].hasOwnProperty('change_color')){
  1486. ObjSaveCursors.cursorList[params.index].change_color = {colors:{r:r,g:g,b:b,a:a,size:size}, src_new: canvas.toDataURL("image/png")}
  1487. } else {
  1488. ObjSaveCursors.cursorList[params.index].change_color = {colors:{r:r,g:g,b:b,a:a,size:size}, src_new: canvas.toDataURL("image/png")}
  1489. }
  1490. if(debug) console.log("Цвета:",ObjSaveCursors.cursorList[params.index]);
  1491. saveToStorage();
  1492. updatePanel();
  1493. } else alert("Object not found, or canvas not isset!");
  1494. }
  1495.  
  1496. function setDefaultCursorColors(params){
  1497. if(params.element.hasOwnProperty("change_color") && Object.keys(params.element.change_color).length && params.element.change_color.hasOwnProperty("src_new")){
  1498. if(confirm(selLang.resetColorAnswer)){
  1499. delete ObjSaveCursors.cursorList[params.index].change_color
  1500. saveToStorage();
  1501. updatePanel();
  1502. new Array().slice.call(document.getElementsByClassName("rangeColors")).forEach(function(el){el.value = 0})
  1503. document.getElementById("colorInput").value = "#000000";
  1504. params.img.attr('src',params.element.cururl)
  1505. changeColor(params)
  1506. }
  1507. }
  1508. }
  1509.  
  1510. function changeColor(params = null){
  1511. let can, ctx,img, colorInput
  1512.  
  1513. can = document.getElementById("canvasChangeColor")
  1514. ctx = can.getContext("2d")
  1515. colorInput = document.getElementById("colorInput")
  1516.  
  1517. if(params != null && Object.keys(params).length){
  1518.  
  1519. if(params.element.change_color && Object.keys(params.element.change_color.colors).length){
  1520. let colors = params.element.change_color.colors,
  1521. a = colors.a,
  1522. inptuts_colors = document.getElementsByClassName("rangeColors")
  1523. inptuts_colors[0].value = colors.r
  1524. inptuts_colors[1].value = colors.g
  1525. inptuts_colors[2].value = colors.b
  1526. colorInput.value = hex(colors.r,colors.g,colors.b)
  1527. $("#rangeSize").data("sizeval",colors.size)
  1528. } else {
  1529. new Array().slice.call(document.getElementsByClassName("rangeColors")).forEach(function(el){el.value = 0})
  1530. colorInput.value = "#000000";
  1531. }
  1532.  
  1533. img = new Image()
  1534. img.onload = function() {
  1535. can.width = this.naturalWidth
  1536. can.height = this.naturalHeight
  1537. ctx.drawImage(this, 0, 0)
  1538.  
  1539. $.data(can, "imagesrc", this.src)
  1540. setSizeParams(can)
  1541. }
  1542. img.src = params.img.attr('src')
  1543.  
  1544. $("#setChangeColor").off().click(setChangeColor.bind(ctx, params))
  1545. $("#setDefaultChangeColor").off().click(setDefaultCursorColors.bind(ctx, params))
  1546.  
  1547. } else {
  1548. can.width = 80
  1549. can.height = 80
  1550. ctx.font="10px Georgia";
  1551. ctx.textAlign="center";
  1552. ctx.fillStyle = "white";
  1553. ctx.fillText(selLang.not_selected.toUpperCase(),can.width/2,can.height/2);
  1554.  
  1555. let eli = document.getElementsByClassName("rangeColors")
  1556. for (let i = 0; i < eli.length; i++) {
  1557. eli[i].addEventListener("input", setColorsScope)
  1558. }
  1559.  
  1560. let boxcolor = document.getElementById("colorInput").addEventListener("input", function(){
  1561. let curColor = this.value,
  1562. digitColor = backdec(curColor)
  1563. eli[0].value = digitColor[0]
  1564. eli[1].value = digitColor[1]
  1565. eli[2].value = digitColor[2]
  1566. colorInput.value = hex(digitColor[0],digitColor[1],digitColor[2])
  1567. setColorsScope()
  1568. })
  1569.  
  1570. // Size
  1571. $("#rangeSize").on("input", function(){
  1572. resize(this.value)
  1573. })
  1574.  
  1575. $("#setChangeColor").add($("#setDefaultChangeColor")).off().click(function(){
  1576. alert(selLang.error_ChangeColor)
  1577. })
  1578. }
  1579. }
  1580.  
  1581. function init(){
  1582. let firststart = false;
  1583. if(loadStorage()){
  1584. firststart = true
  1585. if(debug) console.log("Первый запуск!", firststart)
  1586. }
  1587. console.log("Current game: ", current_game, "Laser support:", game_support[current_game].laser)
  1588. makeMenuButton(firststart)
  1589. makePanel()
  1590. updatePanel(firststart)
  1591. changeColor()
  1592. }
  1593. window.onload = function(){
  1594. init()
  1595. }
  1596. })();