MayhemYDG/4chan-x — Issue #84: Catalog synchronization
Author: desuwa
Created: 2011-12-27 22:33:54+00:00
State: open

What do you think about syncing watched/hidden threads and maybe even filters between 4chan X and the catalog?
Making a standalone userscript that plays well with 4chan X might be a better idea, but I still prefer asking your opinion first.

Here's a demo userscript to show what I'm talking about `https://gist.github.com/1515048`
It acts a bit like a botnet and uses an iframe and *postMessage()* to bypass the same-origin policy and access the catalog's localStorage.

The iframe points to `http://catalog.neet.tv/sync.html`
This page embeds the receiver script `https://github.com/desuwa/fourcat/blob/master/public/javascripts/fourcat-sync.js`
The receiver scripts handles messages from *boards.4chan.org* and *sys.4chan.org* only and accepts a stringified array of objects. To pin (or watch) a thread for example, the postMessage() call will resemble something like that:

var cmd = {
type: 'pin',
slug: 'jp',
pid: '8301113',
r: document.getElementsByTagName('blockquote').length - 1 //replies
};
var remote = 'http://catalog.neet.tv';
frame.contentWindow.postMessage(JSON.stringify( [cmd] ), remote););

It can of course work the other way around, sending hidden and pinned threads, and maybe filters to 4chan X.
I haven't implemented those methods though because I'm too [spoiler]lazy[/spoiler].

I tried writing a ghetto auto-pinning userscript by the way, but the thing just can't work with 4chan because of the instant redirection from /post

Cheers