// KaiOS 2.x specific part to connect and retrieve raw data from Gopher servers // Requires "tcp-socket" permission in the manifest // and the "privileged" or "certified" app permission level // resource format: [type, selector, host, port] // type is autotrimmed, so you don't have to manually strip the description // input is optional and only considered for resource type 7 function gopherRequest(resource, input, successCb, errorCb) { var xsock = navigator.mozTCPSocket.open(resource[2], (resource[3]||70) | 0, {binaryType: 'arraybuffer'}), type = resource[0][0], databuf = [] xsock.ondata = function(e) { var i = 0, db = new Uint8Array(e.data), l = db.length for(;i