From 31db70873b252a5a1fe5aeea25dd62754a2b09bc Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Wed, 21 Sep 2011 22:45:26 +0200 Subject: [PATCH] @run-at document-start --- 4chan_x.user.js | 28 ++++++++++++++-------------- Cakefile | 1 + changelog | 2 ++ script.coffee | 20 +++++++++----------- 4 files changed, 26 insertions(+), 25 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 0e48c1f4f..19e322c76 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -6,6 +6,7 @@ // @license MIT; http://en.wikipedia.org/wiki/Mit_license // @include http://boards.4chan.org/* // @include http://sys.4chan.org/* +// @run-at document-start // @icon https://raw.github.com/aeosynth/4chan-x/gh-pages/favicon.png // ==/UserScript== @@ -60,7 +61,7 @@ */ (function() { - var $, $$, DAY, Favicon, HOUR, MINUTE, Main, NAMESPACE, Recaptcha, SECOND, Time, anonymize, conf, config, cooldown, d, expandComment, expandThread, firstRun, g, getTitle, imgExpand, imgGif, imgHover, imgPreloading, key, keybinds, log, nav, nodeInserted, options, qr, quoteBacklink, quoteInline, quoteOP, quotePreview, redirect, replyHiding, reportButton, revealSpoilers, sauce, threadHiding, threadStats, threading, titlePost, ui, unread, updater, val, watcher; + var $, $$, DAY, Favicon, HOUR, MINUTE, Main, NAMESPACE, Recaptcha, SECOND, Time, anonymize, conf, config, cooldown, d, expandComment, expandThread, firstRun, g, getTitle, imgExpand, imgGif, imgHover, imgPreloading, key, keybinds, log, nav, nodeInserted, options, pathname, qr, quoteBacklink, quoteInline, quoteOP, quotePreview, redirect, replyHiding, reportButton, revealSpoilers, sauce, temp, threadHiding, threadStats, threading, titlePost, ui, unread, updater, val, watcher; var __slice = Array.prototype.slice; config = { main: { @@ -501,6 +502,14 @@ val = conf[key]; conf[key] = $.get(key, val); } + pathname = location.pathname.substring(1).split('/'); + g.BOARD = pathname[0], temp = pathname[1]; + if (temp === 'res') { + g.REPLY = temp; + g.THREAD_ID = pathname[2]; + } else { + g.PAGENUM = parseInt(temp) || 0; + } $$ = function(selector, root) { if (root == null) { root = d.body; @@ -595,7 +604,7 @@ } }, toggle: function(thread) { - var a, backlink, num, pathname, prev, table, threadID, _i, _len, _ref, _ref2, _results; + var a, backlink, num, prev, table, threadID, _i, _len, _ref, _ref2, _results; threadID = thread.firstChild.id; pathname = "/" + g.BOARD + "/res/" + threadID; a = $('a.omittedposts', thread); @@ -2216,7 +2225,7 @@ }); }, toggle: function(e) { - var el, hidden, id, inline, inlined, pathname, root, table, threadID, _i, _len, _ref; + var el, hidden, id, inline, inlined, root, table, threadID, _i, _len, _ref; if (e.shiftKey || e.altKey || e.ctrlKey || e.button !== 0) { return; } @@ -2806,16 +2815,7 @@ }; Main = { init: function() { - var callback, canPost, cutoff, form, hiddenThreads, id, lastChecked, now, op, pathname, table, temp, timestamp, tzOffset, _i, _j, _k, _l, _len, _len2, _len3, _len4, _ref, _ref2, _ref3, _ref4, _ref5; - $.unbind(window, 'load', Main.init); - pathname = location.pathname.substring(1).split('/'); - g.BOARD = pathname[0], temp = pathname[1]; - if (temp === 'res') { - g.REPLY = temp; - g.THREAD_ID = pathname[2]; - } else { - g.PAGENUM = parseInt(temp) || 0; - } + var callback, canPost, cutoff, form, hiddenThreads, id, lastChecked, now, op, table, timestamp, tzOffset, _i, _j, _k, _l, _len, _len2, _len3, _len4, _ref, _ref2, _ref3, _ref4, _ref5; if (location.hostname === 'sys.4chan.org') { qr.sys(); return; @@ -3208,6 +3208,6 @@ if (d.body) { Main.init(); } else { - $.bind(window, 'load', Main.init); + $.bind(document, 'DOMContentLoaded', Main.init); } }).call(this); diff --git a/Cakefile b/Cakefile index 6d5ac1eac..81ea76979 100644 --- a/Cakefile +++ b/Cakefile @@ -11,6 +11,7 @@ HEADER = """ // @license MIT; http://en.wikipedia.org/wiki/Mit_license // @include http://boards.4chan.org/* // @include http://sys.4chan.org/* +// @run-at document-start // @icon https://raw.github.com/aeosynth/4chan-x/gh-pages/favicon.png // ==/UserScript== diff --git a/changelog b/changelog index f7f7df4d7..df4ada742 100644 --- a/changelog +++ b/changelog @@ -1,4 +1,6 @@ master +- mayhem + initiate 4chan X earlier 2.20.1 - mayhem diff --git a/script.coffee b/script.coffee index e7f12dd9e..50bb69279 100644 --- a/script.coffee +++ b/script.coffee @@ -363,6 +363,14 @@ else for key, val of conf conf[key] = $.get key, val +pathname = location.pathname.substring(1).split('/') +[g.BOARD, temp] = pathname +if temp is 'res' + g.REPLY = temp + g.THREAD_ID = pathname[2] +else + g.PAGENUM = parseInt(temp) or 0 + $$ = (selector, root=d.body) -> Array::slice.call root.querySelectorAll selector @@ -2178,15 +2186,6 @@ firstRun = Main = init: -> - $.unbind window, 'load', Main.init - pathname = location.pathname.substring(1).split('/') - [g.BOARD, temp] = pathname - if temp is 'res' - g.REPLY = temp - g.THREAD_ID = pathname[2] - else - g.PAGENUM = parseInt(temp) or 0 - if location.hostname is 'sys.4chan.org' qr.sys() return @@ -2557,8 +2556,7 @@ Main = } ' -#XXX Opera will load early if script is saved w/o .user if d.body Main.init() else - $.bind window, 'load', Main.init + $.bind document, 'DOMContentLoaded', Main.init