Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function PostInfo(id, media) {
- this.id = id;
- this.media = media;
- }
- // Loads JSON of current page and makes an id-md5 list of posts.
- function getPosts() {
- var jsonUrl = document.URL.replace("html", "json");
- var json = JSON.parse(httpGet(jsonUrl));
- var posts = json.threads[0].posts;
- return posts.map(function(post) {
- return getInfo(post);
- });
- }
- // Makes a GET request to a given URL and returns response text.
- function httpGet(url) {
- var xmlHttp = new XMLHttpRequest();
- xmlHttp.open("GET", url, false);
- xmlHttp.send(null);
- return xmlHttp.responseText;
- }
- function getInfo(post) {
- var media = post.files.map(function(file) {
- return file.md5;
- });
- return new PostInfo(post.number, media);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement