Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- console.log("injected"); //console debug - show plugin has started
- var idBlock = $('.opContainer .posteruid span:eq(1)'); //jquery gets the element with OP ID
- var idExtract = idBlock.text(); // Get the text string for OP ID
- console.log(idBlock); // debug - print out the element
- var idStringed = String(idExtract); // Make sure the OP ID text is a string (convert it)
- console.log(idStringed); // console debug
- var numPostsRaw = $('.replyContainer'); // grab all elements from reply posts only
- var numPosts = numPostsRaw.length; // get count of those elements
- var replies = numPosts - 1; // get total replies
- var opHours = $('.dateTime:eq(1)');
- var realHours = new Date (opHours.text());
- var diff = Math.abs(new Date(realHours) - new Date());
- var minutesRaw = diff/1000/60; // get minutes
- var minutes = Math.round(minutesRaw);
- var boilerA = "<div class=\"pepe\">1 Post by this ID!</div>"; //print alert using jquery
- var boilerB = "<div class =\"kermit\">OP posted this "+minutes+" minutes ago. There have been "+ replies + " replies so far and no answer...</div>";
- if (idStringed.indexOf('/') > -1) { // regex to remove any non standard / chars from OP ID
- idStringed = idStringed.replace(/\//g, '\\/');
- console.log(idStringed);
- var searchy = $(".id_"+idStringed); // get all elements with OP ID as class
- } else {
- var searchy = $(".id_"+idStringed)
- };if (idStringed.indexOf('+') > -1) { // conditional to remove any non standard + chars from OP ID
- idStringed = idStringed.replace(/\+/g, '\\+');
- console.log(idStringed);
- var searchy = $(".id_"+idStringed);
- } else {
- var searchy = $(".id_"+idStringed) // get all elements with OP ID as class
- };
- var postsByThisId = searchy.length /2; // check em for total (and divide by two as markup is used for desktop and mobile)
- if (postsByThisId == 1 && numPosts > 25){ // if OP hasnt posted again within 25 posts the alert is triggered.
- $(".thread").prepend(boilerA);
- $('.pepe').fadeTo(100, 0.3, function() { $(this).fadeTo(500, 1.0); });
- $(".pepe").append(boilerB);
- $('.kermit').fadeTo(100, 0.3, function() { $(this).fadeTo(500, 1.0); });
- $(".pepe").fadeIn(100).fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement