From 02a739c57289df0a4bfac34fd42b9eeed51259d6 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Sat, 25 Aug 2012 03:38:26 +0200 Subject: [PATCH] Add $.unsafeWindow. --- 4chan_x.user.js | 5 +++++ script.coffee | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/4chan_x.user.js b/4chan_x.user.js index 087ff5879..14331ce3a 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -488,6 +488,11 @@ $.add(d.head, script); return $.rm(script); }, + unsafeWindow: window.opera && window || unsafeWindow || (function() { + d.createElement('p'); + p.setAttribute('onclick', 'return window'); + return el.onclick(); + })(), shortenFilename: function(filename, isOP) { var threshold; threshold = isOP ? 40 : 30; diff --git a/script.coffee b/script.coffee index a8e1726f6..7ac007124 100644 --- a/script.coffee +++ b/script.coffee @@ -371,6 +371,12 @@ $.extend $, textContent: code $.add d.head, script $.rm script + # http://mths.be/unsafewindow + unsafeWindow: window.opera and window or unsafeWindow or (-> + d.createElement 'p' + p.setAttribute 'onclick', 'return window' + el.onclick() + )() shortenFilename: (filename, isOP) -> # FILENAME SHORTENING SCIENCE: # OPs have a +10 characters threshold.