From 49f2251008ae81ccf74402528eb48c8c6364ad39 Mon Sep 17 00:00:00 2001 From: James Campos Date: Sun, 14 Nov 2010 01:25:17 -0800 Subject: [PATCH] add x-browser GM_openInTab; add t - tabopen --- 4chan_x.coffee | 13 ++++++++++++- 4chan_x.js | 18 ++++++++++++++++-- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/4chan_x.coffee b/4chan_x.coffee index 71c09575f..66470b6c6 100644 --- a/4chan_x.coffee +++ b/4chan_x.coffee @@ -50,6 +50,14 @@ AEOS = style.type = 'text/css' style.textContent = css document.getElementsByTagName('head')[0].appendChild style + window.GM_openInTab = (url) -> + form = document.getElementById 'GM_form' + form.action = link + form.submit() + form = document.createElement 'form' + form.id = 'GM_form' + document.body.appendChild form + #dialog styling GM_addStyle ' div.dialog { @@ -361,7 +369,7 @@ iframeLoad = -> keyboardNav = (e) -> char = String.fromCharCode e.keyCode - unless char in '1234567890GHJKLO' + unless char in '1234567890GHJKLOT' return e.preventDefault() hash = location.hash @@ -407,6 +415,9 @@ keyboardNav = (e) -> when "O" qrLink = $ "#{hash} ~ span[id] a:not(:first-child)" quickReply.call qrLink + when "T" + href = $("#{hash} ~ span[id] a:last-of-type").href + GM_openInTab href g.count = 0 nodeInserted = (e) -> diff --git a/4chan_x.js b/4chan_x.js index f6d870d6a..ff3083311 100644 --- a/4chan_x.js +++ b/4chan_x.js @@ -22,6 +22,7 @@ }; AEOS = { init: function() { + var form; if (!(typeof GM_deleteValue !== "undefined" && GM_deleteValue !== null)) { window.GM_setValue = function(name, value) { value = (typeof value)[0] + value; @@ -50,6 +51,15 @@ style.textContent = css; return document.getElementsByTagName('head')[0].appendChild(style); }; + window.GM_openInTab = function(url) { + var form; + form = document.getElementById('GM_form'); + form.action = link; + return form.submit(); + }; + form = document.createElement('form'); + form.id = 'GM_form'; + document.body.appendChild(form); } return GM_addStyle('\ div.dialog {\ @@ -445,9 +455,9 @@ return recaptchaReload(); }; keyboardNav = function(e) { - var _i, _len, char, count, hash, position, qrLink, temp; + var _i, _len, char, count, hash, href, position, qrLink, temp; char = String.fromCharCode(e.keyCode); - if (!((function(){ for (var _i=0, _len='1234567890GHJKLO'.length; _i<_len; _i++) { if ('1234567890GHJKLO'[_i] === char) return true; } return false; }).call(this))) { + if (!((function(){ for (var _i=0, _len='1234567890GHJKLOT'.length; _i<_len; _i++) { if ('1234567890GHJKLOT'[_i] === char) return true; } return false; }).call(this))) { return null; } e.preventDefault(); @@ -515,6 +525,10 @@ qrLink = $("" + (hash) + " ~ span[id] a:not(:first-child)"); quickReply.call(qrLink); break; + case "T": + href = $("" + (hash) + " ~ span[id] a:last-of-type").href; + GM_openInTab(href); + break; } return (g.count = 0); };