-
Notifications
You must be signed in to change notification settings - Fork 1
/
background.js
2844 lines (2784 loc) · 69.8 KB
/
background.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
var isExtensionOn = false;
var iframe = null;
var channel = null;
var settings = {};
var messageTimeout = 0;
var lastSentMessage = "";
var lastSentTimestamp = 0;
var lastMessageCounter = 0;
function generateStreamID(){
var text = "";
var possible = "ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnpqrstuvwxyz23456789";
for (var i = 0; i < 10; i++){
text += possible.charAt(Math.floor(Math.random() * possible.length));
}
try{
text = text.replaceAll('AD', 'vDAv'); // avoiding adblockers
text = text.replaceAll('Ad', 'vdAv');
text = text.replaceAll('ad', 'vdav');
text = text.replaceAll('aD', 'vDav');
} catch(e){console.log(e);}
return text;
};
var properties = ["streamID", "isExtensionOn"];
channel = generateStreamID();
chrome.storage.sync.get(properties, function(item){
if (item && item.streamID){
channel = item.streamID;
} else {
chrome.storage.sync.set({
streamID: channel
});
chrome.runtime.lastError;
}
if (item && item.settings){
settings = item.settings;
}
if (item && item.isExtensionOn){
isExtensionOn = item.isExtensionOn;
chrome.browserAction.setIcon({path: "/icons/on.png"});
if (iframe==null){
loadIframe(channel);
}
} else {
chrome.storage.sync.set({
isExtensionOn: isExtensionOn
});
chrome.runtime.lastError;
}
toggleMidi();
});
chrome.browserAction.setIcon({path: "/icons/off.png"});
function pushSettingChange(setting){
chrome.tabs.query({}, function(tabs) {
chrome.runtime.lastError;
for (var i=0;i<tabs.length;i++){
if (!tabs[i].url){continue;}
chrome.tabs.sendMessage(tabs[i].id, setting, function(response=false) {
chrome.runtime.lastError;
});
}
});
}
chrome.runtime.onMessage.addListener(
function (request, sender, sendResponse) {
try{
if (request.cmd && request.cmd === "setOnOffState") { // toggle the IFRAME (stream to the remote dock) on or off
isExtensionOn = request.data.value;
if (isExtensionOn){
if (iframe==null){
loadIframe(channel);
}
} else {
if (iframe.src){
iframe.src = null;
}
iframe.remove();
iframe = null;
}
chrome.storage.sync.set({
isExtensionOn: isExtensionOn
});
chrome.runtime.lastError;
toggleMidi();
sendResponse({"state":isExtensionOn,"streamID":channel, "settings":settings});
} else if (request.cmd && request.cmd === "getOnOffState") {
sendResponse({"state":isExtensionOn,"streamID":channel, "settings":settings});
} else if (request.cmd && request.cmd === "saveSetting") {
settings[request.setting] = request.value;
chrome.storage.sync.set(settings);
chrome.runtime.lastError;
sendResponse({"state":isExtensionOn});
if (request.setting == "midi"){
toggleMidi();
}
if (request.setting == "textonlymode"){
if (request.value){
pushSettingChange("textOnlyMode");
} else {
pushSettingChange("richTextMode");
}
}
} else if ("message" in request) { // forwards messages from Youtube/Twitch/Facebook to the remote dock via the VDO.Ninja API
request.message.tid = sender.tab.id; // including the source (tab id) of the social media site the data was pulled from
sendResponse({"state":isExtensionOn}); // respond to Youtube/Twitch/Facebook with the current state of the plugin; just as possible confirmation.
if (isExtensionOn){
if (!settings.discord){
try {
if (request.message.type == "discord"){
return;
}
} catch(e){}
}
try{
applyBotActions(request.message); // perform any immediate actions
} catch(e){console.log(e);}
if (("firstsourceonly" in settings) && settings.firstsourceonly){
if (verifyOriginal(request.message)){
sendDataP2P(request.message); // send the data to the dock
}
} else {
sendDataP2P(request.message);
}
}
} else if ("getSettings" in request) { // forwards messages from Youtube/Twitch/Facebook to the remote dock via the VDO.Ninja API
sendResponse({"settings":settings}); // respond to Youtube/Twitch/Facebook with the current state of the plugin; just as possible confirmation.
} else if (request.cmd && request.cmd === "tellajoke") {
tellAJoke();
sendResponse({"state":isExtensionOn});
} else if (request.cmd && request.cmd === "sidUpdated") {
if (request.value){
channel = request.value;
}
if (iframe){
if (iframe.src){
iframe.src = null;
}
iframe.remove();
iframe = null;
}
if (isExtensionOn){
loadIframe(channel);
}
sendResponse({"state":isExtensionOn});
} else {
sendResponse({"state":isExtensionOn});
}
} catch(e){}
}
);
// The below "levenshtein" function is based on the follow work:
// https://github.com/gustf/js-levenshtein
// MIT License - Requires preservation of copyright and license notice
// Copyright (c) 2017 Gustaf Andersson
function levenshtein(a,b){
if (a === b) {
return 0;
}
if (a.length > b.length) {
var tmp = a;
a = b;
b = tmp;
}
var la = a.length;
var lb = b.length;
while (la > 0 && (a.charCodeAt(la - 1) === b.charCodeAt(lb - 1))) {
la--;
lb--;
}
var offset = 0;
while (offset < la && (a.charCodeAt(offset) === b.charCodeAt(offset))) {
offset++;
}
la -= offset;
lb -= offset;
if (la === 0 || lb < 3) {
return lb;
}
var x = 0;
var y;
var d0;
var d1;
var d2;
var d3;
var dd;
var dy;
var ay;
var bx0;
var bx1;
var bx2;
var bx3;
var vector = [];
for (y = 0; y < la; y++) {
vector.push(y + 1);
vector.push(a.charCodeAt(offset + y));
}
var len = vector.length - 1;
for (; x < lb - 3;) {
bx0 = b.charCodeAt(offset + (d0 = x));
bx1 = b.charCodeAt(offset + (d1 = x + 1));
bx2 = b.charCodeAt(offset + (d2 = x + 2));
bx3 = b.charCodeAt(offset + (d3 = x + 3));
dd = (x += 4);
for (y = 0; y < len; y += 2) {
dy = vector[y];
ay = vector[y + 1];
d0 = _min(dy, d0, d1, bx0, ay);
d1 = _min(d0, d1, d2, bx1, ay);
d2 = _min(d1, d2, d3, bx2, ay);
dd = _min(d2, d3, dd, bx3, ay);
vector[y] = dd;
d3 = d2;
d2 = d1;
d1 = d0;
d0 = dy;
}
}
for (; x < lb;) {
bx0 = b.charCodeAt(offset + (d0 = x));
dd = ++x;
for (y = 0; y < len; y += 2) {
dy = vector[y];
vector[y] = dd = _min(dy, d0, dd, bx0, vector[y + 1]);
d0 = dy;
}
}
return dd;
}
function _min(d0, d1, d2, bx, ay){
return d0 < d1 || d2 < d1
? d0 > d2
? d2 + 1
: d0 + 1
: bx === ay
? d1
: d1 + 1;
}
//// End of levenshtein code
////////////////////////////
function verifyOriginal(msg){
try {
console.log(Date.now(), lastSentTimestamp, Date.now() - lastSentTimestamp);
if (Date.now() - lastSentTimestamp > 5000){ // 2 seconds has passed; assume good.
return true;
}
console.log( cleanText + " | " +lastSentMessage);
console.log(msg.chatmessage);
var cleanText = msg.chatmessage.replace(/<\/?[^>]+(>|$)/g, ""); // clean up; remove HTML tags, etc.
cleanText = cleanText.replace(/\s\s+/g, ' ');
var score = levenshtein(cleanText, lastSentMessage);
// levenshtein(a,b)
console.log("score: "+score+ " - "+ cleanText + " | " +lastSentMessage);
if (score<7){
if (lastMessageCounter){return false;}
lastMessageCounter=1;
} else {
return false;
}
} catch(e){console.error(e);}
return true;
}
function sendDataP2P(data){ // function to send data to the DOCk via the VDO.Ninja API
var msg = {};
msg.overlayNinja = {};
msg.overlayNinja = data;
try {
iframe.contentWindow.postMessage({"sendData":msg, "type": "pcs"}, '*'); // send only to 'viewers' of this stream
} catch(e){}
}
function loadIframe(channel){ // this is pretty important if you want to avoid camera permission popup problems. You can also call it automatically via: <body onload=>loadIframe();"> , but don't call it before the page loads.
iframe = document.createElement("iframe");
iframe.src = "https://vdo.we-keys.fr/?password=false&room="+channel+"&push="+channel+"&vd=0&ad=0&autostart&cleanoutput&view"; // don't listen to any inbound events
document.body.appendChild(iframe);
}
var eventMethod = window.addEventListener ? "addEventListener" : "attachEvent"; // lets us listen to the VDO.Ninja IFRAME API; ie: lets us talk to the dock
var eventer = window[eventMethod];
var messageEvent = eventMethod === "attachEvent" ? "onmessage" : "message";
var debuggerEnabled = {};
var commandCounter = 0;
function onDetach(debuggeeId) { // for faking user input
debuggerEnabled[debuggeeId.tabId] = false;
}
try{
chrome.debugger.onDetach.addListener(onDetach);
} catch(e){
console.log("'chrome.debugger' not supported by this browser");
}
function onAttach(debuggeeId, callback, message) { // for faking user input
if (chrome.runtime.lastError) {
console.log(chrome.runtime.lastError.message);
return;
}
debuggerEnabled[debuggeeId.tabId] = true;
callback(debuggeeId.tabId, message);
}
eventer(messageEvent, function (e) {
if ("dataReceived" in e.data){ // raw data
if ("overlayNinja" in e.data.dataReceived){
if ("response" in e.data.dataReceived.overlayNinja){ // we receieved a response from the dock
processResponse(e.data.dataReceived.overlayNinja);
}
}
}
});
function processResponse(data){
if (!chrome.debugger){return;}
if (!isExtensionOn){return;} // extension not active, so don't let responder happen. Probably safer this way.
chrome.tabs.query({}, function(tabs) {
chrome.runtime.lastError;
var published = {};
for (var i=0;i<tabs.length;i++){
try {
if (("tid" in data) && (data.tid!==false)){ // if an action-response, we want to only respond to the tab that originated it
if ( data.tid !== tabs[i].id){continue;}
}
if (!tabs[i].url){continue;}
if (tabs[i].url in published){continue;} // skip. we already published to this tab.
published[tabs[i].url] = true;
messageTimeout = Date.now();
if (tabs[i].url.startsWith("https://www.twitch.tv/popout/")){ // twitch, but there's also cases for youtube/facebook
if (!debuggerEnabled[tabs[i].id]){
debuggerEnabled[tabs[i].id]=false;
chrome.debugger.attach( { tabId: tabs[i].id }, "1.3", onAttach.bind(null, { tabId: tabs[i].id }, generalFakeChat, data.response, false)); // enable the debugger to let us fake a user
} else {
generalFakeChat(tabs[i].id, data.response, false);
}
} else { // all other destinations. ; generic
if (!debuggerEnabled[tabs[i].id]){
debuggerEnabled[tabs[i].id]=false;
chrome.debugger.attach( { tabId: tabs[i].id }, "1.3", onAttach.bind(null, { tabId: tabs[i].id }, generalFakeChat, data.response, true)); // enable the debugger to let us fake a user
} else {
generalFakeChat(tabs[i].id, data.response, true);
}
}
} catch(e){
chrome.runtime.lastError;
console.log(e);
}
}
});
}
function generalFakeChat(tabid, message, middle=true){ // fake a user input
try{
chrome.tabs.sendMessage(tabid, "focusChat", function(response=false) {
chrome.runtime.lastError;
if (!response){
if (debuggerEnabled[tabid]){
chrome.debugger.detach({ tabId: tabid }, onDetach.bind(null, { tabId: tabid }));
}
return;
}; // make sure the response is valid, else don't inject text
lastSentMessage = message.replace(/<\/?[^>]+(>|$)/g, ""); // keep a cleaned copy
lastSentMessage = lastSentMessage.replace(/\s\s+/g, ' ');
lastSentTimestamp = Date.now();
lastMessageCounter = 0;
chrome.debugger.sendCommand({ tabId:tabid }, "Input.insertText", { text: message }, function (e) {});
chrome.debugger.sendCommand({ tabId:tabid }, "Input.dispatchKeyEvent", {
"type": "keyDown",
"key": "Enter",
"code": "Enter",
"nativeVirtualKeyCode": 13,
"windowsVirtualKeyCode": 13
}, function (e) {});
if (middle){
chrome.debugger.sendCommand({ tabId:tabid }, "Input.dispatchKeyEvent", {
"type": "char",
"key": "Enter",
"text": "\r",
"code": "Enter",
"nativeVirtualKeyCode": 13,
"windowsVirtualKeyCode": 13
}, function (e) {
});
}
chrome.debugger.sendCommand({ tabId:tabid }, "Input.dispatchKeyEvent", {
"type": "keyUp",
"key": "Enter",
"code": "Enter",
"nativeVirtualKeyCode": 13,
"windowsVirtualKeyCode": 13
}, function (e) {
if (debuggerEnabled[tabid]){
chrome.debugger.detach({ tabId: tabid }, onDetach.bind(null, { tabId: tabid }));
}
}
);
});
} catch(e){
console.log(e);
if (debuggerEnabled[tabid]){
chrome.debugger.detach({ tabId: tabid }, onDetach.bind(null, { tabId: tabid }));
}
}
}
////////////////////
function applyBotActions(data){ // this can be customized to create bot-like auto-responses/actions.
// data.tid,, => processResponse({tid:N, response:xx})
if (settings.autohi){
if (data.chatmessage.toLowerCase() === "hi"){
if (Date.now() - messageTimeout > 60000){ // respond to "1" with a "1" automatically; at most 1 time per minute.
messageTimeout = Date.now();
data.response = "Hi, @"+data.chatname+" !";
processResponse(data);
}
}
}
if (settings.joke && (data.chatmessage.toLowerCase() === "!joke")){
if (Date.now() - messageTimeout > 5100){
var score = parseInt(Math.random()* 378);
var joke = jokes[score];
messageTimeout = Date.now();
data.response = "@"+data.chatname+", "+joke["setup"];
processResponse(data);
setTimeout(function(msg, punch){
msg.response = punch;
processResponse(msg);
},5000, data, "@"+data.chatname+".. "+joke["punchline"]);
}
}
}
var MidiInit = false;
try {
function setupMIDI(MidiInput=false){ // setting up MIDI hotkey support.
var midiChannel = 1;
if (MidiInput){
MidiInput.addListener('controlchange', function(e) {
midiHotkeysCommand(e.controller.number, e.rawValue);
});
MidiInput.addListener('noteon', function(e) {
var note = e.note.name + e.note.octave;
var velocity = e.velocity || false;
midiHotkeysNote(note,velocity);
});
} else {
for (var i = 0; i < WebMidi.inputs.length; i++) {
MidiInput = WebMidi.inputs[i];
MidiInput.addListener('controlchange', function(e) {
if (settings.midi && isExtensionOn){
midiHotkeysCommand(e.controller.number, e.rawValue);
}
});
MidiInput.addListener('noteon', function(e) {
if (settings.midi && isExtensionOn){
var note = e.note.name + e.note.octave;
var velocity = e.velocity || false;
midiHotkeysNote(note,velocity);
}
});
}
}
}
function toggleMidi(){
if (!("midi" in settings)){return;}
if (settings.midi){
if (MidiInit===false){
MidiInit=true;
WebMidi.enable().then(() =>{
setupMIDI();
WebMidi.addListener("connected", function(e) {
console.log(e);
setupMIDI(e.target._midiInput);
});
WebMidi.addListener("disconnected", function(e) {
console.log(e);
});
console.log(WebMidi.inputs);
});
} else {
try {
WebMidi.enable();
} catch(e){}
}
} else if (MidiInit){
try {
WebMidi.disable();
} catch(e){}
}
}
} catch(e){console.log(e);}
function midiHotkeysCommand(number, value){ // MIDI control change commands
if (number == 102 && value == 1){
respond1ToAll();
} else if (number == 102 && value == 2){
respondLULToAll();
} else if (number == 102 && value == 3){
tellAJoke();
} else if (number == 102 && value == 4){
var msg = {};
msg.forward = false;
sendDataP2P(msg);
}
}
function midiHotkeysNote(note, velocity){
// In case you want to use NOTES instead of Control Change commands; like if you have a MIDI piano
}
function tellAJoke(){
var score = parseInt(Math.random()* 378);
var joke = jokes[score];
messageTimeout = Date.now();
var data = {};
data.response = joke["setup"] + ".. " + joke["punchline"] + " LUL";
processResponse(data);
}
function respond1ToAll(){
messageTimeout = Date.now();
var data = {};
data.response = "1";
processResponse(data);
}
function respondLULToAll(){
messageTimeout = Date.now();
var data = {};
data.response = "LUL";
processResponse(data);
}
var jokes = [ // jokes from reddit; sourced from github.
{
"id": 1,
"type": "general",
"setup": "What did the fish say when it hit the wall?",
"punchline": "Dam."
},
{
"id": 2,
"type": "general",
"setup": "How do you make a tissue dance?",
"punchline": "You put a little boogie on it."
},
{
"id": 3,
"type": "general",
"setup": "What's Forrest Gump's password?",
"punchline": "1Forrest1"
},
{
"id": 4,
"type": "general",
"setup": "What do you call a belt made out of watches?",
"punchline": "A waist of time."
},
{
"id": 5,
"type": "general",
"setup": "Why can't bicycles stand on their own?",
"punchline": "They are two tired"
},
{
"id": 6,
"type": "general",
"setup": "How does a train eat?",
"punchline": "It goes chew, chew"
},
{
"id": 7,
"type": "general",
"setup": "What do you call a singing Laptop",
"punchline": "A Dell"
},
{
"id": 8,
"type": "general",
"setup": "How many lips does a flower have?",
"punchline": "Tulips"
},
{
"id": 9,
"type": "general",
"setup": "How do you organize an outer space party?",
"punchline": "You planet"
},
{
"id": 10,
"type": "general",
"setup": "What kind of shoes does a thief wear?",
"punchline": "Sneakers"
},
{
"id": 11,
"type": "general",
"setup": "What's the best time to go to the dentist?",
"punchline": "Tooth hurty."
},
{
"id": 12,
"type": "knock-knock",
"setup": "Knock knock. \n Who's there? \n A broken pencil. \n A broken pencil who?",
"punchline": "Never mind. It's pointless."
},
{
"id": 13,
"type": "knock-knock",
"setup": "Knock knock. \n Who's there? \n Cows go. \n Cows go who?",
"punchline": "No, cows go moo."
},
{
"id": 14,
"type": "knock-knock",
"setup": "Knock knock. \n Who's there? \n Little old lady. \n Little old lady who?",
"punchline": "I didn't know you could yodel!"
},
{
"id": 15,
"type": "programming",
"setup": "What's the best thing about a Boolean?",
"punchline": "Even if you're wrong, you're only off by a bit."
},
{
"id": 16,
"type": "programming",
"setup": "What's the object-oriented way to become wealthy?",
"punchline": "Inheritance"
},
{
"id": 17,
"type": "programming",
"setup": "Where do programmers like to hangout?",
"punchline": "The Foo Bar."
},
{
"id": 18,
"type": "programming",
"setup": "Why did the programmer quit his job?",
"punchline": "Because he didn't get arrays."
},
{
"id": 19,
"type": "general",
"setup": "Did you hear about the two silk worms in a race?",
"punchline": "It ended in a tie."
},
{
"id": 20,
"type": "general",
"setup": "What do you call a laughing motorcycle?",
"punchline": "A Yamahahahaha."
},
{
"id": 21,
"type": "general",
"setup": "A termite walks into a bar and says...",
"punchline": "'Where is the bar tended?'"
},
{
"id": 22,
"type": "general",
"setup": "What does C.S. Lewis keep at the back of his wardrobe?",
"punchline": "Narnia business!"
},
{
"id": 23,
"type": "programming",
"setup": "Why do programmers always mix up Halloween and Christmas?",
"punchline": "Because Oct 31 == Dec 25"
},
{
"id": 24,
"type": "programming",
"setup": "A SQL query walks into a bar, walks up to two tables and asks...",
"punchline": "'Can I join you?'"
},
{
"id": 25,
"type": "programming",
"setup": "How many programmers does it take to change a lightbulb?",
"punchline": "None that's a hardware problem"
},
{
"id": 26,
"type": "programming",
"setup": "If you put a million monkeys at a million keyboards, one of them will eventually write a Java program",
"punchline": "the rest of them will write Perl"
},
{
"id": 27,
"type": "programming",
"setup": "['hip', 'hip']",
"punchline": "(hip hip array)"
},
{
"id": 28,
"type": "programming",
"setup": "To understand what recursion is...",
"punchline": "You must first understand what recursion is"
},
{
"id": 29,
"type": "programming",
"setup": "There are 10 types of people in this world...",
"punchline": "Those who understand binary and those who don't"
},
{
"id": 30,
"type": "general",
"setup": "What did the duck say when he bought lipstick?",
"punchline": "Put it on my bill"
},
{
"id": 31,
"type": "general",
"setup": "What happens to a frog's car when it breaks down?",
"punchline": "It gets toad away"
},
{
"id": 32,
"type": "general",
"setup": "did you know the first French fries weren't cooked in France?",
"punchline": "they were cooked in Greece"
},
{
"id": 33,
"type": "programming",
"setup": "Which song would an exception sing?",
"punchline": "Can't catch me - Avicii"
},
{
"id": 34,
"type": "knock-knock",
"setup": "Knock knock. \n Who's there? \n Opportunity.",
"punchline": "That is impossible. Opportunity doesn’t come knocking twice!"
},
{
"id": 35,
"type": "programming",
"setup": "Why do Java programmers wear glasses?",
"punchline": "Because they don't C#"
},
{
"id": 36,
"type": "general",
"setup": "Why did the mushroom get invited to the party?",
"punchline": "Because he was a fungi."
},
{
"id": 37,
"type": "general",
"setup": "Why did the mushroom get invited to the party?",
"punchline": "Because he was a fungi."
},
{
"id": 38,
"type": "general",
"setup": "I'm reading a book about anti-gravity...",
"punchline": "It's impossible to put down"
},
{
"id": 39,
"type": "general",
"setup": "If you're American when you go into the bathroom, and American when you come out, what are you when you're in there?",
"punchline": "European"
},
{
"id": 40,
"type": "general",
"setup": "Want to hear a joke about a piece of paper?",
"punchline": "Never mind...it's tearable"
},
{
"id": 41,
"type": "general",
"setup": "I just watched a documentary about beavers.",
"punchline": "It was the best dam show I ever saw"
},
{
"id": 42,
"type": "general",
"setup": "If you see a robbery at an Apple Store...",
"punchline": "Does that make you an iWitness?"
},
{
"id": 43,
"type": "general",
"setup": "A ham sandwhich walks into a bar and orders a beer. The bartender says...",
"punchline": "I'm sorry, we don't serve food here"
},
{
"id": 44,
"type": "general",
"setup": "Why did the Clydesdale give the pony a glass of water?",
"punchline": "Because he was a little horse"
},
{
"id": 45,
"type": "general",
"setup": "If you boil a clown...",
"punchline": "Do you get a laughing stock?"
},
{
"id": 46,
"type": "general",
"setup": "Finally realized why my plant sits around doing nothing all day...",
"punchline": "He loves his pot."
},
{
"id": 47,
"type": "general",
"setup": "Don't look at the eclipse through a colander.",
"punchline": "You'll strain your eyes."
},
{
"id": 48,
"type": "general",
"setup": "I bought some shoes from a drug dealer.",
"punchline": "I don't know what he laced them with, but I was tripping all day!"
},
{
"id": 49,
"type": "general",
"setup": "Why do chicken coops only have two doors?",
"punchline": "Because if they had four, they would be chicken sedans"
},
{
"id": 50,
"type": "general",
"setup": "What do you call a factory that sells passable products?",
"punchline": "A satisfactory"
},
{
"id": 51,
"type": "general",
"setup": "When a dad drives past a graveyard: Did you know that's a popular cemetery?",
"punchline": "Yep, people are just dying to get in there"
},
{
"id": 52,
"type": "general",
"setup": "Why did the invisible man turn down the job offer?",
"punchline": "He couldn't see himself doing it"
},
{
"id": 53,
"type": "general",
"setup": "How do you make holy water?",
"punchline": "You boil the hell out of it"
},
{
"id": 54,
"type": "general",
"setup": "I had a dream that I was a muffler last night.",
"punchline": "I woke up exhausted!"
},
{
"id": 55,
"type": "general",
"setup": "Why is peter pan always flying?",
"punchline": "Because he neverlands"
},
{
"id": 56,
"type": "programming",
"setup": "How do you check if a webpage is HTML5?",
"punchline": "Try it out on Internet Explorer"
},
{
"id": 57,
"type": "general",
"setup": "What do you call a cow with no legs?",
"punchline": "Ground beef!"
},
{
"id": 58,
"type": "general",
"setup": "I dropped a pear in my car this morning.",
"punchline": "You should drop another one, then you would have a pair."
},
{
"id": 59,
"type": "general",
"setup": "Lady: How do I spread love in this cruel world?",
"punchline": "Random Dude: [...💘]"
},
{
"id": 60,
"type": "programming",
"setup": "A user interface is like a joke.",
"punchline": "If you have to explain it then it is not that good."
},
{
"id": 61,
"type": "knock-knock",
"setup": "Knock knock. \n Who's there? \n Hatch. \n Hatch who?",
"punchline": "Bless you!"
},
{
"id": 62,
"type": "general",
"setup": "What do you call sad coffee?",
"punchline": "Despresso."
},
{
"id": 63,
"type": "general",
"setup": "Why did the butcher work extra hours at the shop?",
"punchline": "To make ends meat."
},
{
"id": 64,
"type": "general",
"setup": "Did you hear about the hungry clock?",
"punchline": "It went back four seconds."
},
{
"id": 65,
"type": "general",
"setup": "Well...",
"punchline": "That’s a deep subject."
},
{
"id": 66,
"type": "general",
"setup": "Did you hear the story about the cheese that saved the world?",
"punchline": "It was legend dairy."
},
{
"id": 67,
"type": "general",
"setup": "Did you watch the new comic book movie?",
"punchline": "It was very graphic!"
},
{
"id": 68,
"type": "general",
"setup": "I started a new business making yachts in my attic this year...",
"punchline": "The sails are going through the roof."
},
{
"id": 69,
"type": "general",
"setup": "I got hit in the head by a soda can, but it didn't hurt that much...",
"punchline": "It was a soft drink."
},
{
"id": 70,
"type": "general",
"setup": "I can't tell if i like this blender...",
"punchline": "It keeps giving me mixed results."
},
{
"id": 71,
"type": "general",
"setup": "I couldn't get a reservation at the library...",
"punchline": "They were fully booked."
},
{
"id": 72,