Advertisement
Guest User

BondBot v259 public

a guest
Nov 11th, 2017
432
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 44.16 KB | None | 0 0
  1. // ==UserScript==
  2. // @name BondBot
  3. // @namespace http://tampermonkey.net/
  4. // @version public
  5. // @description try to take over the world!
  6. // @author CitronSustain / oh / Anon64
  7. // @match http://www.multiplayerpiano.com/*
  8. // @grant none
  9. // ==/UserScript==
  10. //Hello, PasteBin user! You are looking at BondBot! A user focused bot for multiplayerpiano.com. Below are some descriptions of functions you can run using /js!
  11. ///js showClock24Hr() Shows a 24 Hr clock on your name
  12. ///js retardSpam() Copies any messages and repeats them using the tumblr() function
  13. ///js copySpam() Copies any messages and repeats them normally
  14. ///js leetSpam() Self Explanatory
  15. ///js showClockLocale() Shows your local time on your name
  16. ///js tumblr('texthere') Tumblr makes your text LoOk LiKe ThIs
  17. ///js L337('Texthere') makes your text l00k l1k3 th15
  18. ///js sendChat('text here') sends what ever is in the parentheses in chat!
  19. //To start the bot, paste this script into your browser console or Tampermonkey.
  20. //To undo any chatspam functions you have run, please restart the bot by refreshing your page and re pasting it into console.
  21. //If you abuse chatspam functions Bondbot (Shaun Murphy) or Anon64 can turn off the bot.
  22.  
  23. OHS = MPP;
  24.  
  25. prefix = '.';
  26.  
  27. thingy = 1; //pls dont remove, will probably be in use later
  28.  
  29. magic_number = Math.floor(Math.random() * 100 + 1);
  30.  
  31. botname = 'BondBot [.about]';
  32.  
  33. stalemates = 0;
  34.  
  35. lost = 0;
  36.  
  37. won = 0;
  38.  
  39. games = 0;
  40.  
  41. //chat buffer from electrashave
  42. //-electrashave
  43. var chat_buffer = [];
  44. function sendChat(msg) {
  45. msg.match(/.{0,511}/g).forEach(function(x, i) {
  46. if (x === '') return;
  47. if (i !== 0) x = '...' + x;
  48. chat_buffer.push(x);
  49. });
  50. }
  51.  
  52. var chatInt = setInterval(function() {
  53. var msg = chat_buffer.shift();
  54. if (msg) OHS.client.sendArray([{ m: 'a', message: msg }]);
  55. }, 1900);
  56.  
  57. function cockBot() {
  58. sendChat(
  59. 'CockBot has been enabled. To revert changes, please reload the bot.'
  60. );
  61. botname = 'CockBot [' + prefix + 'about]';
  62. prefix = '\u034f';
  63. }
  64. Array.prototype.random = function(q) {
  65. if (q === undefined) {
  66. return this.length > 0
  67. ? this[Math.floor(this.length * Math.random())]
  68. : undefined;
  69. } else {
  70. let amount = q >>> 0;
  71. let result = this.slice(0, amount);
  72. for (let i = amount; i < this.length; i++) {
  73. let j = Math.floor(Math.random() * i);
  74. if (j < amount) {
  75. result[j] = this[i];
  76. }
  77. }
  78. return result;
  79. }
  80. };
  81.  
  82. setTimeout(function() {
  83. sendChat('Starting Bondbot..');
  84. console.log('Starting Bondbot..');
  85. console.log('This loading sequence totally isnt fake...');
  86. }, 1200);
  87. setTimeout(function() {
  88. sendChat(medicalrandom[loadingmedicalrandom]);
  89. console.log(medicalrandom[loadingmedicalrandom]);
  90. }, 1550);
  91. setTimeout(function() {
  92. sendChat(simsloading[loadingsimsrandom]);
  93. console.log(simsloading[loadingsimsrandom]);
  94. sendChat('Loading done! Use .about for commands');
  95. console.log('Sequence completed.');
  96. }, 1790);
  97.  
  98. setInterval(
  99. function() {
  100. console.log('Google history has been saved.');
  101. JSON.stringify(searchHistory);
  102. },
  103. 300000 // every 5 minutes
  104. );
  105.  
  106. setInterval(function() {
  107. console.log('Google history has been loaded.');
  108. JSON.parse(localStorage.history);
  109. }, 300001);
  110.  
  111. setInterval(function() {
  112. sendChat('Guess the magic number for a gift!');
  113. }, 300000);
  114.  
  115. setInterval(function() {
  116. sendChat('discord.gg/5wtubrg - Join the official 160System server!');
  117. }, 300000);
  118.  
  119. //chatlog from Anon64
  120. //-Anon64
  121. OHS.client.on('a', function(boi) {
  122. console.log(
  123. `%c${boi.p.name} (${boi.p._id}): ${boi.a}`,
  124. `color: ${boi.p.color}`
  125. );
  126. });
  127.  
  128. var simsloading = [
  129. 'Adding Hidden Agendas',
  130. 'Adjusting Bell Curves',
  131. 'Aesthesizing Industrial Areas',
  132. 'Aligning Covariance Matrices',
  133. 'Applying Feng Shui Shaders',
  134. 'Applying Theatre Soda Layer',
  135. 'Asserting Packed Exemplars',
  136. 'Attempting to Lock Back-Buffer',
  137. 'Binding Sapling Root System',
  138. 'Breeding Fauna',
  139. ];
  140.  
  141. var loadingsimsrandom = Math.floor(Math.random() * simsloading.length);
  142.  
  143. var medicalrandom = [
  144. 'Making REBOAS...',
  145. 'Adding shunts..',
  146. 'Making incisions..',
  147. 'Avoid cutting your jugular!',
  148. 'Measuring echocardiograms..',
  149. 'My MRI scans for my patients are very important!',
  150. ];
  151.  
  152. var loadingmedicalrandom = Math.floor(Math.random() * medicalrandom.length);
  153.  
  154. OHS.client.on('a', function(msg) {
  155. var b = msg.a;
  156. var msgArr = msg.a.split(' ');
  157. var input = msg.a.substring(msgArr[0].length).trim();
  158. if (
  159. msgArr[0] == prefix + 'pickle' &&
  160. msg.p._id == OHS.client.getOwnParticipant()._id
  161. ) {
  162. console.log('lol');
  163. }
  164.  
  165. var giftArray = [
  166. 'a cute kitten!',
  167. 'a cute puppy!',
  168. 'a potato!',
  169. 'a pikachu!',
  170. 'a brand new Xbox One!',
  171. 'a brand new PS4!',
  172. '1 million cows!',
  173. 'a slice of bacon!',
  174. 'a boating license!',
  175. 'a bunch of money!',
  176. 'some cake!',
  177. 'a box inside of a... BOX!',
  178. 'a new phone!',
  179. 'a new piano!',
  180. 'some chicken nuggets!',
  181. 'a brand new Wii U!',
  182. 'an evil gerbil!',
  183. 'a captains ship!',
  184. 'some sfoof! (Semolina Turmeric Cake)',
  185. 'some pizza!',
  186. 'a new laptop!',
  187. 'a piece of cotton',
  188. 'a spoon',
  189. 'a dribbling cat',
  190. ];
  191. var giftrandom = Math.floor(Math.random() * giftArray.length);
  192.  
  193. if (b == prefix + 'time_24hr') {
  194. sendChat(
  195. new Date().getHours() +
  196. ':' +
  197. new Date().getMinutes() +
  198. ':' +
  199. new Date().getSeconds()
  200. );
  201. }
  202.  
  203. if (b == prefix + 'about') {
  204. sendChat(
  205. 'Bondbot is a bot written by oh including many fun console commands and chat commands. '
  206. );
  207. sendChat(
  208. 'Command list: ' +
  209. prefix +
  210. 'about, ' +
  211. prefix +
  212. 'version, ' +
  213. prefix +
  214. '8ball, ' +
  215. prefix +
  216. 'time_24hr, ' +
  217. prefix +
  218. 'rps, ' +
  219. prefix +
  220. 'google, ' +
  221. prefix +
  222. 'unbox, ' +
  223. prefix +
  224. 'fuck, ' +
  225. prefix +
  226. 'hug, ' +
  227. prefix +
  228. 'kiss, ' +
  229. prefix +
  230. 'lick, ' +
  231. prefix +
  232. 'kill, ' +
  233. prefix +
  234. 'me, ' +
  235. prefix +
  236. 'say, ' +
  237. prefix +
  238. 'afk'
  239. ); //FIXME: add an MPC variable without an autoregen
  240. sendChat('Unbox weapon skins from CS:GO! Inventories will work soon!');
  241. sendChat('New and improved 8ball cmd! More action commands!');
  242. }
  243. //RPS START (there is a lot easier way to do this but I couldn't figure it out cause I'm retarded)
  244.  
  245. var rockwords = [
  246. 'You Lose! Computer chose paper.',
  247. 'You win! Computer chose scissors.',
  248. 'Tie! You both chose rock.',
  249. ];
  250. var rockrandom = Math.floor(Math.random() * rockwords.length);
  251.  
  252. var paperwords = [
  253. 'You Lose! Computer chose scisssors.',
  254. 'You win! Computer chose rock.',
  255. 'Tie! You both chose paper.',
  256. ];
  257. var paperrandom = Math.floor(Math.random() * paperwords.length);
  258.  
  259. var scissorswords = [
  260. 'You Lose! Computer chose rock.',
  261. 'You win! Computer chose paper.',
  262. 'Tie! You both chose scissors.',
  263. ];
  264. var scissorsrandom = Math.floor(Math.random() * scissorswords.length); //FIXME: add some difficulty settings or something cause RPS is stupidly hard
  265. if (b == prefix + 'rps' || b == prefix + 'rockpaperscissors') {
  266. sendChat('Welcome to RPS: do .rps <rock, paper, scissors> to play!');
  267. }
  268.  
  269. if (
  270. b == prefix + 'rps r' ||
  271. b == prefix + 'rockpaperscissors rock' ||
  272. b == prefix + 'rps rock' ||
  273. b == prefix + 'rockpaperscissors r'
  274. ) {
  275. sendChat('RPS: ' + rockwords[rockrandom]);
  276. }
  277.  
  278. if (
  279. b == prefix + 'rps s' ||
  280. b == prefix + 'rockpaperscissors s' ||
  281. b == prefix + 'rps scissors' ||
  282. b == prefix + 'rockpaperscissors scissors'
  283. ) {
  284. sendChat('RPS: ' + scissorswords[scissorsrandom]);
  285. }
  286.  
  287. if (
  288. b == prefix + 'rps p' ||
  289. b == prefix + 'rockpaperscissors paper' ||
  290. b == prefix + 'rps paper' ||
  291. b == prefix + 'rockpaperscissors p'
  292. ) {
  293. sendChat('RPS: ' + paperwords[paperrandom]);
  294. }
  295. //RPS debug shits nothing
  296. if (msg.p._id == OHS.client.getOwnParticipant()._id) {
  297. if (msg.a.toLowerCase().includes('RPS: You win!')) {
  298. won++;
  299. games++;
  300. console.log('Games won: ' + won);
  301. console.log('Games total: ' + games);
  302. console.log('Games lost: ' + lost);
  303. console.log('Stalemates: ' + stalemates);
  304. }
  305. }
  306.  
  307. if (msg.p._id == OHS.client.getOwnParticipant()._id) {
  308. if (msg.a.toLowerCase().includes('RPS: You lose!')) {
  309. lost++;
  310. games++;
  311. console.log('Games won: ' + won);
  312. console.log('Games total: ' + games);
  313. console.log('Games lost: ' + lost);
  314. console.log('Stalemates: ' + stalemates);
  315. }
  316. }
  317.  
  318. if (msg.p._id == OHS.client.getOwnParticipant()._id) {
  319. if (msg.a.toLowerCase().includes('RPS: Tie!')) {
  320. stalemates++;
  321. games++;
  322. console.log('Games won: ' + won);
  323. console.log('Games total: ' + games);
  324. console.log('Games lost: ' + lost);
  325. console.log('Stalemates: ' + stalemates);
  326. }
  327. } //FIXME: idk what the fuck is wrong with this
  328.  
  329. //magic number stuff
  330.  
  331. /*if (b == magic_number) {
  332. sendChat(msg.p.name + ' guessed the magic number correctly! They win air!');
  333. magic_number = Math.floor(Math.random() * 100 + 1);
  334. }*/
  335.  
  336. if (msg.a.toLowerCase().includes(magic_number)) {
  337. if (msg.a.length > 5) return;
  338. sendChat(
  339. msg.p.name +
  340. ' guessed the magic number correctly, ' +
  341. '(' +
  342. magic_number +
  343. ')' +
  344. ' and won ' +
  345. giftArray[giftrandom]
  346. );
  347. magic_number = Math.floor(Math.random() * 100 + 1); //FIXME: maybe turn into a math problem solving thing
  348. }
  349.  
  350. if (
  351. b == prefix + 'unbox csweaponscase1' ||
  352. b == prefix + 'unbox Weapons Case 1' ||
  353. b == prefix + 'unbox 1'
  354. ) {
  355. if (blIds.includes(msg.p._id) || blNames.includes(msg.p.name)) {
  356. } else {
  357. sendChat(
  358. 'CS:GO: You unboxed a ' + csweaponscase1[case1random] + wear[wearrandom]
  359. );
  360. }
  361. }
  362.  
  363. if (
  364. b == prefix + 'unbox Gamma' ||
  365. b == prefix + 'unbox gamma' ||
  366. b == prefix + 'unbox 2'
  367. ) {
  368. if (blIds.includes(msg.p._id) || blNames.includes(msg.p.name)) {
  369. } else {
  370. sendChat('CS:GO: You unboxed a ' + gamma[gammarandom] + wear[wearrandom]);
  371. }
  372. }
  373. });
  374.  
  375. //CS:GO Unbox Sim START
  376.  
  377. var wear = [
  378. 'Battle-Scarred (BS)',
  379. 'Field-Tested (FT)',
  380. 'Well-Worn (WW)',
  381. 'Minimal Wear (MW)',
  382. 'Factory New (FN)',
  383. ];
  384.  
  385. var csweaponscase1 = [
  386. 'MP7 | Skulls | Mil-spec ',
  387. 'SG 553 | Ultraviolet | Mil-spec ',
  388. 'AUG | Wings | Mil-spec ',
  389. 'M4A1-S | Dark Water | Restricted ',
  390. 'USP-S | Dark Water | Restricted ',
  391. 'Glock-18 | Dragon Tattoo | Restricted ',
  392. 'Desert Eagle | Hypnotic | Classified ',
  393. 'AK-47 | Case Hardened | Classified ',
  394. 'AWP | Lightning Strike | Covert ',
  395. '★ Karambit | Exceedingly Rare ',
  396. ];
  397.  
  398. var gamma = [
  399. 'Five-SeveN | Violent Daimyo | Mil-Spec',
  400. 'MAC-10 | Carnivore | Mil-Spec',
  401. 'Nova | Exo | Mil-Spec',
  402. 'P250 | Iron Clad | Mil-Spec',
  403. 'PP-Bizon | Harvester | Mil-Spec',
  404. 'SG 553 | Aerial | Mil-Spec',
  405. 'Tec-9 | Ice Cap | Mil-Spec',
  406. 'AUG | Aristocrat | Restricted',
  407. 'AWP | Phobos | Restricted',
  408. 'P90 | Chopper | Restricted',
  409. 'R8 Revolver | Reboot | Restricted',
  410. 'Sawed-Off | Limelight | Restricted',
  411. 'M4A4 | Desolate Space | Classified',
  412. 'P2000 | Imperial Dragon | Classified',
  413. 'SCAR-20 | Bloodsport | Classified',
  414. 'Glock-18 | Wasteland Rebel | Covert',
  415. 'M4A1-S | Mecha Industries | Covert',
  416. 'M9 Bayonet | Crimson Web',
  417. ];
  418. var case1random = Math.floor(Math.random() * csweaponscase1.length);
  419. var wearrandom = Math.floor(Math.random() * wear.length);
  420. var gammarandom = Math.floor(Math.random() * gamma.length);
  421. /*var chromarandom = Math.floor(Math.random() * chroma.length);
  422. var chroma2random = Math.floor(Math.random() * chroma2.length);*/
  423.  
  424. OHS.client.on('a', function(msg) {
  425. var cmd = msg.a.split(' ')[0].toLowerCase();
  426. var input = msg.a.substring(cmd.length).trim();
  427. if (cmd == prefix + 'unbox') {
  428. if (blIds.includes(msg.p._id) || blNames.includes(msg.p.name)) {
  429. } else {
  430. sendChat(
  431. 'Welcome to CS:GO unboxing simulator on OHS! To unbox a case, do .unbox <case name or id>. Current cases available: Weapons Case 1 (csweaponscase1, 1), Gamma (gamma, 2)'
  432. );
  433. }
  434. }
  435. });
  436.  
  437. /* if (
  438. b == prefix + 'unbox csweaponscase1' ||
  439. b == prefix + 'unbox Weapons Case 1' ||
  440. b == prefix + 'unbox 1'
  441. ) {
  442. sendChat(
  443. 'CS:GO: You unboxed a ' + csweaponscase1[case1random] + wear[wearrandom]
  444. );
  445. }*/
  446.  
  447. /*if (
  448. b == prefix + 'unbox Gamma' ||
  449. b == prefix + 'unbox gamma' ||
  450. b == prefix + 'unbox 2'
  451. ) {
  452. sendChat('CS:GO: You unboxed a ' + gamma[gammarandom] + wear[wearrandom]);
  453. }*/
  454. /*if (
  455. b == prefix + 'unbox Chroma' ||
  456. b == prefix + 'unbox cschroma' ||
  457. b == prefix + 'unbox 3'
  458. ) {
  459. }*/
  460.  
  461. OHS.client.on('a', function(msg) {
  462. var cmd = msg.a.split(' ')[0].toLowerCase();
  463. var input = msg.a.substring(cmd.length).trim();
  464. if (cmd == prefix + 'anon64') {
  465. if (blIds.includes(msg.p._id) || blNames.includes(msg.p.name)) {
  466. } else {
  467. sendChat(
  468. 'According to according according to the according records of according, Anon64 is a bot and the proof is that he displays codes. codes that are in the programming language that was invented by a human called javascript. it was widely used in the internet. the internet is a place where people communicate. it is also a good place to watch some u know what. -- A guy named Natas(SATAN)'
  469. );
  470. }
  471. }
  472. });
  473. /*if (b == prefix + 'anon64') {
  474. sendChat(
  475. 'According to according according to the according records of according, Anon64 is a bot and the proof is that he displays codes. codes that are in the programming language that was invented by a human called javascript. it was widely used in the internet. the internet is a place where people communicate. it is also a good place to watch some u know what. -- A guy named Natas(SATAN)'
  476. );
  477. }*/
  478. /*if (
  479. (b == 'Bondbot, shutdown' && msg.p._id == 'd55bf273f64f37c5691f3bbb') ||
  480. (b == 'Bondbot, shutdown' && msg.p._id == '63ce4e6b86780ae23e04a5b8') ||
  481. (b == 'Bondbot, shutdown' && msg.p._id == 'a2db90c04712080af5d797a1')
  482. ) {
  483. sendChat('Shutting down -- Reason: Requested by Admin');
  484. location.reload();
  485. }*/
  486. OHS.client.on('a', function(msg) {
  487. var cmd = msg.a.split(' ')[0].toLowerCase();
  488. var input = msg.a.substring(cmd.length).trim();
  489. if (
  490. //FIXME: improve cmd above by using cmd below somehow
  491. msg.p._id == 'd55bf273f64f37c5691f3bbb' ||
  492. msg.p._id == '63ce4e6b86780ae23e04a5b8' ||
  493. msg.p._id == 'a2db90c04712080af5d797a1'
  494. ) {
  495. if (msg.a.toLowerCase().includes('shut down' && 'bondbot shutdown')) {
  496. sendChat('Shutting down -- Requested by Admin.');
  497. location.reload();
  498. }
  499. }
  500.  
  501. if (msg.a.toLowerCase().includes('what')) {
  502. if (msg.a.toLowerCase().includes('time')) {
  503. sendChat(
  504. new Date().getHours() +
  505. ':' +
  506. new Date().getMinutes() +
  507. ':' +
  508. new Date().getSeconds()
  509. );
  510. }
  511. }
  512.  
  513. if (
  514. msg.p._id == 'd55bf273f64f37c5691f3bbb' ||
  515. msg.p._id == '63ce4e6b86780ae23e04a5b8' ||
  516. msg.p._id == 'a2db90c04712080af5d797a1'
  517. ) {
  518. if (msg.a.toLowerCase().includes('activate clock')) {
  519. if (msg.a.toLowerCase().includes('clock')) {
  520. sendChat('Turning on 24Hr Clock');
  521. showClock24Hr();
  522. }
  523. }
  524. }
  525.  
  526. if (
  527. msg.p._id == 'd55bf273f64f37c5691f3bbb' ||
  528. msg.p._id == '63ce4e6b86780ae23e04a5b8' ||
  529. msg.p._id == 'a2db90c04712080af5d797a1'
  530. ) {
  531. if (msg.a.toLowerCase().includes('be doctor' && 'shaun murphy')) {
  532. sendChat('Making REBOAS...');
  533. botname = 'Dr. Shaun Murphy [.about]';
  534. }
  535. }
  536.  
  537. if (msg.a.toLowerCase().includes('( WWW.AMIGHTYWIND.COM )'.toLowerCase())) {
  538. sendChat('FUCK OFF!');
  539. }
  540.  
  541. if (msg.a.toLowerCase().includes('yeet' && 'y e e t'.toLowerCase())) {
  542. sendChat('YEET');
  543. }
  544. });
  545.  
  546. blNames = ['Anonymous'];
  547. blIds = [
  548. 'ffa07b701a54f9d408fc76b1', //A5R13L B0t
  549. ];
  550.  
  551. function info(name) {
  552. //epicos shit
  553. var array = [];
  554. for (var pl in OHS.client.ppl) {
  555. if (OHS.client.ppl[pl].name.toLowerCase().includes(name.toLowerCase())) {
  556. array.push(OHS.client.ppl[pl]);
  557. }
  558. }
  559. return array[Math.floor(Math.random() * array.length)];
  560. }
  561.  
  562. //also epicos shit wow im superlazy
  563. afkusersnames = [];
  564. afkusersids = [];
  565.  
  566. OHS.client.on('a', function(msg) {
  567. if (msg.a.toLowerCase() == prefix + 'afk')
  568. if (blIds.includes(msg.p._id) || blNames.includes(msg.p.name)) {
  569. } else {
  570. sendChat(
  571. '**' +
  572. msg.p.name +
  573. ' is now marked as AFK. Send any message to be unmarked.'
  574. );
  575. setTimeout(function() {
  576. afkusersnames.push(msg.p.name);
  577. afkusersids.push(msg.p._id);
  578. }, 2000);
  579. }
  580. else {
  581. }
  582. });
  583.  
  584. MPP.client.on('a', function(msg) {
  585. var cmd = msg.a.split(' ')[0].toLowerCase();
  586. var input = msg.a.substring(cmd.length).trim();
  587. if (cmd == prefix + 'bunny')
  588. if (blIds.includes(msg.p._id) || blNames.includes(msg.p.name)) {
  589. } else {
  590. sendChat('..( /)');
  591. sendChat('..(•.•)');
  592. sendChat('c(")(")');
  593. }
  594. });
  595.  
  596. OHS.client.on('a', function(msg) {
  597. if (afkusersids.includes(msg.p._id)) {
  598. if (
  599. msg.a.toLowerCase() == 'afk' ||
  600. msg.a.toLowerCase() == 'brb' ||
  601. msg.a.toLowerCase() == prefix + 'afk'
  602. ) {
  603. sendChat('You are marked as AFK already ' + msg.p.name + '!');
  604. } else {
  605. sendChat('**' + msg.p.name + ' is no longer AFK.');
  606. afkusersids.splice(msg.p._id);
  607. afkusersnames.splice(msg.p.name);
  608. }
  609. }
  610. });
  611.  
  612. OHS.client.on('a', function(msg) {
  613. var cmd = msg.a.split(' ')[0].toLowerCase();
  614. var input = msg.a.substring(cmd.length).trim();
  615. if (cmd == prefix + 'say') {
  616. if (blIds.includes(msg.p._id) || blNames.includes(msg.p.name)) {
  617. } else {
  618. }
  619. sendChat('\u034f' + msg.a.substring(cmd.length).trim());
  620. }
  621. });
  622.  
  623. OHS.client.on('a', function(msg) {
  624. var cmd = msg.a.split(' ')[0].toLowerCase();
  625. var input = msg.a.substring(cmd.length).trim();
  626. if (cmd == prefix + 'me') {
  627. if (blIds.includes(msg.p._id) || blNames.includes(msg.p.name)) {
  628. } else {
  629. sendChat('**' + msg.p.name + ' ' + msg.a.substring(cmd.length).trim());
  630. }
  631. }
  632. });
  633.  
  634. OHS.client.on('a', function(msg) {
  635. var cmd = msg.a.split(' ')[0].toLowerCase();
  636. var input = msg.a.substring(cmd.length).trim();
  637. if (cmd == prefix + 'version') {
  638. if (blIds.includes(msg.p._id) || blNames.includes(msg.p.name)) {
  639. } else {
  640. sendChat('Version: v0.169');
  641. }
  642. }
  643. });
  644.  
  645. OHS.client.on('a', function(msg) {
  646. var cmd = msg.a.split(' ')[0].toLowerCase();
  647. var input = msg.a.substring(cmd.length).trim();
  648. var eightballwords = [
  649. 'It is certain',
  650. 'It is decidedly so',
  651. 'Without a doubt',
  652. 'Yes, definitely.',
  653. 'You may rely on it',
  654. 'As I see it yes',
  655. 'Most likely',
  656. 'Outlook good',
  657. 'Yes',
  658. 'Signs point to yes',
  659. 'Reply hazy, try again.',
  660. 'Ask again later',
  661. 'Better not tell you now',
  662. 'Cannot predict now',
  663. 'Concentrate and ask again',
  664. 'Dont count on it',
  665. 'My reply is no',
  666. 'My sources say no',
  667. 'Outlook not so good',
  668. 'Very doubtful',
  669. 'No',
  670. ];
  671. eightballrandom = Math.floor(Math.random() * eightballwords.length);
  672. if (cmd == prefix + '8ball') {
  673. if (blIds.includes(msg.p._id) || blNames.includes(msg.p.name)) {
  674. } else {
  675. if (input == '') {
  676. sendChat(
  677. '8ball: ' +
  678. msg.p.name +
  679. ", Ask me a question to answer, don't just stand there!"
  680. );
  681. } else {
  682. sendChat(
  683. '8ball: ' + msg.p.name + ', ' + eightballwords[eightballrandom]
  684. );
  685. }
  686. }
  687. }
  688. });
  689.  
  690. OHS.client.on('a', function(msg) {
  691. var cmd = msg.a.split(' ')[0].toLowerCase();
  692. var input = msg.a.substring(cmd.length).trim();
  693. if (cmd == prefix + 'fuck') {
  694. if (blIds.includes(msg.p._id) || blNames.includes(msg.p.name)) {
  695. } else {
  696. if (input == '') {
  697. sendChat(msg.p.name + ' is so lonely they fuck air.');
  698. } else {
  699. if (input == msg.p.name) {
  700. //make infoinput.selfname function
  701. sendChat(msg.p.name + ' fucks themselves.');
  702. } else {
  703. sendChat(
  704. msg.p.name +
  705. ' fucks ' +
  706. info(input).name +
  707. ' so FUCKING HARD that they die from too much sex.'
  708. );
  709. }
  710. }
  711. }
  712. }
  713. });
  714.  
  715. OHS.client.on('a', function(msg) {
  716. var cmd = msg.a.split(' ')[0].toLowerCase();
  717. var input = msg.a.substring(cmd.length).trim();
  718. if (cmd == prefix + 'hug') {
  719. if (blIds.includes(msg.p._id) || blNames.includes(msg.p.name)) {
  720. } else {
  721. if (input == '') {
  722. sendChat(msg.p.name + ' hugs no one. :(');
  723. } else {
  724. if (input == msg.p.name) {
  725. sendChat(msg.p.name + ' hugs themselves because they are lonely. :(');
  726. } else {
  727. sendChat(
  728. msg.p.name + ' gives ' + info(input).name + ' a big warm hug.'
  729. );
  730. }
  731. }
  732. }
  733. }
  734. });
  735.  
  736. OHS.client.on('a', function(msg) {
  737. var cmd = msg.a.split(' ')[0].toLowerCase();
  738. var input = msg.a.substring(cmd.length).trim();
  739. if (cmd == prefix + 'kiss') {
  740. if (blIds.includes(msg.p._id) || blNames.includes(msg.p.name)) {
  741. } else {
  742. if (input == '') {
  743. sendChat(msg.p.name + ' kisses the air.');
  744. } else {
  745. if (input == msg.p.name) {
  746. sendChat(msg.p.name + ' is so lonely, they kiss their elbow.');
  747. } else {
  748. sendChat(msg.p.name + ' kisses ' + info(input).name + '.');
  749. }
  750. }
  751. }
  752. }
  753. });
  754.  
  755. OHS.client.on('a', function(msg) {
  756. var cmd = msg.a.split(' ')[0].toLowerCase();
  757. var input = msg.a.substring(cmd.length).trim();
  758. if (cmd == prefix + 'eat') {
  759. if (blIds.includes(msg.p._id) || blNames.includes(msg.p.name)) {
  760. } else {
  761. if (input == '') {
  762. sendChat(msg.p.name + ' eats nothing. They then die of starvation.');
  763. } else {
  764. sendChat(
  765. msg.p.name +
  766. ' eats a ' +
  767. msg.a.substring(cmd.length).trim() +
  768. '. It was delicious!'
  769. );
  770. }
  771. }
  772. }
  773. });
  774.  
  775. OHS.client.on('a', function(msg) {
  776. var cmd = msg.a.split(' ')[0].toLowerCase();
  777. var input = msg.a.substring(cmd.length).trim();
  778. if (cmd == prefix + 'drink') {
  779. if (blIds.includes(msg.p._id) || blNames.includes(msg.p.name)) {
  780. } else {
  781. if (input == '') {
  782. sendChat(
  783. msg.p.name +
  784. ' attempts to pour water into a cup. They start to drink, but nothing comes out. Upon closer inspection, the cup was empty.'
  785. );
  786. } else {
  787. sendChat(
  788. msg.p.name +
  789. ' drinks a ' +
  790. msg.a.substring(cmd.length).trim() +
  791. '. It was refreshing.'
  792. );
  793. }
  794. }
  795. }
  796. });
  797.  
  798. OHS.client.on('a', function(msg) {
  799. var cmd = msg.a.split(' ')[0].toLowerCase();
  800. var input = msg.a.substring(cmd.length).trim();
  801. if (cmd == prefix + 'lick') {
  802. if (blIds.includes(msg.p._id) || blNames.includes(msg.p.name)) {
  803. } else {
  804. if (input == '') {
  805. sendChat(
  806. msg.p.name +
  807. " couldn't find anything to lick, so they licked the wall."
  808. );
  809. } else {
  810. if (input == msg.p.name) {
  811. sendChat(
  812. msg.p.name + " licks themselves. I don't want to know where."
  813. );
  814. } else {
  815. sendChat(msg.p.name + ' licks ' + info(input).name + '.');
  816. sendChat(info(input).name + ' revolts in disgust.');
  817. }
  818. }
  819. }
  820. }
  821. });
  822.  
  823. OHS.client.on('a', function(msg) {
  824. var cmd = msg.a.split(' ')[0].toLowerCase();
  825. var input = msg.a.substring(cmd.length).trim();
  826. if (cmd == prefix + 'kill') {
  827. if (blIds.includes(msg.p._id) || blNames.includes(msg.p.name)) {
  828. } else {
  829. if (input == '') {
  830. sendChat(
  831. msg.p.name +
  832. ' attempts to stab the air, somehow misses and the knife landed on their foot. ' +
  833. msg.p.name +
  834. ' screams in pain.'
  835. );
  836. } else {
  837. if (input == msg.p.name) {
  838. sendChat(msg.p.name + ' commits suicide! :(');
  839. } else {
  840. sendChat(
  841. msg.p.name +
  842. ' kills ' +
  843. info(input).name +
  844. ' with scissors. ' +
  845. info(input).name +
  846. ' screams in pain.'
  847. );
  848. }
  849. }
  850. }
  851. }
  852. });
  853.  
  854. //ADMINS start
  855. admincode = Math.random();
  856. adminIds = [
  857. 'a2db90c04712080af5d797a1', //citronsustain
  858. '63ce4e6b86780ae23e04a5b8', //citronsustain
  859. 'd55bf273f64f37c5691f3bbb', //Anon64
  860. '051ee1ec34cf0218653af6a8', //JPDLD
  861. '0eab0774ba77d8744c9bf2a4', //Infinity~
  862. '5b414d782edd2d3f517a5080', //dude/error
  863. 'eda8c37f125a3641fe041799', //Japanese
  864. ];
  865.  
  866. OHS.client.on('a', function(ver) {
  867. var cmd = ver.a.split(' ')[0].toLowerCase();
  868. var input = ver.a.substring(cmd.length).trim();
  869. if (cmd == prefix + 'verify' + admincode) {
  870. if (blIds.includes(msg.p._id) || blNames.includes(msg.p.name)) {
  871. } else {
  872. sendChat(
  873. 'Verification code correct. Adding to admins.' + '(' + ver.p.name + ')'
  874. );
  875. console.log(
  876. ver.p.name + ver.p._id + ' was added to admins. This will not save.'
  877. );
  878. adminIds.push(ver.p._id);
  879. admincode = Math.random();
  880. }
  881. }
  882. });
  883.  
  884. OHS.client.on('a', function(msg) {
  885. var cmd = msg.a.split(' ')[0].toLowerCase;
  886. var input = msg.a.substring(cmd.length).trim();
  887. if (cmd == prefix + 'botname') {
  888. if (adminIds.includes(msg.p._id)) {
  889. botname == msg.a.substring(cmd.length).trim();
  890. } else {
  891. sendChat('You do not have access to this command!');
  892. }
  893. }
  894. });
  895.  
  896. OHS.client.on('a', function(msg) {
  897. var cmd = msg.a.split(' ')[0].toLowerCase;
  898. var input = msg.a.substring(cmd.length).trim();
  899. if (cmd == prefix + 'cmdchar') {
  900. if (adminIds.includes(msg.p._id)) {
  901. prefix == msg.a.substring(cmd.length).trim();
  902. } else {
  903. sendChat('You do not have access to this command!');
  904. }
  905. }
  906. });
  907.  
  908. OHS.client.on('a', function(msg) {
  909. if (msg.a.toLowerCase() == prefix + 'adminstatus')
  910. if (blIds.includes(msg.p._id) || blNames.includes(msg.p.name)) {
  911. } else {
  912. sendChat('k hold on');
  913. if (adminIds.includes(msg.p._id)) {
  914. sendChat('You are admin');
  915. } else {
  916. sendChat('You are not admin.');
  917. }
  918. }
  919. });
  920. //ADMINS end
  921.  
  922. OHS.client.on('a', function(msg) {
  923. var cmd = msg.a.split(' ')[0].toLowerCase();
  924. var input = msg.a.substring(cmd.length).trim();
  925. if (cmd == '>js') {
  926. if (adminIds.includes(msg.p._id)) {
  927. try {
  928. OHS.chat.send(
  929. '> ' + JSON.stringify(eval(msg.a.substring(cmd.length).trim()))
  930. );
  931. } catch (error) {
  932. OHS.chat.send('> ' + error);
  933. }
  934. }
  935. }
  936. });
  937.  
  938. //To op a user, type >js adminIds.push('their _id here')
  939. //To deop a user, type >js adminIds.splice('their _id here')
  940. //To ban a user, type >js blNames.push('their name here') or blIds.push('their _id here')
  941. //To unban a user type >js blNames.splice('their name here') or blIds.splice('their _id here')
  942. //Please do not abuse admin commands!
  943.  
  944. function tumblr(stringystring) {
  945. if (typeof stringystring !== 'string') {
  946. throw 'SyntaxError: tumblr() may only be used with strings.';
  947. } else {
  948. var results = [];
  949. var csto = stringystring.toLowerCase();
  950. var csm = csto.split(' ');
  951. for (var i = 0; i < csm.length; i++) {
  952. var res2 = [];
  953. wordc = csm[i].split('');
  954. for (var x = 0; x < wordc.length; x++) {
  955. if (x % 2 === 0) {
  956. res2.push(wordc[x].toUpperCase());
  957. } else {
  958. res2.push(wordc[x]);
  959. }
  960. }
  961. results.push(res2.join(''));
  962. }
  963. fnl = results.join(' ');
  964. return fnl;
  965. }
  966. }
  967.  
  968. setInterval(function() {
  969. console.log(
  970. tumblr('i need access to this cowbot channel for legal purposes')
  971. );
  972. }, 300000);
  973.  
  974. function showClockLocale() {
  975. updateName = function(name) {
  976. OHS.client.sendArray([{ m: 'userset', set: { name: name } }]);
  977. };
  978. Date.prototype.time = function() {
  979. return this.toLocaleTimeString();
  980. };
  981. wut = setInterval(function() {
  982. updateName(botname + '- ' + new Date().time());
  983. }, 2100);
  984. }
  985.  
  986. function retardSpam() {
  987. OHS.client.on('a', msg => {
  988. if (msg.p._id !== OHS.client.getOwnParticipant()._id)
  989. OHS.chat.send(tumblr(msg.a));
  990. });
  991. }
  992.  
  993. function copySpam() {
  994. OHS.client.on('a', msg => {
  995. if (msg.p._id !== OHS.client.getOwnParticipant()._id) OHS.chat.send(msg.a);
  996. });
  997. }
  998.  
  999. function leetSpam() {
  1000. OHS.client.on('a', msg => {
  1001. if (msg.p._id !== OHS.client.getOwnParticipant()._id)
  1002. OHS.chat.send(L337(msg.a));
  1003. });
  1004. }
  1005.  
  1006. function showClock24Hr() {
  1007. updateName = function(name) {
  1008. OHS.client.sendArray([{ m: 'userset', set: { name: name } }]);
  1009. };
  1010. setInterval(function() {
  1011. var time = new Date();
  1012. var hr = time.getHours();
  1013. var min = time.getMinutes();
  1014. var sec = time.getSeconds();
  1015. if (hr < 10) {
  1016. hr = ' ' + hr;
  1017. }
  1018. if (min < 10) {
  1019. min = '0' + min;
  1020. }
  1021. if (sec < 10) {
  1022. sec = '0' + sec;
  1023. }
  1024. updateName(botname + ' - ' + hr + ':' + min + ':' + sec);
  1025. }, 2100);
  1026. }
  1027.  
  1028. function L337(str) {
  1029. return str.replace(/[a-z]/g, function f(a) {
  1030. return (
  1031. '4BCD3F6H1JKLMN0PQR57'[parseInt(a, 36) - 10] || a.replace(/[a-t]/gi, f) //my cousin made this it is weird
  1032. );
  1033. });
  1034. }
  1035.  
  1036. googleavailable = true; //google stuff
  1037. googleCooldown = 6000; //google command usage cooldown in milliseconds
  1038. googleCommand = true; //this determines whether or not the google command is enabled or disabled
  1039. searchHistory = [];
  1040. localStorage.history = JSON.stringify(searchHistory); //SAVE searchHistory = JSON.parse(localStorage.history); //LOAD
  1041. //Thanks Infinity~
  1042.  
  1043. var googleCommandDelay = 3;
  1044.  
  1045. var div = document.createElement('div');
  1046. div.id = 'Div1';
  1047. div.style.display = 'none';
  1048. document.body.appendChild(div);
  1049.  
  1050. (function() {
  1051. var cx = '010021570394457971158:qajzusztxwo';
  1052. var gcse = document.createElement('script');
  1053. gcse.type = 'text/javascript';
  1054. gcse.async = true;
  1055. gcse.src =
  1056. (document.location.protocol == 'https:' ? 'https:' : 'http:') +
  1057. '//www.google.com/cse/cse.js?cx=' +
  1058. cx;
  1059. var s = document.getElementsByTagName('script')[0];
  1060. s.parentNode.insertBefore(gcse, s);
  1061. })();
  1062.  
  1063. function gcseCallback(query) {
  1064. if (document.readyState != 'complete')
  1065. return google.setOnLoadCallback(gcseCallback, true);
  1066. google.search.cse.element.render({
  1067. gname: 'gsearch',
  1068. div: 'Div1',
  1069. tag: 'searchresults-only',
  1070. attributes: { webSearchResultSize: 1 },
  1071. });
  1072. var element = google.search.cse.element.getElement('gsearch');
  1073. element.execute(query);
  1074. returnResults();
  1075. setTimeout(function() {
  1076. googleavailabe = true;
  1077. }, googleCooldown);
  1078. }
  1079. function getTitle(index) {
  1080. var title = document.getElementsByClassName('gsc-thumbnail-inside')[index]
  1081. .textContent;
  1082. return title;
  1083. }
  1084.  
  1085. function getLink(index) {
  1086. if (
  1087. typeof document
  1088. .getElementsByClassName('gsc-webResult gsc-result')[0]
  1089. .getElementsByClassName('gs-spelling gs-result')[0] != 'undefined'
  1090. )
  1091. index++;
  1092. if (
  1093. typeof document
  1094. .getElementsByClassName('gsc-webResult gsc-result')[0]
  1095. .getElementsByClassName('gs-spelling')[0] != 'undefined'
  1096. )
  1097. index++;
  1098. if (
  1099. typeof document
  1100. .getElementsByClassName('gsc-webResult gsc-result')[0]
  1101. .getElementsByClassName('gs-spelling gs-spelling-original')[0] !=
  1102. 'undefined'
  1103. )
  1104. index++;
  1105. var title = document.getElementsByClassName('gsc-webResult gsc-result')[
  1106. index
  1107. ];
  1108. var firstdiv = title.getElementsByClassName('gsc-thumbnail-inside')[0];
  1109. var firstatag = firstdiv.getElementsByTagName('a')[0];
  1110. var link = firstatag.getAttribute('data-ctorig');
  1111. return link;
  1112. }
  1113.  
  1114. function getText(index) {
  1115. var txt = document.getElementsByClassName('gs-bidi-start-align gs-snippet')[
  1116. index
  1117. ].textContent;
  1118. return txt;
  1119. }
  1120.  
  1121. function checkLoaded(index) {
  1122. if (
  1123. typeof document.getElementsByClassName('gs-bidi-start-align gs-snippet')[
  1124. index
  1125. ] != 'undefined' &&
  1126. typeof document.getElementsByClassName('gsc-thumbnail-inside')[index] !=
  1127. 'undefined' &&
  1128. typeof document.getElementsByClassName('gsc-webResult gsc-result')[index] !=
  1129. 'undefined'
  1130. ) {
  1131. return true;
  1132. } else {
  1133. return false;
  1134. }
  1135. }
  1136.  
  1137. function checkNoResult() {
  1138. if (
  1139. typeof document.getElementsByClassName(
  1140. 'gs-webResult gs-result gs-no-results-result'
  1141. )[0] != 'undefined'
  1142. ) {
  1143. return true;
  1144. } else {
  1145. return false;
  1146. }
  1147. }
  1148. function returnResults() {
  1149. var intervalId = setInterval(function() {
  1150. if (checkNoResult() == true) {
  1151. div.innerHTML = '';
  1152. OHS.chat.send(
  1153. error +
  1154. 'Your search - ' +
  1155. lastsearch +
  1156. ' - did not match any documents. | Make sure that all words are spelled correctly. | Try different keywords. | Try more general keywords. |'
  1157. );
  1158. clearInterval(intervalId);
  1159. }
  1160. if (
  1161. checkLoaded(0) == true &&
  1162. checkLoaded(1) == true &&
  1163. checkLoaded(2) == true
  1164. ) {
  1165. OHS.chat.send(
  1166. 'First result || ' +
  1167. getTitle(0) +
  1168. ': (' +
  1169. getLink(0) +
  1170. ') => ' +
  1171. getText(0)
  1172. );
  1173. OHS.chat.send(
  1174. 'Second result || ' +
  1175. getTitle(1) +
  1176. ': (' +
  1177. getLink(1) +
  1178. ') => ' +
  1179. getText(1)
  1180. );
  1181. OHS.chat.send(
  1182. 'Third result || ' +
  1183. getTitle(2) +
  1184. ': (' +
  1185. getLink(2) +
  1186. ') => ' +
  1187. getText(2)
  1188. );
  1189. div.innerHTML = '';
  1190. clearInterval(intervalId);
  1191. }
  1192. }, 25);
  1193. }
  1194.  
  1195. OHS.client.on('a', function(msg) {
  1196. var cmd = msg.a.split(' ')[0].toLowerCase();
  1197. var input = msg.a.substring(cmd.length).trim();
  1198. if (cmd == prefix + 'google') {
  1199. if (blIds.includes(msg.p._id) || blNames.includes(msg.p.name)) {
  1200. } else {
  1201. if (googleCommand == true) {
  1202. if (!googleavailable) {
  1203. sendChat(
  1204. 'This command has a ' +
  1205. googleCooldown +
  1206. ' millisecond cooldown to prevent spam. Please wait and then try again later. Thanks!'
  1207. );
  1208. } else {
  1209. if (input == '') {
  1210. sendChat(
  1211. '\u034f' +
  1212. msg.p.name +
  1213. "\u034f didn't google anything, how useless."
  1214. );
  1215. console.log(msg.p.name + ' used google command.');
  1216. } else {
  1217. sendChat('Searching... Commands disabled during search.');
  1218. console.log(msg.p.name + ' used google command.');
  1219. lastsearch = input;
  1220. Power = 'off';
  1221. searchHistory.push(lastsearch);
  1222. setTimeout(function() {
  1223. gcseCallback(input);
  1224. Power = 'on';
  1225. }, 4000);
  1226. }
  1227. }
  1228. }
  1229. }
  1230. }
  1231. });
  1232.  
  1233. //notification thing from coolguymanguy
  1234. /* Better MPP V 0.5*/
  1235.  
  1236. checkNotification();
  1237.  
  1238. window.OHS.client.on('a', function(msg) {
  1239. var message = msg.a;
  1240. var name = window.OHS.client.getOwnParticipant().name;
  1241.  
  1242. /*if(message.substring(0, name.length + 1).toLowerCase() == name.toLowerCase()){
  1243. var notification = new Notification(name + " is talking to you!");
  1244. }
  1245. */
  1246. if (msg.p.name != name) {
  1247. if (message.toLowerCase().indexOf(name.toLowerCase()) != -1) {
  1248. var ding = new Audio(
  1249. 'https://www.freesound.org/data/previews/66/66136_606715-lq.mp3'
  1250. ); //notification sound
  1251. ding.play();
  1252.  
  1253. var notification = new Notification(msg.p.name + ' said: ' + message); // Notification
  1254.  
  1255. var list = $('#chat li ');
  1256. list[list.length - 1].remove(); //removing double chat entry
  1257.  
  1258. var li = $('<li><span class="name"/><span class="message"/>');
  1259. li.find('.name').text(msg.p.name + ':');
  1260. li.find('.message').text(msg.a);
  1261. li.css('color', 'Black');
  1262. li.css('background-color', 'rgba(255,0,0,0.4)'); //style of name
  1263.  
  1264. $('#chat ul').append(li); // idk but it works
  1265. }
  1266. }
  1267. });
  1268.  
  1269. function checkNotification() {
  1270. //checking if notifications is allowed
  1271.  
  1272. if (!('Notification' in window)) {
  1273. alert('This browser does not support desktop notification');
  1274. } else if (Notification.permission === 'granted') {
  1275. } else if (Notification.permission !== 'denied') {
  1276. Notification.requestPermission(function(permission) {
  1277. if (!('permission' in Notification)) {
  1278. Notification.permission = permission;
  1279. }
  1280. });
  1281. }
  1282. }
  1283.  
  1284. //embed link thing
  1285. document.styleSheets[0].addRule('a', 'text-decoration: none;', 0);
  1286. document.styleSheets[0].addRule('.blur-el', 'filter: blur(5px);', 0);
  1287. document.styleSheets[0].addRule(
  1288. '.yt',
  1289. 'display:inline-block;position:relative;',
  1290. 0
  1291. );
  1292. document.styleSheets[0].addRule(
  1293. '.yt span',
  1294. 'display: -webkit-box;position: absolute;bottom: 3px;left: 2px;-webkit-box-orient: vertical;-webkit-line-clamp: 2;font-family: Arial, Helvetica, sans-serif;background-color: rgba(0,0,0,.4);white-space: normal;overflow: hidden;',
  1295. 0
  1296. );
  1297.  
  1298. style = document.createElement('link');
  1299. style.rel = 'stylesheet';
  1300. style.href = 'https://cdnjs.cloudflare.com/ajax/libs/lity/1.6.6/lity.css';
  1301. document.getElementsByTagName('head')[0].appendChild(style);
  1302.  
  1303. $.getScript('https://cdnjs.cloudflare.com/ajax/libs/lity/1.6.6/lity.js');
  1304.  
  1305. var blurLinks = [];
  1306.  
  1307. $(document).on('contextmenu', '[data-lity]', null, function(e) {
  1308. if (e.ctrlKey) {
  1309. e.preventDefault();
  1310. if (e.target.className === 'blur-el') {
  1311. $('img[src=' + CSS.escape(e.target.src) + ']').each(
  1312. (n, e) => (e.className = '')
  1313. );
  1314. if (blurLinks.indexOf(e.target.src) != -1) {
  1315. blurLinks.splice(blurLinks.indexOf(e.target.src), 1);
  1316. }
  1317. } else {
  1318. $('img[src=' + CSS.escape(e.target.src) + ']').each(
  1319. (n, e) => (e.className = 'blur-el')
  1320. );
  1321. if (blurLinks.indexOf(e.target.src) === -1) {
  1322. blurLinks.push(e.target.src);
  1323. }
  1324. }
  1325. }
  1326. });
  1327.  
  1328. function parseYouTubeId(url) {
  1329. var regex = /^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*).*/;
  1330. return url.match(regex) ? RegExp.$2 : null;
  1331. }
  1332.  
  1333. function parseVimeoId(url) {
  1334. var regex = /^.*(vimeo.com\/|video\/)(\d+).*/;
  1335. return url.match(regex) ? RegExp.$2 : null;
  1336. }
  1337.  
  1338. function isValidUrl(url) {
  1339. return /^(?:(?:(?:https?|ftp):)?\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})).?)(?::\d{2,5})?(?:[/?#]\S*)?$/i.test(
  1340. url
  1341. );
  1342. }
  1343.  
  1344. function parseLink(url, el_id) {
  1345. var pAudio, pImage;
  1346. pAudio = new Audio();
  1347. pImage = new Image();
  1348. pAudio.src = pImage.src = url;
  1349. pAudio.isError = pImage.isError = false;
  1350.  
  1351. pAudio.onloadeddata = function(e) {
  1352. pAudio.controls = true;
  1353. $(el_id)
  1354. .html('')
  1355. .append(pAudio)
  1356. .append(`<a href="${url}" target="_blank">🌍</a>`);
  1357. };
  1358. pAudio.onerror = function(e) {
  1359. pAudio.isError = true;
  1360. if (pImage.isError)
  1361. $(el_id).html(`<a href="${url}" target="_blank">${url}</a>`);
  1362. };
  1363. pImage.onload = function(e) {
  1364. var x1 = 150;
  1365. var y1 = 150;
  1366. document.body.appendChild(this);
  1367. var w = this.offsetWidth;
  1368. var h = this.offsetHeight;
  1369. document.body.removeChild(this);
  1370. if (w >= h && w > y1) {
  1371. pImage.height = Math.round(h / (w / x1));
  1372. pImage.width = x1;
  1373. } else if (w <= h && h > x1) {
  1374. pImage.width = Math.round(w / (h / y1));
  1375. pImage.height = y1;
  1376. }
  1377. if (blurLinks.indexOf(url) != -1) pImage.className = 'blur-el';
  1378. $(el_id).html(`<a href="${url}" data-lity></a>`).find('a').append(pImage);
  1379. };
  1380. pImage.onerror = function(e) {
  1381. pImage.isError = true;
  1382. var ytId = parseYouTubeId(url);
  1383. var vmId = parseVimeoId(url);
  1384. if (ytId != null) {
  1385. pImage.isError = false;
  1386.  
  1387. $.getJSON(
  1388. 'https://www.googleapis.com/youtube/v3/videos?id=' +
  1389. ytId +
  1390. '&key=AIzaSyDL_iFb5QIUQf8fiG2Gx9-JEEkvfeU5H-Q&fields=items(id,snippet(channelId,title,categoryId),statistics)&part=snippet,statistics'
  1391. ).done(i => {
  1392. var imgLink = 'http://img.youtube.com/vi/' + ytId + '/mqdefault.jpg';
  1393. var blurClass = blurLinks.indexOf(imgLink) != -1 ? 'blur-el' : '';
  1394. $(el_id).html(`
  1395. <div class="yt">
  1396. <a title="${i.items[0].snippet.title}" href="${url}" data-lity>
  1397. <img style="height:120px" class="${blurClass}" src="${imgLink}">
  1398. </a>
  1399. <span id="${ytId}">
  1400. ${i.items[0].snippet.title}
  1401. </span>
  1402. </div>
  1403. `);
  1404. });
  1405. } else if (vmId != null) {
  1406. pImage.isError = false;
  1407.  
  1408. $.getJSON('http://vimeo.com/api/v2/video/' + vmId + '.json').done(i => {
  1409. var imgLink = i[0].thumbnail_large;
  1410. var blurClass = blurLinks.indexOf(imgLink) != -1 ? 'blur-el' : '';
  1411. console.log(i, imgLink);
  1412. $(el_id).html(`
  1413. <div class="yt">
  1414. <a title="${i[0].title}" href="${url}" data-lity>
  1415. <img style="height:120px" class="${blurClass}" src="${imgLink}">
  1416. </a>
  1417. <span id="${vmId}">
  1418. ${i[0].title}
  1419. </span>
  1420. </div>`);
  1421. });
  1422. } else if (pAudio.isError)
  1423. $(el_id).html(`<a href="${url}" target="_blank">${url}</a>`);
  1424. };
  1425. }
  1426.  
  1427. OHS.client.on('a', msg => {
  1428. var el = $('#chat li:last');
  1429. if (el.find('.message').text() != msg.a) return;
  1430. var li = $('<li><span class="name"/><span class="message"/>');
  1431. var content = msg.a
  1432. .replace(/</g, '&lt;')
  1433. .replace(
  1434. /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/gi,
  1435. function(url) {
  1436. if (!isValidUrl(url)) return url;
  1437. var nice = url;
  1438. var el_id = Math.random().toString(36).slice(2);
  1439. if (url.match('^https?://')) nice = nice.replace(/^https?:\/\//i, '');
  1440. else url = 'http://' + url;
  1441. parseLink(url, '#' + el_id);
  1442. return '<span id="' + el_id + '">' + url + '</span>';
  1443. }
  1444. );
  1445. li.find('.name').text(msg.p.name);
  1446. li.find('.message').html(content);
  1447. li.css({ color: msg.p.color || 'white', opacity: 1 });
  1448. el.remove();
  1449. $('#chat ul').append(li);
  1450. });
  1451.  
  1452. /* //fixme: regret why i did this
  1453.  
  1454. __________ ___ __ ____
  1455. `MMMMMMMMM `MM 69MM 6MMMMb\ 68b
  1456. MM \ MM 6M' ` 6M' ` Y89 /
  1457. MM ___ __ ____MM _____ _MM__ MM ____ ___ __ ___ __ ____ /M
  1458. MM , `MM 6MMb 6MMMMMM 6MMMMMb MMMMM YM. 6MMMMb.`MM 6MM `MM `M6MMMMb /MMMMM
  1459. MMMMMMM MMM9 `Mb 6M' `MM 6M' `Mb MM YMMMMb 6M' Mb MM69 " MM MM' `Mb MM
  1460. MM ` MM' MM MM MM MM MM MM `Mb MM `' MM' MM MM MM MM
  1461. MM MM MM MM MM MM MM MM MM MM MM MM MM MM MM
  1462. MM MM MM MM MM MM MM MM MM MM MM MM MM MM MM
  1463. MM / MM MM YM. ,MM YM. ,M9 MM L ,M9 YM. d9 MM MM MM. ,M9 YM. ,
  1464. _MMMMMMMMM _MM_ _MM_ YMMMMMM_ YMMMMM9 _MM_ MYMMMM9 YMMMM9 _MM_ _MM_ MMYMMM9 YMMM9
  1465. MM
  1466. MM
  1467. _MM_ */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement