This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Run this at thread level to select a random 1st level (aka parent/top-tier) comment. Useful for giveaways. | |
var parentComments = $(".sitetable.nestedlisting > .thing > .parent"); | |
var index = Math.floor(Math.random() * parentComments.length); | |
var selectedComment = $(parentComments[index]).parent(); | |
var commentId = selectedComment.attr('id'); | |
var username = selectedComment.find(".entry > .tagline > .author").text(); | |
var commentText = selectedComment.find(".usertext > .usertext-body").text(); | |
console.log(`Selected comment "${commentId}" by "${username}"\n\n${commentText}`); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using Newtonsoft.Json.Linq; | |
public static class JTokenExtensions | |
{ | |
/// <summary> | |
/// Extension of JToken Value<T> method. Used to avoid null exceptions with value types when parsing JToken. | |
/// </summary> | |
/// <typeparam name="T"></typeparam> | |
/// <param name="token"></param> |