Skip to content

Commit

Permalink
open-in-pdf-reader for edge
Browse files Browse the repository at this point in the history
  • Loading branch information
andy-portmen committed May 12, 2020
1 parent 84a9111 commit ac09cce
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 70 deletions.
2 changes: 2 additions & 0 deletions config.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ exports.ids = {
'khgbdhkpcapllhgfekjegcinegfhjbmi', // YVAD by (Opera) [By @InBasic]
'cehiomcamjpnfmemkmpjadaclohoibgo', // Open in PDF viewer (Chrome)
'honagjpkinogkppkapphkpdffnegagge', // Open in PDF viewer (Opera)
'ciphgjdgpkhlngiadnpebblpcjcoabcp', // Open in PDF viewer (Edge)
'nfpgfobeckckemhmggkdfjkjaiikadnd', // Open in Yandex (Chrome)
'dlobcokaeaiaihfebfhpdoongldphgkf', // Open in Yandex (Opera)
'bffjckjhidlcnenenacdahhpbacpgapo', // Country Flags (Chrome)
Expand All @@ -62,6 +63,7 @@ exports.ids = {
'mgmnomlncpmfgelhofilonnecmbdaoia', // Open in Brave (Chrome) [By @brian-girko]
'pfenoignchfmjmphnpfihgockdhejcjf', // Open in Sumatra (Chrome)
'ojmcfmboidiokgkgmilnmjnjkdbgakpn', // Open in Sumatra (Opera)
'alighchillgifpgaigbgnmhnndoecalj', // TESSST
],
firefox: [
'{b8fa78dd-dae1-4839-9d0e-ce5e213083ce}', // Open in GIMP
Expand Down
2 changes: 1 addition & 1 deletion host.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ let files = [];
const sprocess = [];

const config = {
version: '0.8.8'
version: '0.8.9'
};
// closing node when parent process is killed
process.stdin.resume();
Expand Down
138 changes: 69 additions & 69 deletions messaging.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,119 +7,119 @@
// - Transform - transform message objects to reply objects
// - Debug - transform JavaScript objects to lines of JSON (for debugging, obviously)

var stream = require('stream');
var util = require('util');
const stream = require('stream');
const util = require('util');

function Input() {
stream.Transform.call(this);
stream.Transform.call(this);

// Transform bytes...
this._writableState.objectMode = false;
// ...into objects.
this._readableState.objectMode = true;
// Transform bytes...
this._writableState.objectMode = false;
// ...into objects.
this._readableState.objectMode = true;

// Unparsed data.
this.buf = new Buffer(0);
// Parsed length.
this.len = null;
// Unparsed data.
this.buf = Buffer.alloc(0);
// Parsed length.
this.len = null;
}

util.inherits(Input, stream.Transform);

Input.prototype._transform = function(chunk, encoding, done) {
// Save this chunk.
this.buf = Buffer.concat([ this.buf, chunk ]);

var self = this;

function parseBuf() {
// Do we have a length yet?
if (typeof self.len !== 'number') {
// Nope. Do we have enough bytes for the length?
if (self.buf.length >= 4) {
// Yep. Parse the bytes.
self.len = self.buf.readUInt32LE(0);
// Remove the length bytes from the buffer.
self.buf = self.buf.slice(4);
}
}

// Do we have a length yet? (We may have just parsed it.)
if (typeof self.len === 'number') {
// Yep. Do we have enough bytes for the message?
if (self.buf.length >= self.len) {
// Yep. Slice off the bytes we need.
var message = self.buf.slice(0, self.len);
// Remove the bytes for the message from the buffer.
self.buf = self.buf.slice(self.len);
// Clear the length so we know we need to parse it again.
self.len = null;
// Parse the message bytes.
var obj = JSON.parse(message.toString());
// Enqueue it for reading.
self.push(obj);
// We could have more messages in the buffer so check again.
parseBuf();
}
}
// Save this chunk.
this.buf = Buffer.concat([this.buf, chunk]);

const self = this;

function parseBuf() {
// Do we have a length yet?
if (typeof self.len !== 'number') {
// Nope. Do we have enough bytes for the length?
if (self.buf.length >= 4) {
// Yep. Parse the bytes.
self.len = self.buf.readUInt32LE(0);
// Remove the length bytes from the buffer.
self.buf = self.buf.slice(4);
}
}

// Check for a parsable buffer (both length and message).
parseBuf();
// Do we have a length yet? (We may have just parsed it.)
if (typeof self.len === 'number') {
// Yep. Do we have enough bytes for the message?
if (self.buf.length >= self.len) {
// Yep. Slice off the bytes we need.
const message = self.buf.slice(0, self.len);
// Remove the bytes for the message from the buffer.
self.buf = self.buf.slice(self.len);
// Clear the length so we know we need to parse it again.
self.len = null;
// Parse the message bytes.
const obj = JSON.parse(message.toString());
// Enqueue it for reading.
self.push(obj);
// We could have more messages in the buffer so check again.
parseBuf();
}
}
}

// Check for a parsable buffer (both length and message).
parseBuf();

// We're done.
done();
// We're done.
done();
};

function Output() {
stream.Transform.call(this);
stream.Transform.call(this);

this._writableState.objectMode = true;
this._readableState.objectMode = false;
this._writableState.objectMode = true;
this._readableState.objectMode = false;
}

util.inherits(Output, stream.Transform);

Output.prototype._transform = function(chunk, encoding, done) {
var len = new Buffer(4);
var buf = new Buffer(JSON.stringify(chunk));
const len = Buffer.alloc(4);
const buf = new Buffer(JSON.stringify(chunk));

len.writeUInt32LE(buf.length, 0);
len.writeUInt32LE(buf.length, 0);

this.push(len);
this.push(buf);
this.push(len);
this.push(buf);

done();
done();
};

function Transform(handler) {
stream.Transform.call(this);
stream.Transform.call(this);

this._writableState.objectMode = true;
this._readableState.objectMode = true;
this._writableState.objectMode = true;
this._readableState.objectMode = true;

this.handler = handler;
this.handler = handler;
}

util.inherits(Transform, stream.Transform);

Transform.prototype._transform = function(msg, encoding, done) {
this.handler(msg, this.push.bind(this), done);
this.handler(msg, this.push.bind(this), done);
};

function Debug() {
stream.Transform.call(this);
stream.Transform.call(this);

this._writableState.objectMode = true;
this._readableState.objectMode = false;
this._writableState.objectMode = true;
this._readableState.objectMode = false;
}

util.inherits(Debug, stream.Transform);

Debug.prototype._transform = function(chunk, encoding, done) {
this.push(JSON.stringify(chunk) + '\n');
this.push(JSON.stringify(chunk) + '\n');

done();
done();
};

exports.Input = Input;
Expand Down

0 comments on commit ac09cce

Please sign in to comment.