Advertisement
Guest User

Untitled

a guest
Aug 10th, 2018
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.18 KB | None | 0 0
  1. console.log("injected"); //console debug - show plugin has started
  2. var idBlock = $('.opContainer .posteruid span:eq(1)'); //jquery gets the element with OP ID
  3. var idExtract = idBlock.text(); // Get the text string for OP ID
  4. console.log(idBlock); // debug - print out the element
  5. var idStringed = String(idExtract); // Make sure the OP ID text is a string (convert it)
  6. console.log(idStringed); // console debug
  7. var numPostsRaw = $('.replyContainer'); // grab all elements from reply posts only
  8. var numPosts = numPostsRaw.length; // get count of those elements
  9. var replies = numPosts - 1; // get total replies
  10. var opHours = $('.dateTime:eq(1)');
  11. var realHours = new Date (opHours.text());
  12. var diff = Math.abs(new Date(realHours) - new Date());
  13. var minutesRaw = diff/1000/60; // get minutes
  14. var minutes = Math.round(minutesRaw);
  15. var boilerA = "<div class=\"pepe\">1 Post by this ID!</div>"; //print alert using jquery
  16. var boilerB = "<div class =\"kermit\">OP posted this "+minutes+" minutes ago. There have been "+ replies + " replies so far and no answer...</div>";
  17. if (idStringed.indexOf('/') > -1) { // regex to remove any non standard / chars from OP ID
  18. idStringed = idStringed.replace(/\//g, '\\/');
  19. console.log(idStringed);
  20. var searchy = $(".id_"+idStringed); // get all elements with OP ID as class
  21. } else {
  22. var searchy = $(".id_"+idStringed)
  23. };if (idStringed.indexOf('+') > -1) { // conditional to remove any non standard + chars from OP ID
  24. idStringed = idStringed.replace(/\+/g, '\\+');
  25. console.log(idStringed);
  26. var searchy = $(".id_"+idStringed);
  27. } else {
  28. var searchy = $(".id_"+idStringed) // get all elements with OP ID as class
  29. };
  30. var postsByThisId = searchy.length /2; // check em for total (and divide by two as markup is used for desktop and mobile)
  31. if (postsByThisId == 1 && numPosts > 25){ // if OP hasnt posted again within 25 posts the alert is triggered.
  32. $(".thread").prepend(boilerA);
  33. $('.pepe').fadeTo(100, 0.3, function() { $(this).fadeTo(500, 1.0); });
  34. $(".pepe").append(boilerB);
  35. $('.kermit').fadeTo(100, 0.3, function() { $(this).fadeTo(500, 1.0); });
  36. $(".pepe").fadeIn(100).fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100);
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement