-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontent.js
More file actions
1060 lines (910 loc) · 34.8 KB
/
Copy pathcontent.js
File metadata and controls
1060 lines (910 loc) · 34.8 KB
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
// Slop or Not - LinkedIn AI Content Detector
(function() {
'use strict';
const DEBUG = false;
const log = (...args) => DEBUG && console.log('[Slop or Not]', ...args);
class SlopDetector {
constructor() {
this.analyzedPosts = new Set();
this.pendingPosts = new Map(); // postId -> {element, truncatedLength}
this.stats = { total: 0, scores: { 1: 0, 2: 0 } };
this.scanTimeout = null;
this.loadStats().then(() => this.init());
}
async loadStats() {
try {
if (chrome?.storage?.local) {
const result = await chrome.storage.local.get(['slopStats']);
if (result.slopStats) {
this.stats = result.slopStats;
log('Loaded stats from storage:', this.stats);
}
}
} catch (e) {
log('Could not load stats:', e);
}
}
init() {
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', () => this.start());
} else {
this.start();
}
}
start() {
log('Starting detector...');
// Initial scan
this.debouncedScan();
// Watch for DOM changes with debouncing
this.observeChanges();
// Listen for clicks on "see more" buttons
document.addEventListener('click', (e) => this.handleClick(e), true);
// Save stats periodically
setInterval(() => this.saveStats(), 5000);
}
observeChanges() {
const observer = new MutationObserver(() => {
this.debouncedScan();
});
observer.observe(document.body, {
childList: true,
subtree: true
});
}
debouncedScan() {
if (this.scanTimeout) {
clearTimeout(this.scanTimeout);
}
this.scanTimeout = setTimeout(() => this.scanForPosts(), 300);
}
handleClick(e) {
// Check if clicked element is a "see more" type button
const target = e.target;
const text = (target.textContent || '').toLowerCase().trim();
// Very specific matching for LinkedIn's "...more" button
if (text === '…more' || text === '...more' || text === 'see more') {
log('See more clicked, will re-scan in 500ms');
// Wait for content to expand, then re-scan
setTimeout(() => {
// Find the parent post and force re-analysis
const post = target.closest('[data-urn*="urn:li:activity"]') ||
target.closest('[role="article"]');
if (post) {
const postId = this.getPostId(post);
if (postId && this.pendingPosts.has(postId)) {
log('Re-analyzing expanded post:', postId.substring(0, 30));
this.pendingPosts.delete(postId);
this.analyzePost(post, postId);
}
}
}, 500);
}
}
scanForPosts() {
// Find all feed posts
const posts = document.querySelectorAll('[data-urn*="urn:li:activity"]');
log(`Found ${posts.length} posts`);
posts.forEach(post => {
const postId = this.getPostId(post);
if (!postId) return;
// Skip if already analyzed
if (this.analyzedPosts.has(postId)) return;
// Check if this post has a "see more" button in its TEXT content area
const isTruncated = this.isPostTruncated(post);
const textContent = this.extractPostText(post);
const textLength = textContent ? textContent.length : 0;
log('Checking post:', {
id: postId.substring(0, 40),
isTruncated,
textLength,
preview: textContent?.substring(0, 50)
});
if (isTruncated) {
// Store as pending, wait for expansion
if (!this.pendingPosts.has(postId)) {
this.pendingPosts.set(postId, { element: post, truncatedLength: textLength });
log('Post is truncated, waiting for expansion');
}
return;
}
// Not truncated or already expanded - analyze it
this.analyzePost(post, postId);
});
}
getPostId(post) {
return post.getAttribute('data-urn') || null;
}
isPostTruncated(post) {
// Look specifically for the "...more" button within the post's text container
// LinkedIn wraps the post text in specific containers
// First, find the text content area (not the whole post which has "more comments" etc)
const textContainer = post.querySelector(
'.feed-shared-update-v2__description, ' +
'.update-components-text, ' +
'[data-test-id*="commentary"], ' +
'.feed-shared-text-view'
);
if (!textContainer) {
// If we can't find a specific text container, look in the general area
// but be very specific about what we're looking for
const allText = post.querySelectorAll('span, button');
for (const el of allText) {
const text = (el.textContent || '').trim();
// Must be EXACTLY "…more" or "...more" - not "1 more" or "see more comments"
if (text === '…more' || text === '...more') {
// Check it's not inside comments section
const inComments = el.closest('[class*="comment"]');
if (!inComments) {
return true;
}
}
}
return false;
}
// Search within the text container only
const moreButtons = textContainer.querySelectorAll('button, span, a');
for (const btn of moreButtons) {
const text = (btn.textContent || '').trim().toLowerCase();
if (text === '…more' || text === '...more' || text === 'see more') {
return true;
}
}
return false;
}
extractPostText(post) {
// Target the actual post content, not metadata
const selectors = [
'.feed-shared-update-v2__description .update-components-text',
'.feed-shared-update-v2__description',
'.update-components-text',
'[data-test-id*="commentary"]',
'.feed-shared-text-view',
'.feed-shared-inline-show-more-text'
];
for (const selector of selectors) {
const element = post.querySelector(selector);
if (element) {
// Get text but filter out the "...more" button text
let text = element.innerText || element.textContent || '';
text = text.replace(/…more/g, '').replace(/\.\.\.more/g, '').replace(/see more/gi, '');
text = text.trim();
if (text.length > 20) {
return text;
}
}
}
return null;
}
analyzePost(post, postId) {
const textContent = this.extractPostText(post);
if (!textContent || textContent.length < 50) {
log('Skipping - insufficient text content');
return;
}
log('Analyzing:', {
id: postId.substring(0, 40),
length: textContent.length,
preview: textContent.substring(0, 100)
});
// Calculate score
const { score, breakdown } = this.calculateScore(textContent);
log('Score breakdown:', breakdown, '→ Total:', score, '→ Level:', this.mapScoreToLevel(score));
// Mark as analyzed
this.analyzedPosts.add(postId);
this.pendingPosts.delete(postId);
// Update stats
const level = this.mapScoreToLevel(score);
this.stats.total++;
this.stats.scores[level]++;
// Extract author name and generate commentary
const authorName = this.extractAuthorName(post);
const commentary = this.generateCommentary(breakdown, level, authorName);
this.injectBadge(post, level, commentary);
}
// ========================================
// HEURISTICS SYSTEM
// Based on Wikipedia's "Signs of AI Writing"
// https://en.wikipedia.org/wiki/Wikipedia:Signs_of_AI_writing
// ========================================
calculateScore(text) {
const breakdown = {};
let score = 0;
// Wikipedia-based AI writing detection heuristics (1-6)
// 1. AI Vocabulary Words (Wikipedia + AI Phrase Finder top 100)
breakdown.vocab = this.checkAIVocabulary(text);
score += breakdown.vocab;
// 2. Grandiose/Promotional Language
breakdown.grandiose = this.checkGrandioseLanguage(text);
score += breakdown.grandiose;
// 3. Rule of Three Pattern
breakdown.ruleOfThree = this.checkRuleOfThree(text);
score += breakdown.ruleOfThree;
// 4. Present Participle Trailing Clauses ("emphasizing the importance")
breakdown.participle = this.checkParticipleTrailers(text);
score += breakdown.participle;
// 5. Editorial Commentary ("it's important to note")
breakdown.editorial = this.checkEditorialCommentary(text);
score += breakdown.editorial;
// 6. Excessive Transitions (moreover, furthermore)
breakdown.transitions = this.checkTransitionSpam(text);
score += breakdown.transitions;
// Structural AI patterns (7-10)
// 7. Parallel Negation Patterns
breakdown.parallelNegation = this.checkParallelNegation(text);
score += breakdown.parallelNegation;
// 8. Single-Sentence Paragraph Rhythm
breakdown.sentenceRhythm = this.checkSentenceRhythm(text);
score += breakdown.sentenceRhythm;
// 9. Perfect List Parallelism
breakdown.listParallelism = this.checkListParallelism(text);
score += breakdown.listParallelism;
// 10. Colon-Introduced Lists
breakdown.colonLists = this.checkColonLists(text);
score += breakdown.colonLists;
// 11. Em Dash Spacing (strong AI signal)
breakdown.emDash = this.checkEmDashSpacing(text);
score += breakdown.emDash;
// 12. Single Newline Staccato (very strong AI signal)
breakdown.staccato = this.checkStaccatoRhythm(text);
score += breakdown.staccato;
// 13. Tired Business Metaphors
breakdown.metaphors = this.checkTiredMetaphors(text);
score += breakdown.metaphors;
// 14. Engagement Bait Questions
breakdown.engagementBait = this.checkEngagementBait(text);
score += breakdown.engagementBait;
return { score, breakdown };
}
// Heuristic 1: AI Vocabulary Words
// From Wikipedia's guide + AI Phrase Finder's top 100
checkAIVocabulary(text) {
const aiWords = [
// High-signal words from Wikipedia
'delve', 'delving', 'delved',
'tapestry', 'multifaceted', 'comprehensive',
'intricate', 'nuanced', 'multitude',
'realm', 'paradigm', 'ethos',
'embark', 'beacon', 'testament',
'pivotal', 'paramount', 'profound',
'meticulous', 'meticulously',
'intrinsic', 'intrinsically',
'resonate', 'resonates', 'resonating',
'foster', 'fostering', 'fosters',
'leverage', 'leveraging', 'leveraged',
'navigate', 'navigating', 'navigates',
'elevate', 'elevating', 'elevates',
'underscore', 'underscores', 'underscoring',
'robust', 'robustly',
'seamless', 'seamlessly',
'vibrant', 'bustling',
'bespoke', 'tailor-made',
'nuance', 'nuances',
'landscape', // when used metaphorically
'journey', // when used metaphorically for career/life
'ecosystem',
'holistic', 'holistically',
'synergy', 'synergies',
'endeavor', 'endeavors',
'cornerstone',
'spearhead', 'spearheading',
'bolster', 'bolstering',
'augment', 'augmenting',
'harness', 'harnessing',
'cultivate', 'cultivating',
'aligns', 'aligning',
'streamline', 'streamlining',
'optimize', 'optimizing',
'revolutionize', 'revolutionizing',
'transformative', 'transform',
'game-changer', 'game-changing',
'cutting-edge', 'cutting edge',
'groundbreaking',
'trailblazing',
'unparalleled',
'unrivaled',
'unprecedented'
];
const lower = text.toLowerCase();
let matches = 0;
for (const word of aiWords) {
// Use word boundary matching for accuracy
const regex = new RegExp(`\\b${word}\\b`, 'gi');
if (regex.test(lower)) matches++;
}
if (matches >= 5) return -4;
if (matches >= 3) return -2;
return 0;
}
// Heuristic 2: Grandiose/Promotional Language
// Wikipedia: "stands as a testament", "plays a vital role", "breathtaking"
checkGrandioseLanguage(text) {
const phrases = [
// Testament/legacy patterns
'stands as a testament',
'serves as a testament',
'testament to',
'enduring legacy',
'lasting legacy',
'indelible mark',
'left an indelible',
// Vital/crucial patterns
'plays a vital role',
'plays a crucial role',
'plays a pivotal role',
'plays an important role',
'of paramount importance',
'cannot be overstated',
// Promotional superlatives
'rich cultural heritage',
'rich history',
'breathtaking',
'stunning',
'awe-inspiring',
'world-class',
'best-in-class',
'industry-leading',
'thought leader',
'visionary',
'trailblazer',
// Symbolism patterns
'symbolizes',
'embodies the spirit',
'epitomizes',
'exemplifies',
// Significance inflation
'a pivotal moment',
'a watershed moment',
'a turning point',
'marks a significant',
'represents a major',
'a major milestone'
];
const lower = text.toLowerCase();
let matches = 0;
for (const phrase of phrases) {
if (lower.includes(phrase)) matches++;
}
if (matches >= 2) return -4;
if (matches >= 1) return -2;
return 0;
}
// Heuristic 3: Rule of Three Pattern
// Wikipedia: LLMs overuse "adjective, adjective, adjective" and "phrase, phrase, and phrase"
checkRuleOfThree(text) {
let matches = 0;
// Pattern: "X, Y, and Z" where X, Y, Z are similar length phrases
const triplePattern = /(\w+(?:\s+\w+)?), (\w+(?:\s+\w+)?), and (\w+(?:\s+\w+)?)/gi;
const tripleMatches = text.match(triplePattern) || [];
matches += tripleMatches.length;
// Pattern: Three adjectives in a row
const adjectiveTriple = /\b(\w+), (\w+), and (\w+)\b/gi;
const adjMatches = text.match(adjectiveTriple) || [];
matches += adjMatches.length;
// Pattern: Colon followed by three items
const colonTriple = /:\s*(\w+(?:\s+\w+)*),\s*(\w+(?:\s+\w+)*),\s*and\s*(\w+(?:\s+\w+)*)/gi;
const colonMatches = text.match(colonTriple) || [];
matches += colonMatches.length;
if (matches >= 2) return -2;
return 0;
}
// Heuristic 4: Present Participle Trailing Clauses
// Wikipedia: "emphasizing the significance", "reflecting the importance"
checkParticipleTrailers(text) {
const patterns = [
/,?\s+(emphasizing|highlighting|underscoring|reflecting|demonstrating|showcasing|illustrating|signifying|representing)\s+(the|its|their|a)\s+(importance|significance|relevance|impact|value|commitment|dedication)/gi,
/,?\s+(marking|signaling|heralding)\s+a\s+(new|major|significant|important)/gi,
/,?\s+(paving the way|setting the stage|laying the groundwork)/gi,
/,?\s+(cementing|solidifying|reinforcing)\s+(its|their|his|her)\s+(position|status|reputation|legacy)/gi
];
let matches = 0;
for (const pattern of patterns) {
const found = text.match(pattern) || [];
matches += found.length;
}
if (matches >= 2) return -3;
if (matches >= 1) return -2;
return 0;
}
// Heuristic 5: Editorial Commentary
// Wikipedia: "it's important to note", "it is worth mentioning"
checkEditorialCommentary(text) {
const phrases = [
"it's important to note",
"it is important to note",
"it's worth noting",
"it is worth noting",
"it's worth mentioning",
"it is worth mentioning",
"importantly,",
"significantly,",
"notably,",
"interestingly,",
"crucially,",
"remarkably,",
"it should be noted",
"one must consider",
"it bears mentioning",
"needless to say",
"it goes without saying",
"no discussion.*would be complete without",
"in summary,",
"in conclusion,",
"to summarize,",
"to conclude,",
"overall,",
"all in all,",
"at the end of the day"
];
const lower = text.toLowerCase();
let matches = 0;
for (const phrase of phrases) {
if (phrase.includes('.*')) {
const regex = new RegExp(phrase, 'i');
if (regex.test(lower)) matches++;
} else if (lower.includes(phrase)) {
matches++;
}
}
if (matches >= 2) return -3;
if (matches >= 1) return -2;
return 0;
}
// Heuristic 6: Excessive Transitions
// Wikipedia: "moreover", "furthermore"
checkTransitionSpam(text) {
const transitions = [
'moreover',
'furthermore',
'additionally',
'in addition',
'consequently',
'subsequently',
'nevertheless',
'nonetheless',
'hence',
'thus',
'therefore',
'accordingly',
'on the other hand',
'conversely',
'in contrast',
'similarly',
'likewise',
'as such',
'that said',
'that being said',
'with that in mind',
'in light of this',
'given this',
'firstly',
'secondly',
'thirdly',
'lastly',
'finally'
];
const lower = text.toLowerCase();
let matches = 0;
for (const t of transitions) {
const regex = new RegExp(`\\b${t}\\b`, 'gi');
const found = lower.match(regex) || [];
matches += found.length;
}
if (matches >= 4) return -2;
return 0;
}
// Heuristic 7: Parallel Negation Patterns
// AI loves "The X isn't Y. The X is Z." or "This isn't X. It's Y."
checkParallelNegation(text) {
const patterns = [
// "The X isn't Y. The X is Z."
/The \w+\s+(?:isn't|is not|aren't|are not|wasn't|were not)\s+\w+\.\s*The \w+\s+is\s+/gi,
// "This isn't X. It's Y." / "This isn't X. This is Y."
/(?:This|That|It)\s+(?:isn't|is not|wasn't|was not)\s+[^.]+\.\s*(?:This|That|It'?s?)\s+is\s+/gi,
// Repeated structure: "X isn't... X isn't... X isn't..."
/(\w+\s+(?:isn't|is not|aren't|are not)[^.]+\.)\s*\1/gi
];
let matches = 0;
for (const pattern of patterns) {
const found = text.match(pattern) || [];
matches += found.length;
}
if (matches >= 3) return -4;
if (matches >= 2) return -3;
if (matches >= 1) return -2;
return 0;
}
// Heuristic 8: Single-Sentence Paragraph Rhythm
// AI-generated essays often have perfect single-sentence paragraph cadence
checkSentenceRhythm(text) {
const paragraphs = text.split(/\n+/).filter(p => p.trim().length > 15);
// Need enough paragraphs to detect pattern
if (paragraphs.length < 4) return 0;
let singleSentence = 0;
for (const p of paragraphs) {
// Count sentences (split by . ! ?)
const sentences = p.split(/[.!?]+/).filter(s => s.trim().length > 5);
if (sentences.length === 1) singleSentence++;
}
const ratio = singleSentence / paragraphs.length;
// High ratio of single-sentence paragraphs in formal writing is AI-like
if (ratio >= 0.75 && paragraphs.length >= 6) return -3;
if (ratio >= 0.6 && paragraphs.length >= 4) return -2;
return 0;
}
// Heuristic 9: Perfect List Parallelism
// AI creates perfectly parallel lists where all items start identically
checkListParallelism(text) {
const lines = text.split('\n');
let perfectLists = 0;
// Look for bullet/numbered list patterns
for (let i = 0; i < lines.length - 2; i++) {
const line1 = lines[i].trim();
const line2 = lines[i + 1].trim();
const line3 = lines[i + 2].trim();
// Check if these look like list items
if (this.isListItem(line1) && this.isListItem(line2) && this.isListItem(line3)) {
// Extract text after bullet/number
const text1 = this.extractListText(line1);
const text2 = this.extractListText(line2);
const text3 = this.extractListText(line3);
// Check if they start with same word or same structure
const words1 = text1.split(/\s+/);
const words2 = text2.split(/\s+/);
const words3 = text3.split(/\s+/);
if (words1.length > 0 && words2.length > 0 && words3.length > 0) {
if (words1[0].toLowerCase() === words2[0].toLowerCase() &&
words2[0].toLowerCase() === words3[0].toLowerCase()) {
perfectLists++;
}
}
}
}
if (perfectLists >= 2) return -3;
if (perfectLists >= 1) return -2;
return 0;
}
// Helper: Check if line looks like list item
isListItem(line) {
return /^[\s]*(?:[-•\*\d]+[\.\)]|\d+\.)\s+\w/.test(line);
}
// Helper: Extract text after list marker
extractListText(line) {
return line.replace(/^[\s]*(?:[-•\*\d]+[\.\)]|\d+\.)\s+/, '');
}
// Heuristic 10: Colon-Introduced Lists
// AI loves "Here's what matters:" followed by perfect list
checkColonLists(text) {
// Pattern: sentence ending in colon, followed by list items
const colonPattern = /[^:\n]+:\s*\n/g;
const colonMatches = text.match(colonPattern) || [];
// Check if colon is followed by list structure
let colonLists = 0;
for (const match of colonMatches) {
const index = text.indexOf(match);
const afterColon = text.substring(index + match.length, index + match.length + 200);
// Check if next lines are list items
const nextLines = afterColon.split('\n').slice(0, 4);
let listItems = 0;
for (const line of nextLines) {
if (this.isListItem(line.trim())) listItems++;
}
if (listItems >= 2) colonLists++;
}
if (colonLists >= 3) return -3;
if (colonLists >= 2) return -2;
return 0;
}
// Heuristic 11: Em Dash with Spaces
// AI loves " — " (space-em dash-space) for dramatic pauses
// This is a VERY strong signal - humans rarely format this way
checkEmDashSpacing(text) {
// Match em dash (—) or double/triple hyphen (-- or ---) with spaces on both sides
const emDashPattern = /\s(—|–|--)\s/g;
const matches = text.match(emDashPattern) || [];
const count = matches.length;
// This is such a strong signal that even 1-2 instances should heavily weight toward Slop
if (count >= 3) return -6;
if (count >= 2) return -4;
if (count >= 1) return -3;
return 0;
}
// Heuristic 12: Single Newline Staccato Rhythm
// AI uses single \n for dramatic sentence breaks instead of proper \n\n paragraph breaks
// Pattern: "Sentence.\nNew sentence." instead of "Sentence.\n\nNew paragraph."
checkStaccatoRhythm(text) {
// Look for sentence endings followed by single newline and capital letter
// This indicates sentence breaks without proper paragraph spacing
const staccatoPattern = /[.!?]\n[A-Z]/g;
const matches = text.match(staccatoPattern) || [];
const singleNewlineBreaks = matches.length;
// Also check for very short lines (< 60 chars) which indicates fragmentation
const lines = text.split('\n');
const shortLines = lines.filter(line => {
const trimmed = line.trim();
return trimmed.length > 0 && trimmed.length < 60 && /[.!?]$/.test(trimmed);
}).length;
// High ratio of staccato breaks or many short dramatic lines = AI
if (singleNewlineBreaks >= 8 || shortLines >= 10) return -6;
if (singleNewlineBreaks >= 5 || shortLines >= 7) return -4;
if (singleNewlineBreaks >= 3 || shortLines >= 5) return -3;
return 0;
}
// Heuristic 13: Tired Business Metaphors
// AI loves overused business clichés
checkTiredMetaphors(text) {
const metaphors = [
// Physical metaphors
'three-legged stool',
'two sides of the same coin',
'tip of the iceberg',
'low-hanging fruit',
'move the needle',
'moving the goalposts',
'shift gears',
'hit the ground running',
'all hands on deck',
'boots on the ground',
// Journey/path metaphors
'at the end of the day',
'when all is said and done',
'at this point in time',
'circle back',
'take it offline',
'touch base',
'on the same page',
// Business jargon metaphors
'think outside the box',
'drink the kool-aid',
'boil the ocean',
'drinking from a firehose',
'run it up the flagpole',
'synergy',
'leverage synergies',
'move forward',
'going forward',
'take a step back',
// Scale/growth metaphors
'10x',
'scale up',
'double down',
'deep dive',
'drill down',
'take a holistic view',
'from 30,000 feet',
'high-level overview'
];
const lower = text.toLowerCase();
let matches = 0;
for (const metaphor of metaphors) {
if (lower.includes(metaphor)) matches++;
}
if (matches >= 3) return -4;
if (matches >= 2) return -3;
if (matches >= 1) return -2;
return 0;
}
// Heuristic 14: Engagement Bait Questions
// AI posts often end with questions to drive engagement
checkEngagementBait(text) {
const lines = text.split('\n').filter(l => l.trim().length > 0);
if (lines.length === 0) return 0;
// Check last 2 lines for engagement patterns
const lastLines = lines.slice(-2).join(' ').toLowerCase();
const baitPatterns = [
// Question patterns
/what('s| is) your (take|thought|opinion|experience|perspective)/i,
/what do you think/i,
/how (do|would) you/i,
/have you (ever|experienced)/i,
/what (was|were) the last/i,
/what are you (doing|working)/i,
/who else (agrees|disagrees)/i,
// Call to action patterns
/let me know in the comments/i,
/drop (your|a) comment/i,
/share (your|this)/i,
/tag someone who/i,
/agree or disagree/i,
/sound off below/i,
/weigh in/i,
// Emoji question indicators
/[❓⁉️]/
];
for (const pattern of baitPatterns) {
if (pattern.test(lastLines)) {
return -3;
}
}
return 0;
}
mapScoreToLevel(score) {
// 2-level system: Human or Slop
// Be decisive - no "maybe"
if (score >= -6) return 2; // Human
return 1; // Slop
}
extractAuthorName(post) {
// Try to find the author name in various LinkedIn post structures
// LinkedIn 2024/2025 DOM structure - be very specific to avoid picking up wrong text
const nameSelectors = [
// Primary: the actor name container with nested spans
'.update-components-actor__name .hoverable-link-text span[aria-hidden="true"]',
'.update-components-actor__name span[aria-hidden="true"]',
'.update-components-actor__title span[aria-hidden="true"]',
// Feed shared structure
'.feed-shared-actor__name span[aria-hidden="true"]',
// Fallback to the link itself
'.update-components-actor__name a',
'.feed-shared-actor__name a'
];
for (const selector of nameSelectors) {
const nameEl = post.querySelector(selector);
if (nameEl && nameEl.textContent) {
const fullName = nameEl.textContent.trim();
// Skip if it looks like non-name content
if (fullName.length < 2 || fullName.length > 50) continue;
if (/^(Exciting|Sponsored|Promoted|Follow|Connect|\d)/i.test(fullName)) continue;
// Extract first name (before first space)
const firstName = fullName.split(' ')[0];
// Validate it looks like a name (starts with capital, reasonable length)
if (firstName.length >= 2 && firstName.length <= 20 && /^[A-Z]/.test(firstName)) {
return firstName;
}
}
}
return 'the author'; // Fallback - reads better in sentences
}
generateCommentary(breakdown, level, authorName) {
// Sort breakdown by most negative (most suspicious)
const factors = [];
for (const [key, value] of Object.entries(breakdown)) {
if (value < 0) {
factors.push({ name: key, score: value });
}
}
factors.sort((a, b) => a.score - b.score);
// More descriptive, varied names for each heuristic
const factorNames = {
vocab: ['AI buzzwords', 'telltale AI words', 'robot vocabulary', 'AI-speak'],
grandiose: ['puffed-up language', 'grandiose claims', 'over-the-top prose'],
ruleOfThree: ['the classic rule of three', 'triplet pattern', 'three-part lists'],
participle: ['"-ing" clause overload', 'dangling modifiers', 'participle padding'],
editorial: ['unnecessary commentary', '"importantly" spam', 'editorial asides'],
transitions: ['transition word soup', 'moreover/furthermore abuse', 'connector overload'],
parallelNegation: ['parallel negation tricks', '"not X, but Y" pattern', 'negation structure'],
sentenceRhythm: ['choppy paragraph rhythm', 'one-sentence paragraphs', 'robotic cadence'],
listParallelism: ['too-perfect lists', 'identical list structure', 'parallel list items'],
colonLists: ['colon-list combos', '"here\'s what:" pattern', 'setup-list structure'],
emDash: ['dramatic em dashes', 'spaced em dashes', '— pause abuse —'],
staccato: ['staccato line breaks', 'dramatic one-liners', 'punchy fragments'],
metaphors: ['tired business clichés', 'overused metaphors', 'corporate speak'],
engagementBait: ['engagement bait', '"what do you think?"', 'comment-fishing']
};
// Pick a random variant for variety
const getFactorName = (key) => {
const variants = factorNames[key];
if (Array.isArray(variants)) {
return variants[Math.floor(Math.random() * variants.length)];
}
return key;
};
// Friendly Detective personality
if (level === 1) {
// SLOP - AI detected
const top3 = factors.slice(0, 3).map(f => getFactorName(f.name));
const templates = [
`Elementary! The evidence points to AI: ${top3.join(', ')}.`,
`The clues don't lie: ${top3.join(', ')}. That's AI.`,
`Investigating... AI confirmed. Signals: ${top3.join(', ')}.`,
`AI detected. The tells? ${top3.join(', ')}.`,
`Case closed: ${top3.join(', ')} = AI writing.`
];
return templates[Math.floor(Math.random() * templates.length)];
} else {
// HUMAN - authentic content
if (factors.length === 0) {
const templates = [
`Looks human to me! No AI fingerprints detected.`,
`Elementary! This one's authentic. Clean as a whistle.`,
`Case closed: genuine human writing. Zero AI tells.`,
`All clear here. Not a single red flag.`
];
return templates[Math.floor(Math.random() * templates.length)];
} else if (factors.length <= 2) {
const factorList = factors.map(f => getFactorName(f.name)).join(', ');
const templates = [
`Looks human. Minor signals (${factorList}) but well below threshold.`,
`Probably authentic. Slight traces of ${factorList}, but nothing suspicious.`,
`Passes the human test. Detected ${factorList}, but the voice is genuine.`
];
return templates[Math.floor(Math.random() * templates.length)];
} else {
const factorList = factors.slice(0, 2).map(f => getFactorName(f.name)).join(', ');
const templates = [
`Likely authentic. Some patterns (${factorList}) but not enough to convict.`,
`Human verdict. ${factorList} noted, but passes the test.`,
`Genuine content. ${factorList} present, but inconclusive.`
];
return templates[Math.floor(Math.random() * templates.length)];
}
}
}
injectBadge(post, level, commentary) {
if (post.querySelector('.slop-detector-badge')) return;
const badge = document.createElement('div');
badge.className = 'slop-detector-badge';
badge.setAttribute('data-level', level);
// Build badge content
const content = document.createElement('div');
content.className = 'slop-badge-content';
// Icon (emoji indicator)
const icon = document.createElement('div');
icon.className = 'slop-icon';
icon.textContent = level === 1 ? '🤖' : '✍️';
// Label
const label = document.createElement('div');
label.className = 'slop-label';
label.textContent = this.getLabelText(level);
// Commentary
const commentaryEl = document.createElement('div');
commentaryEl.className = 'slop-commentary';
commentaryEl.textContent = commentary;
content.appendChild(icon);
content.appendChild(label);
content.appendChild(commentaryEl);
badge.appendChild(content);
// Create a sticky container positioned to the left
// Check viewport width for responsive positioning