Fix #506
This commit is contained in:
parent
bccee036b2
commit
b059bb7fd1
@ -449,6 +449,14 @@
|
|||||||
},
|
},
|
||||||
open: function(url) {
|
open: function(url) {
|
||||||
return (GM_openInTab || window.open)(location.protocol + url, '_blank');
|
return (GM_openInTab || window.open)(location.protocol + url, '_blank');
|
||||||
|
},
|
||||||
|
globalEval: function(code) {
|
||||||
|
var script;
|
||||||
|
script = $.el('script', {
|
||||||
|
textContent: code
|
||||||
|
});
|
||||||
|
$.add(d.head, script);
|
||||||
|
return $.rm(script);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -760,7 +768,8 @@
|
|||||||
if (Conf['Indicate Cross-thread Quotes']) {
|
if (Conf['Indicate Cross-thread Quotes']) {
|
||||||
QuoteCT.node(post);
|
QuoteCT.node(post);
|
||||||
}
|
}
|
||||||
return $.replace(a.parentNode.parentNode, node);
|
$.replace(a.parentNode.parentNode, node);
|
||||||
|
return Main.prettify();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1356,7 +1365,7 @@
|
|||||||
return setTimeout(this.asyncInit);
|
return setTimeout(this.asyncInit);
|
||||||
},
|
},
|
||||||
asyncInit: function() {
|
asyncInit: function() {
|
||||||
var link, script;
|
var link;
|
||||||
if (Conf['Hide Original Post Form']) {
|
if (Conf['Hide Original Post Form']) {
|
||||||
link = $.el('h1', {
|
link = $.el('h1', {
|
||||||
innerHTML: "<a href=javascript:;>" + (g.REPLY ? 'Quick Reply' : 'New Thread') + "</a>"
|
innerHTML: "<a href=javascript:;>" + (g.REPLY ? 'Quick Reply' : 'New Thread') + "</a>"
|
||||||
@ -1370,11 +1379,7 @@
|
|||||||
});
|
});
|
||||||
$.before($.id('postForm'), link);
|
$.before($.id('postForm'), link);
|
||||||
}
|
}
|
||||||
script = $.el('script', {
|
$.globalEval('Recaptcha.focus_response_field=function(){}');
|
||||||
textContent: 'Recaptcha.focus_response_field=function(){}'
|
|
||||||
});
|
|
||||||
$.add(d.head, script);
|
|
||||||
$.rm(script);
|
|
||||||
if (Conf['Persistent QR']) {
|
if (Conf['Persistent QR']) {
|
||||||
QR.dialog();
|
QR.dialog();
|
||||||
if (Conf['Auto Hide QR']) {
|
if (Conf['Auto Hide QR']) {
|
||||||
@ -3282,8 +3287,9 @@
|
|||||||
Time.node(post);
|
Time.node(post);
|
||||||
}
|
}
|
||||||
if (Conf['File Info Formatting']) {
|
if (Conf['File Info Formatting']) {
|
||||||
return FileInfo.node(post);
|
FileInfo.node(post);
|
||||||
}
|
}
|
||||||
|
return Main.prettify();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -4060,6 +4066,7 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Main.hasCodeTags = !!$('script[src="//static.4chan.org/js/prettify/prettify.js"]');
|
||||||
board = $('.board');
|
board = $('.board');
|
||||||
nodes = [];
|
nodes = [];
|
||||||
_ref1 = $$('.postContainer', board);
|
_ref1 = $$('.postContainer', board);
|
||||||
@ -4148,6 +4155,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Main.prettify();
|
||||||
},
|
},
|
||||||
observer: function(mutations) {
|
observer: function(mutations) {
|
||||||
var addedNode, mutation, nodes, _i, _j, _len, _len1, _ref;
|
var addedNode, mutation, nodes, _i, _j, _len, _len1, _ref;
|
||||||
@ -4173,6 +4181,12 @@
|
|||||||
return Main.node([Main.preParse(target)]);
|
return Main.node([Main.preParse(target)]);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
prettify: function() {
|
||||||
|
if (!Main.hasCodeTags) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
return $.globalEval('window.prettyPrint()');
|
||||||
|
},
|
||||||
namespace: '4chan_x.',
|
namespace: '4chan_x.',
|
||||||
version: '2.30.4',
|
version: '2.30.4',
|
||||||
callbacks: [],
|
callbacks: [],
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
master
|
master
|
||||||
|
|
||||||
- Mayhem
|
- Mayhem
|
||||||
|
Fix syntax highlighting in code of fetched posts on /g/.
|
||||||
Add quick [code] tags keybind (alt+c).
|
Add quick [code] tags keybind (alt+c).
|
||||||
|
|
||||||
2.30.4
|
2.30.4
|
||||||
|
|||||||
@ -346,6 +346,10 @@ $.extend $,
|
|||||||
return
|
return
|
||||||
open: (url) ->
|
open: (url) ->
|
||||||
(GM_openInTab or window.open) location.protocol + url, '_blank'
|
(GM_openInTab or window.open) location.protocol + url, '_blank'
|
||||||
|
globalEval: (code) ->
|
||||||
|
script = $.el 'script', textContent: code
|
||||||
|
$.add d.head, script
|
||||||
|
$.rm script
|
||||||
|
|
||||||
$.cache.requests = {}
|
$.cache.requests = {}
|
||||||
|
|
||||||
@ -588,6 +592,7 @@ ExpandComment =
|
|||||||
if Conf['Indicate Cross-thread Quotes']
|
if Conf['Indicate Cross-thread Quotes']
|
||||||
QuoteCT.node post
|
QuoteCT.node post
|
||||||
$.replace a.parentNode.parentNode, node
|
$.replace a.parentNode.parentNode, node
|
||||||
|
Main.prettify()
|
||||||
|
|
||||||
ExpandThread =
|
ExpandThread =
|
||||||
init: ->
|
init: ->
|
||||||
@ -1014,10 +1019,7 @@ QR =
|
|||||||
$.before $.id('postForm'), link
|
$.before $.id('postForm'), link
|
||||||
|
|
||||||
# Prevent original captcha input from being focused on reload.
|
# Prevent original captcha input from being focused on reload.
|
||||||
script = $.el 'script',
|
$.globalEval 'Recaptcha.focus_response_field=function(){}'
|
||||||
textContent: 'Recaptcha.focus_response_field=function(){}'
|
|
||||||
$.add d.head, script
|
|
||||||
$.rm script
|
|
||||||
|
|
||||||
if Conf['Persistent QR']
|
if Conf['Persistent QR']
|
||||||
QR.dialog()
|
QR.dialog()
|
||||||
@ -2489,6 +2491,7 @@ QuotePreview =
|
|||||||
Time.node post
|
Time.node post
|
||||||
if Conf['File Info Formatting']
|
if Conf['File Info Formatting']
|
||||||
FileInfo.node post
|
FileInfo.node post
|
||||||
|
Main.prettify()
|
||||||
|
|
||||||
QuoteOP =
|
QuoteOP =
|
||||||
init: ->
|
init: ->
|
||||||
@ -3088,6 +3091,8 @@ Main =
|
|||||||
if Conf['Index Navigation']
|
if Conf['Index Navigation']
|
||||||
setTimeout -> Nav.init()
|
setTimeout -> Nav.init()
|
||||||
|
|
||||||
|
Main.hasCodeTags = !! $ 'script[src="//static.4chan.org/js/prettify/prettify.js"]'
|
||||||
|
|
||||||
board = $ '.board'
|
board = $ '.board'
|
||||||
nodes = []
|
nodes = []
|
||||||
for node in $$ '.postContainer', board
|
for node in $$ '.postContainer', board
|
||||||
@ -3151,6 +3156,7 @@ Main =
|
|||||||
callback node for node in nodes
|
callback node for node in nodes
|
||||||
catch err
|
catch err
|
||||||
alert "4chan X (#{Main.version}) error: #{err.message}\nhttp://mayhemydg.github.com/4chan-x/#bug-report\n\n#{err.stack}" if notify
|
alert "4chan X (#{Main.version}) error: #{err.message}\nhttp://mayhemydg.github.com/4chan-x/#bug-report\n\n#{err.stack}" if notify
|
||||||
|
Main.prettify()
|
||||||
return
|
return
|
||||||
observer: (mutations) ->
|
observer: (mutations) ->
|
||||||
nodes = []
|
nodes = []
|
||||||
@ -3164,6 +3170,11 @@ Main =
|
|||||||
if /\bpostContainer\b/.test target.className
|
if /\bpostContainer\b/.test target.className
|
||||||
Main.node [Main.preParse target]
|
Main.node [Main.preParse target]
|
||||||
|
|
||||||
|
prettify: ->
|
||||||
|
return unless Main.hasCodeTags
|
||||||
|
# window.prettyPrintOne(html) does not preserve indentation
|
||||||
|
$.globalEval 'window.prettyPrint()'
|
||||||
|
|
||||||
namespace: '4chan_x.'
|
namespace: '4chan_x.'
|
||||||
version: '2.30.4'
|
version: '2.30.4'
|
||||||
callbacks: []
|
callbacks: []
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user