Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

convert new api.4chan.json to java?

Name: Anonymous 2013-03-02 7:05

var first = true, n = 0, l = 0, m = 0;
var offset = 1; //how early it starts posting (default is 1, or 1 post before)
var sticky = true; //posting box follows you as you scroll down the page
var postrange = 20; //number of posts to use for post rate calc

function verbose() {
    if (document.getElementsByName("getstatus")[0].innerHTML == "Waiting for: " + n + "...")
        document.getElementsByName("getstatus")[0].innerHTML = "Waiting for: " + n + ".";
    else if (document.getElementsByName("getstatus")[0].innerHTML == "Waiting for: " + n + ".")
        document.getElementsByName("getstatus")[0].innerHTML = "Waiting for: " + n + "..";
    else
        document.getElementsByName("getstatus")[0].innerHTML = "Waiting for: " + n + "...";
    }
   
function check() {
    if (n == 0) return;
    verbose();
    var k = first ? n : (n-offset);
    GM_xmlhttpRequest({
        method: "HEAD",
        url: "http://sys.4chan.org" + location.pathname.match(/\/[^\/]+\//)[0] + "imgboard.php?res=" + k,
        onload: function(response) {
            if (n == 0) return;
            if (response.status == 200) {
                if (first) {
                    alert(n + " passed");
                    document.getElementsByName("txtpostnumber")[0].value = n;
                    document.getElementsByName("txtpostnumber")[0].focus();
                    document.getElementsByName("getstatus")[0].innerHTML = "Ready...";
                    n = 0;
                } else {
                    document.getElementsByName("post")[0].submit();
                }
            } else {
                first = false;
                check();
            }
        }
    });
}

function qrcheck() {
    if (n == 0) return;
    verbose();
    var k = first ? n : (n-offset);
    GM_xmlhttpRequest({
        method: "HEAD",
        url: "http://sys.4chan.org" + location.pathname.match(/\/[^\/]+\//)[0] + "imgboard.php?res=" + k,
        onload: function(response) {
            if (n == 0) return;
            if (response.status == 200) {
                if (first) {
                    alert(n + " passed");
                    document.getElementsByName("txtpostnumber")[0].value = n;
                    document.getElementsByName("txtpostnumber")[0].focus();
                    document.getElementsByName("getstatus")[0].innerHTML = "Ready...";
                    n = 0;
                } else {
                    document.getElementsByName("qrsubmit")[0].click();
                    document.getElementsByName("getstatus")[0].innerHTML = "Ready...";
                }
            } else {
                first = false;
                qrcheck();
            }
        }
    });
}

function postrates() {
    if (n == 0) return;
    verbose();
    GM_xmlhttpRequest({
        method: "HEAD",
        url: "http://sys.4chan.org" + location.pathname.match(/\/[^\/]+\//)[0] + "imgboard.php?res=" + n,
        onload: function(response) {
            if (n == 0) return;
            if (response.status == 200) {
                if (first) {
                    alert(n + " passed");
                    document.getElementsByName("txtpostnumber")[0].value = n;
                    document.getElementsByName("txtpostnumber")[0].focus();
                    document.getElementsByName("getstatus")[0].innerHTML = "Ready...";
                    n = 0;
                } else {
                    if (l == 0) {
                        l = (new Date()).getTime() / 1000;
                        n = (n + postrange);
                        document.getElementsByName("getstatus")[0].innerHTML = "Waiting for: " + n + "...";
                        postrates();
                    }
                    else {
                    m = Math.round((new Date()).getTime() / 1000 - l);
                    alert(postrange + " posts in " + m + " seconds. Average post time: " + Math.round((postrange / m)*100)/100 + "/s");
                    document.getElementsByName("getstatus")[0].innerHTML = "Ready...";
                    }
                }
            } else {
                first = false;
                postrates();
            }
        }
    });
}

function setup() {
getbox = window.document.createElement('div');
getbox.innerHTML = "<table border='0' cellpadding='0' cellspacing='1' id='getbox' style='width: 200px;'> <tbody> <tr> <td colspan='3'> <label name='getstatus'>Ready...</label></td> </tr> <tr> <td colspan='3' style='text-align: center;'> <input name='txtpostnumber' size='24' type='text' style='width: 100%'/></td> </tr> <tr> <td style='text-align: center; width: 32%;'> <input name='btpost' type='button' value='Post' style='width: 100%' /></td> <td style='text-align: center; width: 32%;'> <input name='btqrpost' type='button' value='QR Post' style='width: 100%' /></td> <td style='text-align: center; width: 36%;'> <input name='btpostrate' type='button' value='Post Rate' style='width: 100%' /></td> </tr> </tbody> </table>";
if (sticky == true) {
    getbox.style.position = "fixed";
}
else {
    getbox.style.position = "absolute";
}
getbox.style.right = "20px";
getbox.style.top = "39px";
window.document.getElementsByTagName("body")[0].appendChild(getbox);

document.getElementsByName("btpost")[0].addEventListener("click", function(e) {
    first = true;
    document.getElementsByName("txtpostnumber")[0].value = document.getElementsByName("txtpostnumber")[0].value.replace(/[^0123456789]/g, "");
    n = parseInt(document.getElementsByName("txtpostnumber")[0].value);
    if (!isNaN(n)) {
        document.getElementsByName("txtpostnumber")[0].value = "";
        document.getElementsByName("getstatus")[0].innerHTML = "Waiting for: " + n + "...";
        check();
    }
    else
        alert("Invalid Number");
}, false);

document.getElementsByName("btqrpost")[0].addEventListener("click", function(e) {
    if (document.getElementById("qr_form")) {
        document.getElementById('com_submit').id = "com_submit1";
        document.getElementById('com_submit').name = "qrsubmit";
        document.getElementById('com_submit1').id = "com_submit";
        first = true;
        document.getElementsByName("txtpostnumber")[0].value = document.getElementsByName("txtpostnumber")[0].value.replace(/[^0123456789]/g, "");
        n = parseInt(document.getElementsByName("txtpostnumber")[0].value);
        if (!isNaN(n)) {
            document.getElementsByName("txtpostnumber")[0].value = "";
            document.getElementsByName("getstatus")[0].innerHTML = "Waiting for: " + n + "...";
            qrcheck();
        }
        else
            alert("Invalid Number");
    }
    else
        alert("Quick Reply is not Open");
}, false);

document.getElementsByName("btpostrate")[0].addEventListener("click", function(e) {
    document.getElementsByName("txtpostnumber")[0].value = document.getElementsByName("txtpostnumber")[0].value.replace(/[^0123456789]/g, "");
    n = parseInt(document.getElementsByName("txtpostnumber")[0].value);
    if (!isNaN(n)) {
        document.getElementsByName("txtpostnumber")[0].value = "";
        document.getElementsByName("getstatus")[0].innerHTML = "Waiting for: " + n + "...";
        l = 0;
        postrates();
    }
    else
        alert("Invalid Number");
}, false);

}

setup();

Name: Anonymous 2013-03-02 7:07

can anyone help me with this? i am happy to pay someone for their services. the problem is that 4chan no longer allows massive server requests to sys.4chan.org. but with the new api can someone convert the json to java? also, if you can read this script and you know what it does, dont flame me. it helps me deal with the shitposts and cancer.here’s my script. it took me forever to piece it together and i learned a lot doing it. i just don’t have time to learn the new api.
 
so once again, this is my chemo, i’m not cancer. i enjoy it on so many levels, not just for the obvious. i love dictating bong names for rolls, "the demotivator and my glass dick, or name my new dog. they are all named penor or mr. pickles. last text request to his female neighbor was as follows. 1. I want to glue your eyes shut with my semen. 2. So you won’t see what I am going to shove up your FILTHY WHORE CUNT. 3. Because I destroy more pussy than cervical cancer. so help a 35 year old /b/tard who misses his first 2 years at /b/, 2008 and 2009 and this is the only chemo i have that’s just for me. it makes all the shitposts and cancer bearable. here’s the script

Name: Anonymous 2013-03-02 7:12

4chan has api? o.O

Name: Anonymous 2013-03-02 7:20

https://github.com/4chan/4chan-API

JSON API
i imagine i would have to replace my
GM_xmlhttpRequest({
        method: "HEAD",
        url: "http://sys.4chan.org" + location.pathname.match(/\/[^\/]+\//)[0] + "imgboard.php?res=" + k,
        onload: function(response) {
            if (n == 0) return;
            if (response.status == 200) {
with something like their new:
QR.banXhr = new XMLHttpRequest();
  QR.banXhr.open('GET', '//api.4chan.org/banned?' + Date.now(), true);
  QR.banXhr.timeout = 3000;
  QR.banXhr.onload = function() {
    if (this.status == 403) {
????D?

Name: Anonymous 2013-03-02 7:54

This code is horrifying and hard to read. I'm not even sure what is meant by "convert it to Java", since this seems to manipulate the DOM, hence meant to run in a browser.

Name: Anonymous 2013-03-02 8:06

Why does 4chan need an API? It's a forum.

Name: Anonymous 2013-03-02 8:12

>>6
ask moot api@4chan.org

also (/\/[^\/]+\//) - ^_^ so kawaii, gonna take home :3

Name: Anonymous 2013-03-02 8:58

>>5
oh i completely agree with you and i apologize for my level of ignorance when it comes to programming. i run it in my browser as a userscript.js. i guess what i am basically asking is how do i format the request to http://sys.4chan.org/
to request from http://api.4chan.org/ instead.


GM_xmlhttpRequest(
        method: "HEAD",
        url: "http://sys.4chan.org"

to contain

GM_xmlhttpRequest({
        method: "HEAD",
        url: "http://api.4chan.org/"

i imagine i have to invoke the syntax described here:
https://github.com/4chan/4chan-API/blob/master/README.md

thanks for even replying to my moronathon /b/ro

Name: Anonymous 2013-03-02 9:42

>>8

Why are you even using "HEAD"? You don't seem to make use of the response at all, so I don't see what the problem is. I don't have GreaseMonkey installed, but it seems like a GET to the API subdomain works fine:


printf "GET /b/0.json HTTP/1.0\r\nHost:api.4chan.org\r\n\r\n" | nc api.4chan.org 80 | head -n 16
HTTP/1.1 200 OK
Server: cloudflare-nginx
Date: Sat, 02 Mar 2013 14:41:28 GMT
Content-Type: application/json
Connection: close
Last-Modified: Sat, 02 Mar 2013 14:41:26 GMT
Vary: Accept-Encoding
ETag: "51320f96-1aef"
Cache-Control: public, must-revalidate, proxy-revalidate
Expires: -1
Access-Control-Allow-Origin: http://boards.4chan.org
Access-Control-Allow-Methods: GET, OPTIONS
Access-Control-Allow-Headers: If-Modified-Since
Set-Cookie: __cfduid=d42eebc9310fe886ca94d5710587737641362235288; expires=Mon, 23-Dec-2019 23:50:00 GMT; path=/; domain=.4chan.org
CF-RAY: 48ed917129804a9

Name: Anonymous 2013-03-02 9:44

>>9

Yes but HEAD gives me the header with GET I cannot get it. I want to transfer the header to java. How do I need to transform the code <-> greasemonkey?

Name: Anonymous 2013-03-02 9:53

lel javashit

Name: Anonymous 2013-03-02 9:55

>>11

I am sorry it is written very bad, I got dick in code.

Name: Anonymous 2013-03-02 10:57

>>>/polkat /g/ebabs/

Name: Anonymous 2013-03-02 11:36

Bak to /g/ plase?

Name: Anonymous 2013-03-02 12:03

>>14
I need to hep me, plese

Name: Anonymous 2013-03-02 13:11

>>14
Actually, /polkat /g/ebabs/ would ``translate'' to ``bak to /g/ pleasb''.

Name: Anonymous 2013-03-02 14:28

>>16
You mena “baka got plebs”

Name: Anonymous 2013-03-02 16:03

pleas /b/ bak to /g/

Name: Anonymous 2013-03-02 19:58

but the API doesn't work on the textboards
why would you even care about the imagereddits.

Don't change these.
Name: Email:
Entire Thread Thread List