canto's profile picture

Published by

published
updated

Category: Web, HTML, Tech

Blog Viewer Script

Script I made a few minutes ago to crawl blogposts in sequence. Run with Tampermonkey.

If you crawl onto a Link-Only blog the button will appear red. Privacy invasion!

 // ==UserScript==
// @name         Blog switcher
// @version      0.1
// @description  view blog posts sequentially
// @match        https://blog.spacehey.com/entry?id=*
// ==/UserScript==

(function() {

    'use strict';
    let postId = document.location.href.split("=")[1];
    let url = 'https://blog.spacehey.com/entry?id=';

    let nextPost = document.createElement("button");
    nextPost.id = "nextpostbutton";
    nextPost.innerText = "Next post";
    nextPost.style.width = "100%";
    nextPost.style.padding = "1rem";
    nextPost.style.fontFamily = "monospace";
    nextPost.style.backgroundColor = "black";
    nextPost.style.color = "white";
    nextPost.style.fontSize = "1.5rem";

    let goNext = function(){
        window.location.href = url + (parseInt(postId) + 1);
    }

    nextPost.addEventListener("click", goNext);
    for(var i of document.getElementsByTagName("h1")){
        if(i.innerText.includes("Page not found.")){
            goNext();
        }
    }

    for(var o of document.getElementsByClassName("error")){
        if(o.innerText.includes("Error: This is a private Blog Entry.")){
            goNext();
        }
    }

    for(var j of document.getElementsByClassName("category")){
        if(j.innerText.includes("Privacy: Link-only")){
            nextPost.style.backgroundColor = "red";
            nextPost.style.color = "black";
            nextPost.innerText = "Next Post (Currently on a Link-Only post)";
        }
    }

    document.getElementsByTagName("nav")[0].appendChild(nextPost);
})();


4 Kudos

Comments

Displaying 3 of 3 comments ( View all | Add Comment )

yurmom

yurmom's profile picture

nevermind, dont wanna risk a ban from spacehey


Report Comment



according to the TOS the closest way this script might infringe is in section 3.2 VII:


vii. use software or automated agents or scripts that don't use the official SpaceHey.com API to produce multiple accounts on the Site or to generate automated searches, requests, or queries to the Site.

However, none of the queries made by this script are "automatic", since viewing each new blog post requires user interaction (by clicking a button), and it neither scrapes nor saves any of the data. Also, any blog posts it can view are technically public (even link only ones!) and can be accessed by a user who simply punches in X+1 into the id= field.
TL:DR; I think I'm in the clear here.

by canto; ; Report

they didnt say manual softwre wasnt banned, sooooo....... 0_0

by yurmom; ; Report

actually through the power of timezones i can access advent calendar posts pretty early if that makes you feel better.

by yurmom; ; Report

BLUSHIN ReT

BLUSHIN ReT's profile picture

Very neat!


Report Comment

Rafael

Rafael's profile picture

Inb4 your b& from Spacehey ;P


Report Comment



it's not automated crawling... so I think I'm in the clear... hopefully.

by canto; ; Report