Advertisement
Guest User

Untitled

a guest
Sep 20th, 2019
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 24.78 KB | None | 0 0
  1. ===================================================================
  2. --- Current Version
  3. +++ New Version
  4. @@ -1,446 +1,7 @@
  5. // ==UserScript==
  6. // @name Christmas Town 2018
  7. // @namespace mafia.christmas
  8. // @author Mafia[610357]
  9. -// @description Notification for items near you in christmas town map
  10. -// @match https://www.torn.com/christmas_town.php
  11. -// @version 2018.29
  12. -// @require http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js
  13. -// @require https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment.min.js
  14. -// @require https://greasyfork.org/scripts/39572/code/mafia-helper.js
  15. -// @require https://greasyfork.org/scripts/375903/code/wshook.js
  16. -// @require https://greasyfork.org/scripts/375735/code/achex.js
  17. -// @grant none
  18. -// @run-at document-start
  19. -// ==/UserScript==
  20. -
  21. -'use strict';
  22. -
  23. -var ct = JSON.parse(localStorage.ct || '{}');
  24. -
  25. -if(typeof ct.user == 'undefined') {
  26. - $(document).ready(function() {
  27. - uid = $("script[src*='js/chat/chat']").attr("uid");
  28. - name = $("script[src*='js/chat/chat']").attr("name");
  29. - ct.user = name + "[" + uid + "]";
  30. - localStorage.ct = JSON.stringify(ct);
  31. -
  32. - alert('Initializing CT 2018 script. Press OK to reload page.');
  33. - location.reload();
  34. - });
  35. -}
  36. -else {
  37. - var npcs = ['Grinch','Santa'];
  38. - wsHook.after = function(messageEvent, url) {
  39. - obj = JSON.parse(messageEvent.data);
  40. - if(url.indexOf('websocket') !== -1) {
  41. - if(obj.body.hasOwnProperty('data')) {
  42. - if(obj.body.data.message.action == "openChest") {
  43. - $("#ctchest li#" + obj.body.data.message.hash).attr("class","chestOpened").removeAttr("id").find(".cttime").text(obj.body.data.message.user.playername+" has unlocked a chest")
  44. - .closest("li").fadeOut(7000, function(){
  45. - $(this).remove();
  46. - if(!$("#ctchest ul li").length)
  47. - $("#ctchest ul").before('<p>No chest found at a moment.</p>');
  48. - });
  49. - }
  50. - }
  51. -
  52. - }
  53. - if(url.indexOf('chat') !== -1) {
  54. - if(obj.hasOwnProperty('data')) {
  55. - s = obj.proc;
  56. - if(s == "people/faction" || s == "people/friends") {
  57. - if(typeof ct[s.substr(s.indexOf("/")+1)] == 'undefined') ct[s.substr(s.indexOf("/")+1)] = [];
  58. - ct[s.substr(s.indexOf("/")+1)] = [];
  59. - $.each(obj.data, function(){
  60. - ct[s.substr(s.indexOf("/")+1)].push(parseInt(this.Id));
  61. - });
  62. - localStorage.ct = JSON.stringify(ct);
  63. - }
  64. - }
  65. - }
  66. - return messageEvent;
  67. - }
  68. -
  69. -
  70. - $.achex({
  71. - facebook: false,
  72. - username: ct.user,
  73. - password: 'none',
  74. - url: 'wss://ws.achex.ca',
  75. - port: 443,
  76. - reconnect: 3000,
  77. - callback: function(o, d, e)
  78. - {
  79. - var o = o;
  80. - if(o.type == "NPC" && npcs.indexOf(o.npcName) != -1) {
  81. - if($("#ctnpc p").length) $("#ctnpc p").remove();
  82. - if($("#npc"+o.npcName).length){
  83. - $("#npc"+o.npcName+" span:eq(0)").html(o.npcName + ' at <strong>' + o.x + ',' + o.y + '</strong>');
  84. - $("#npc"+o.npcName+" .cttime").attr("by", moment().unix());
  85. - }
  86. - else {
  87. - $("#ctnpc ul").append('<li id="npc'+o.npcName+'"><img src="/images/v2/christmas_town/users/new/'+o.npcName.toLowerCase()+'.png"/> <div><span>' + o.npcName + ' at <strong>' + o.x + ',' + o.y + '</strong></span><br/><span class="cttime" by="'+moment().unix()+'">a few seconds ago</span></div><div class="clear"></div></li>');
  88. - setInterval(() => {
  89. - $("#npc" + o.npcName + " .cttime").text(moment.unix(parseInt($("#npc" + o.npcName + " .cttime").attr("by"))).fromNow());
  90. - }, 5000);
  91. - }
  92. - }
  93. - if(o.type == "CTitems" && (o.itemID > 0 && o.itemID < 5)) {
  94. - switch (o.itemID) {
  95. - case 1:
  96. - if(o.itemName == "wooden" && o.ctID == "chests.1") {
  97. - o.itemName = "Wooden";
  98. - valid = true;
  99. - }
  100. - break;
  101. - case 2:
  102. - if(o.itemName == "bronze" && o.ctID == "chests.2") {
  103. - o.itemName = "Bronze";
  104. - valid = true;
  105. - }
  106. - break;
  107. - case 3:
  108. - if(o.itemName == "silver" && o.ctID == "chests.3") {
  109. - o.itemName = "Silver";
  110. - valid = true;
  111. - }
  112. - break;
  113. - case 4:
  114. - if(o.itemName == "golden" && o.ctID == "chests.4") {
  115. - o.itemName = "Golden";
  116. - valid = true;
  117. - }
  118. - break;
  119. - default:
  120. - valid= false;
  121. - break;
  122. - }
  123. -
  124. - if(valid) {
  125. - if($("#ctchest p").length) $("#ctchest p").remove();
  126. - if(!$(".chest" + o.x + '_' + o.y).length) {
  127. - $("#ctchest ul").prepend("<li id='"+o.hash+"' class='chest"+o.x+"_"+o.y+"'><img src='/images/items/christmas_town/chests/"+o.ctID.replace(/\./g,'-')+".png'/> <div><span>" + o.itemName + " Chest</spantext-transform:> at <strong>" + o.x + ',' + o.y + "</strong><br/><span class='cttime' by='"+moment().unix()+"'>Now</span></div><div class='clear'></div></li>");
  128. - setInterval(() => {
  129. - diff = (moment().unix() - parseInt($(".chest"+o.x+"_"+o.y+" .cttime").attr("by")));
  130. - $(".chest"+o.x+"_"+o.y+" .cttime").text(diff <= 5 ? 'Now' : diff + ' seconds ago');
  131. - if(moment().unix() - parseInt($(".chest"+o.x+"_"+o.y+" .cttime").attr("by")) > 45) {
  132. - $(".chest"+o.x+"_"+o.y).fadeOut(15000,function(){
  133. - $(".chest"+o.x+"_"+o.y).remove();
  134. - if(!$("#ctchest ul li").length)
  135. - $("#ctchest ul").before('<p>No chest found at a moment.</p>');
  136. - });
  137. - }
  138. - }, 1000);
  139. - }
  140. - else {
  141. - $(".chest"+o.x+"_"+o.y).stop(true, true).show();
  142. - $(".chest"+o.x+"_"+o.y+" .cttime").attr("by", moment().unix());
  143. - if($(".chest"+o.x+"_"+o.y).attr("id") == 'undefined')
  144. - $(".chest"+o.x+"_"+o.y).attr("id", o.hash);
  145. - }
  146. - }
  147. - }
  148. -
  149. - if(o.type == "openChest" || o.type == "openChest2") {
  150. - unlocker = o.type == "openChest" ? o.FROM.substr(0,o.FROM.indexOf('[')) : "Someone";
  151. - $("#ctchest li#" + o.hash).attr("class","chestOpened").removeAttr("id").find(".cttime").text(unlocker+" has unlocked a chest")
  152. - .closest("li").fadeOut(7000, function(){
  153. - $(this).remove();
  154. - if(!$("#ctchest ul li").length)
  155. - $("#ctchest ul").before('<p>No chest found at a moment.</p>');
  156. - });
  157. - }
  158. - }
  159. - });
  160. - $.achex.join('CT2018');
  161. -
  162. - var $achex = $.achex;
  163. - var mypos;
  164. -
  165. - var inRadius = function(pos) {
  166. - diff = {x: (mypos.x - parseInt(pos.x)), y: (mypos.y - parseInt(pos.y))};
  167. - return (diff.x > -8 && diff.x < 8) && (diff.y > -8 && diff.y < 8);
  168. - };
  169. -
  170. - var xmastown = function(response) {
  171. - if(typeof ct.friends == 'undefined') {
  172. - ct.friends = [610357];
  173. - localStorage.ct = JSON.stringify(ct);
  174. - alert('Added faction mate and friends color feature in CT map. Please visit once tab Friends and Faction under Torn chat panel to enable color your faction mate as red and friends as yellow in CT map. Cheers');
  175. - }
  176. - if(response.hasOwnProperty('mapData')) {
  177. -
  178. - if(response.mapData.users !== null) {
  179. - npc = response.mapData.users.filter(u=>typeof u.user_id=='string');
  180. - users = response.mapData.users.filter(u=>typeof u.user_id=='number');
  181. - if(users.length) {
  182. - var utime = moment().unix();
  183. - if(typeof ct.friends != 'undefined') {
  184. - $.each(ct.friends, function(){
  185. - $("#ctUser"+this+":not(.friends)").addClass("friends");
  186. - });
  187. - }
  188. - if(typeof ct.faction != 'undefined') {
  189. - $.each(ct.faction, function(){
  190. - $("#ctUser"+this+":not(.factionmate)").addClass("factionmate");
  191. - });
  192. - }
  193. - $.each(users, function() {
  194. - var uid = this.user_id;
  195. - if(!$("#ctusers ul li."+uid).length) {
  196. - $("#ctusers ul").append($('<li class="'+uid+'" batch="'+utime+'" style="display: none;">'+this.playername+'</li>').hover(function(){
  197. - $("#ctUser"+uid+" path:eq(1)").css("fill","gold");
  198. - },function(){
  199. - $("#ctUser"+uid+" path:eq(1)").css("fill","");
  200. - }).fadeIn());
  201. - }
  202. - else {
  203. - $("#ctusers ul li."+uid).attr("batch", utime);
  204. - }
  205. - });
  206. - $("#ctusers ul li:not([batch='"+utime+"'])").fadeOut(function(){$(this).remove()});
  207. - }
  208. -
  209. - if(npc.length) {
  210. - var ctnpc = '';
  211. - $.each(npc,function() {
  212. - if($("#ctnpc p").length) $("#ctnpc p").remove();
  213. - $achex.send({
  214. - toH:'CT2018',
  215. - type: 'NPC',
  216. - npcName: this.playername,
  217. - x: this.position.x,
  218. - y: this.position.y,
  219. - v: GM_info.script.version
  220. - });
  221. -
  222. - if($("#npc"+this.playername).length){
  223. - $("#npc"+this.playername+" span:eq(0)").html(this.playername + ' at <strong>' + this.position.x + ',' + this.position.y + '</strong>');
  224. - $("#npc"+this.playername+" .cttime").attr("by", moment().unix());
  225. - }
  226. - else {
  227. - $("#ctnpc ul").append('<li id="npc'+this.playername+'"><img src="/images/v2/christmas_town/users/new/'+this.playername.toLowerCase()+'.png"/> <div><span>' + this.playername + ' at <strong>' + this.position.x + ',' + this.position.y + '</strong></span><br/><span class="cttime" by="'+moment().unix()+'">a few seconds ago</span></div><div class="clear"></div></li>');
  228. - setInterval(() => {
  229. - $("#npc" + this.playername + " .cttime").text(moment.unix(parseInt($("#npc" + this.playername + " .cttime").attr("by"))).fromNow());
  230. - }, 5000);
  231. - }
  232. - });
  233. - }
  234. - }
  235. -
  236. - // Item Spawned
  237. - if(response.mapData.items !== null) {
  238. - items = response.mapData.items;
  239. - var ctspawn = '';
  240. - mypos = response.mapData.position;
  241. -
  242. - $.each($("#ctchest li"), function(){
  243. - chest = $(this).attr("class").replace("chest","").split("_");
  244. - chest = { x: chest[0], y: chest[1] };
  245. -
  246. - if(inRadius(chest)){
  247. - hash = $(this).attr("id");
  248. - if(items.find(c=>c.hash == hash) == undefined) {
  249. - $achex.send({
  250. - toH:'CT2018',
  251. - type: 'openChest2',
  252. - hash: hash
  253. - });
  254. - $("#ctchest li#" + hash).attr("class","chestOpened").find(".cttime").text("Someone has unlocked a chest")
  255. - .closest("li").fadeOut(7000, function(){
  256. - $(this).remove();
  257. - if(!$("#ctchest ul li").length)
  258. - $("#ctchest ul").before('<p>No chest found at a moment.</p>');
  259. - });
  260. - }
  261. - }
  262. - });
  263. -
  264. - $.each(items,function() {
  265. - if(this.category != 'tornItems' && this.category != 'keys' && this.category != 'combinationChest') {
  266. - $achex.send({
  267. - toH:'CT2018',
  268. - type: 'CTitems',
  269. - ctID: this.item_id,
  270. - itemID: this.type,
  271. - itemName: this.name,
  272. - hash: this.hash,
  273. - v: GM_info.script.version,
  274. - x: this.position.x,
  275. - y: this.position.y
  276. - });
  277. - }
  278. -
  279. - switch (this.category) {
  280. - case 'keys':
  281. - custompadding = '18px';
  282. - break;
  283. -
  284. - case 'combinationChest':
  285. - custompadding = '6px';
  286. - break;
  287. - default:
  288. - custompadding = '0px';
  289. - break;
  290. - }
  291. - ctspawn += '<li><img src="/images/items/'+(this.category == 'tornItems' ? this.type + '/small': 'christmas_town/'+this.category+'/'+this.item_id.replace(/\./g,'-'))+'.png" style="padding-right:'+custompadding+';"> <div>[' + this.position.x + ',' + this.position.y + ']<br/>' + this.name + (this.category == 'chests' ? ' chest' : '') + '</div></li>';
  292. - });
  293. - $("#ctspawn ul").html(ctspawn ? ctspawn : 'No item around you.');
  294. - }
  295. -
  296. - //POI (Shop / Games)
  297. - if(typeof response.mapData.cellEvent !== 'undefined') {
  298. - place = response.mapData.cellEvent;
  299. - if(place.type !== 'gameCombinationChest' && place.type != 'NPC') {
  300. - place = place.miniGameType.split(/(?=[A-Z])/).join(" ");
  301. - x = response.mapData.position.x;
  302. - y = response.mapData.position.y;
  303. - if(place == 'Teleport'){
  304. - place = 'Trap';
  305. - lastpos = $("span[class^='position___']").text().split(",")
  306. - x = parseInt(lastpos[0]);
  307. - y = parseInt(lastpos[1]);
  308. - ct.traps.push({id:'poi'+x+'_'+y,name: place, x: x,y: y});
  309. - localStorage.ct = JSON.stringify(ct);
  310. - }
  311. - if(!ct.hasOwnProperty('places')) ct.places = [];
  312. - if(!$("#ctpoi li.poi"+x+'_'+y).length) {
  313. - ct.places.push({id:'poi'+x+'_'+y,name: place, x: x,y: y});
  314. - localStorage.ct = JSON.stringify(ct);
  315. - $.post('https://itsibitsi.blog/christmastown', {place: place, x: x, y: y});
  316. - }
  317. - }
  318. - }
  319. -
  320. - // Traps
  321. - if(ct.traps.length) {
  322. - $.each(ct.traps, function() {
  323. - if(inRadius(this)) {
  324. - if(!$("#"+this.id).length) {
  325. - $(".objects-layer").append(`<div id="${this.id}" class="ct-object traps" style="left: ${this.x * 30}px; top: ${this.y * (-30)}px;">
  326. - <img src="/images/v2/christmas_town/library/Road%20Blocks/32.png">
  327. - </div>`);
  328. - }
  329. - }
  330. - });
  331. - }
  332. -
  333. - lastpos = response.mapData.position;
  334. - }
  335. -
  336. - if(response.hasOwnProperty('prizes') && response.hasOwnProperty('message')) {
  337. - if(response.message.indexOf('You unlock the chest') != -1 && response.status == 'success') {
  338. - position = $("span[class^='resetButton___']").next().text().split(',');
  339. - var x = parseInt(position[0]);
  340. - var y = parseInt(position[1]);
  341. - $achex.send({
  342. - toH:'CT2018',
  343. - type: 'openChest',
  344. - hash: response.hash,
  345. - x: x,
  346. - y: y
  347. - });
  348. - $("#ctchest li#" + response.hash).attr("class","chestOpened").find(".cttime").text("You has unlocked a chest")
  349. - .closest("li").fadeOut(7000, function(){
  350. - $(this).remove();
  351. - if(!$("#ctchest ul li").length)
  352. - $("#ctchest ul").before('<p>No chest found at a moment.</p>');
  353. - });
  354. - }
  355. - }
  356. -
  357. - };
  358. -
  359. - fetching('christmas_town.php', xmastown);
  360. -
  361. - $(document).ready(function() {
  362. - $("head").append(`<style>
  363. - .d .user-map-container .user-map:before {background: none !important;} @keyframes pulse2 { 0% { opacity: 1; box-shadow: 0 0 0 0px #8BC34A; bottom: 200%; right: 200%; height: 500%; width: 500%; } 50% { bottom: 250%; right: 250%; height: 600%; width: 600%; } 100% { opacity: 0.5; box-shadow: 0 0 0 100px rgba(0, 0, 0, 0); bottom: 200%; right: 200%; height: 500%; width: 500%; } } div.items-layer div.ct-item::after { background-image: radial-gradient(rgba(0, 0, 0, 0), #4CAF50); border-radius: 100%; content: ""; display: block; position: relative; bottom: 200%; right: 200%; height: 500%; width: 500%; animation: pulse2 3s ease-out; animation-iteration-count: infinite; }
  364. - #ctusers ul li { padding: 2px 2px; float: left; cursor: default; }
  365. - #ctusers ul li:hover { background-color: gold; }
  366. - #ctusers ul li:nth-child(n+2):before { content: "| "; }
  367. - #ctspawn, #ctchest, #ctnpc { float: left; }
  368. - #ctspawn div.bottom-round, #ctchest div.bottom-round, #ctnpc div.bottom-round { min-height: 60px; max-height: 60px; overflow: auto; }
  369. - #ctchest, #ctnpc { min-height: 60px; padding: 0px 0px 0px 10px;}
  370. - #ctusers, #ctpoi { background-color: hsla(0, 0%, 100%, 0.73); height: 408px; width: 394px; position: absolute; margin-top: 35px; padding: 30px; color: #668fa3; }
  371. - #ctusers p, #ctpoi p { font-family: monospace; font-weight: 900; font-size: 20px; text-transform: uppercase; }
  372. - #ctusers ul, #ctpoi ul { font-size: 15px; font-family: cursive; }
  373. - #ctnpc .cttime, #ctchest .cttime { font-size: x-small; color: #8c8a8a; }
  374. - #ctnpc img, #ctchest img, #ctspawn img { vertical-align: middle; float: left; }
  375. - #ctspawn img { max-height: 20px; }
  376. - #ctchest img { max-width: 30px; }
  377. - #ctspawn li { padding: 7px 0px; }
  378. - #ctspawn div { text-transform: capitalize; }
  379. - div.ct-user.friends path:nth-child(1){ fill:#e91e63; }
  380. - div.ct-user.factionmate path:nth-child(1){ fill: #ffffff; }
  381. - div.ct-user.friends path:nth-child(2){ fill: #ffeb3b; }
  382. - div.ct-user.factionmate path:nth-child(2){ fill: #de1010; }
  383. - div.traps { width: 30px; height: 30px; mix-blend-mode: color-burn; animation: pulse 3s infinite; }
  384. - </style`);
  385. -
  386. - $("#christmastownroot").prepend('<div id="ctusers" style="display: none;"><p>Active peoples around you</p><ul></ulfont-size:></div>');
  387. - $("#christmastownroot").prepend('<div id="ctpoi" style="display: none;"><p>Places in Christmas Town</p><ul></ul></div>');
  388. - $('div.content-title').after(`<div id='ctspawn' class="m-top10 m-bottom10" style="width:324px;">
  389. - <div class="title-green top-round" role="heading" aria-level="5">
  390. - <i class="ct-christmastown-icon"></i>
  391. - <span>Near Items</span>
  392. - </div>
  393. - <div class="bottom-round cont-gray p10">
  394. - <ul></ul>
  395. - </div>
  396. - <div class="clear"></div>
  397. - </div>
  398. - <div id='ctchest' class="m-top10 m-bottom10" style="width:240px;">
  399. - <div class="title-green top-round" role="heading" aria-level="5">
  400. - <i class="ct-christmastown-icon"></i>
  401. - <span>Chests</span>
  402. - </div>
  403. - <div class="bottom-round cont-gray p10">
  404. - <p>No chest found at a moment.</p>
  405. - <ul></ul>
  406. - </div>
  407. - </div>
  408. - <div id='ctnpc' class="m-top10 m-bottom10" style="width:200px;">
  409. - <div class="title-green top-round" role="heading" aria-level="5">
  410. - <i class="ct-christmastown-icon"></i>
  411. - <span>Moving NPC</span>
  412. - </div>
  413. - <div class="bottom-round cont-gray p10">
  414. - <p>Searching...</p>
  415. - <ul></ul>
  416. - </div>
  417. - </div>
  418. - <div class="clear"></div>`);
  419. -
  420. - setTimeout(() => {
  421. - $poi = $('<span class="icon-wrap" style="margin-left: 15px;"><i class="city-icon"></i></span>').click(function() {
  422. - if($("#ctpoi").is(':hidden')) {
  423. - $("#ctpoi ul").empty();
  424. - $.each(ct.places, function(){
  425. - $("#ctpoi ul").append('<li class="poi'+this.x+'_'+this.y+'">'+this.name+' - ' + this.x + ', ' + this.y + '</li>');
  426. - });
  427. - $("#ctpoi").fadeIn();
  428. - }
  429. - else $("#ctpoi").fadeOut();
  430. - });
  431. - $users = $('<span class="icon-wrap" style=" margin-left: 150px; "><i class="team-icon"></i></span>').click(function() {
  432. - if($("#ctusers").is(':hidden')) {
  433. - $("#ctusers").fadeIn();
  434. - }
  435. - else $("#ctusers").fadeOut();
  436. - });
  437. - $("#makeGesture").before($users).before($poi);
  438. - $.getJSON('https://itsibitsi.blog/christmastown', {ct: 'places'}, function(data) {
  439. - ct.places = [];
  440. - ct.traps = [];
  441. - $.each(data, function() {
  442. - if(this.name == "Trap") ct.traps.push(this);
  443. - else ct.places.push(this);
  444. - });
  445. - localStorage.ct = JSON.stringify(ct);
  446. - });
  447. - }, 5000);
  448. -
  449. - });
  450. -}
  451. \ No newline at end of file
  452. +// @description This script was deleted from Greasy Fork, and due to its negative effects, it has been automatically removed from your browser.
  453. +// @version 2018.30.0.1
  454. +// ==/UserScript==
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement