Mayhem made responseType JSON default for any URL containing .json.
This commit is contained in:
parent
f133da454d
commit
b62d82bed0
2
LICENSE
2
LICENSE
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* 4chan X - Version 1.3.2 - 2014-01-22
|
* 4chan X - Version 1.3.2 - 2014-01-24
|
||||||
*
|
*
|
||||||
* Licensed under the MIT license.
|
* Licensed under the MIT license.
|
||||||
* https://github.com/seaweedchan/4chan-x/blob/master/LICENSE
|
* https://github.com/seaweedchan/4chan-x/blob/master/LICENSE
|
||||||
|
|||||||
@ -23,7 +23,7 @@
|
|||||||
// ==/UserScript==
|
// ==/UserScript==
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 4chan X - Version 1.3.2 - 2014-01-22
|
* 4chan X - Version 1.3.2 - 2014-01-24
|
||||||
*
|
*
|
||||||
* Licensed under the MIT license.
|
* Licensed under the MIT license.
|
||||||
* https://github.com/seaweedchan/4chan-x/blob/master/LICENSE
|
* https://github.com/seaweedchan/4chan-x/blob/master/LICENSE
|
||||||
@ -7431,12 +7431,13 @@
|
|||||||
}
|
}
|
||||||
return $.ajax("//api.4chan.org/" + post.board + "/res/" + post.thread + ".json", {
|
return $.ajax("//api.4chan.org/" + post.board + "/res/" + post.thread + ".json", {
|
||||||
onload: function() {
|
onload: function() {
|
||||||
var i, postObj;
|
var i, postObj, posts;
|
||||||
if (this.status !== 200) {
|
if (this.status !== 200) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
i = 0;
|
i = 0;
|
||||||
while (postObj = JSON.parse(this.response).posts[i++]) {
|
posts = this.response.posts;
|
||||||
|
while (postObj = posts[i++]) {
|
||||||
if (postObj.no === post.ID) {
|
if (postObj.no === post.ID) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -8261,7 +8262,7 @@
|
|||||||
switch (response.status) {
|
switch (response.status) {
|
||||||
case 200:
|
case 200:
|
||||||
case 304:
|
case 304:
|
||||||
text = "" + (service.text(JSON.parse(response.responseText)));
|
text = "" + (service.text(response.response));
|
||||||
if (Conf['Embedding']) {
|
if (Conf['Embedding']) {
|
||||||
embed.dataset.title = text;
|
embed.dataset.title = text;
|
||||||
}
|
}
|
||||||
@ -8357,7 +8358,7 @@
|
|||||||
if (status !== 200 && status !== 304) {
|
if (status !== 200 && status !== 304) {
|
||||||
return div.innerHTML = "ERROR " + status;
|
return div.innerHTML = "ERROR " + status;
|
||||||
}
|
}
|
||||||
files = JSON.parse(this.response).files;
|
files = this.response.files;
|
||||||
_ref = ['video/mp4', 'video/ogv', 'image/svg+xml', 'image/png', 'image/gif', 'image/jpeg', 'image/svg', 'audio/mpeg'];
|
_ref = ['video/mp4', 'video/ogv', 'image/svg+xml', 'image/png', 'image/gif', 'image/jpeg', 'image/svg', 'audio/mpeg'];
|
||||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||||
type = _ref[_i];
|
type = _ref[_i];
|
||||||
@ -12155,13 +12156,13 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
clean: function() {
|
clean: function() {
|
||||||
var posts, threads;
|
var board;
|
||||||
posts = g.posts, threads = g.threads;
|
|
||||||
g.threads.forEach(function(thread) {
|
g.threads.forEach(function(thread) {
|
||||||
return thread.collect();
|
return thread.collect();
|
||||||
});
|
});
|
||||||
QuoteBacklink.containers = {};
|
QuoteBacklink.containers = {};
|
||||||
return $.rmAll($('.board'));
|
board = $('.board');
|
||||||
|
return $.replace(board, board.cloneNode(false));
|
||||||
},
|
},
|
||||||
features: [['Thread Excerpt', ThreadExcerpt], ['Unread Count', Unread], ['Quote Threading', QuoteThreading], ['Thread Stats', ThreadStats], ['Thread Updater', ThreadUpdater], ['Thread Expansion', ExpandThread]],
|
features: [['Thread Excerpt', ThreadExcerpt], ['Unread Count', Unread], ['Quote Threading', QuoteThreading], ['Thread Stats', ThreadStats], ['Thread Updater', ThreadUpdater], ['Thread Expansion', ExpandThread]],
|
||||||
disconnect: function() {
|
disconnect: function() {
|
||||||
@ -12260,7 +12261,6 @@
|
|||||||
},
|
},
|
||||||
updateBoard: function(boardID) {
|
updateBoard: function(boardID) {
|
||||||
var fullBoardList, onload, req;
|
var fullBoardList, onload, req;
|
||||||
req = null;
|
|
||||||
fullBoardList = $('#full-board-list', Header.boardList);
|
fullBoardList = $('#full-board-list', Header.boardList);
|
||||||
$.rmClass($('.current', fullBoardList), 'current');
|
$.rmClass($('.current', fullBoardList), 'current');
|
||||||
$.addClass($("a[href*='/" + boardID + "/']", fullBoardList), 'current');
|
$.addClass($("a[href*='/" + boardID + "/']", fullBoardList), 'current');
|
||||||
@ -12276,7 +12276,7 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
_ref = JSON.parse(req.response).boards;
|
_ref = req.response.boards;
|
||||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||||
aboard = _ref[_i];
|
aboard = _ref[_i];
|
||||||
if (!(aboard.board === boardID)) {
|
if (!(aboard.board === boardID)) {
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
// Generated by CoffeeScript
|
// Generated by CoffeeScript
|
||||||
/*
|
/*
|
||||||
* 4chan X - Version 1.3.2 - 2014-01-22
|
* 4chan X - Version 1.3.2 - 2014-01-24
|
||||||
*
|
*
|
||||||
* Licensed under the MIT license.
|
* Licensed under the MIT license.
|
||||||
* https://github.com/seaweedchan/4chan-x/blob/master/LICENSE
|
* https://github.com/seaweedchan/4chan-x/blob/master/LICENSE
|
||||||
@ -7446,12 +7446,13 @@
|
|||||||
}
|
}
|
||||||
return $.ajax("//api.4chan.org/" + post.board + "/res/" + post.thread + ".json", {
|
return $.ajax("//api.4chan.org/" + post.board + "/res/" + post.thread + ".json", {
|
||||||
onload: function() {
|
onload: function() {
|
||||||
var i, postObj;
|
var i, postObj, posts;
|
||||||
if (this.status !== 200) {
|
if (this.status !== 200) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
i = 0;
|
i = 0;
|
||||||
while (postObj = JSON.parse(this.response).posts[i++]) {
|
posts = this.response.posts;
|
||||||
|
while (postObj = posts[i++]) {
|
||||||
if (postObj.no === post.ID) {
|
if (postObj.no === post.ID) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -8254,7 +8255,7 @@
|
|||||||
switch (response.status) {
|
switch (response.status) {
|
||||||
case 200:
|
case 200:
|
||||||
case 304:
|
case 304:
|
||||||
text = "" + (service.text(JSON.parse(response.responseText)));
|
text = "" + (service.text(response.response));
|
||||||
if (Conf['Embedding']) {
|
if (Conf['Embedding']) {
|
||||||
embed.dataset.title = text;
|
embed.dataset.title = text;
|
||||||
}
|
}
|
||||||
@ -8350,7 +8351,7 @@
|
|||||||
if (status !== 200 && status !== 304) {
|
if (status !== 200 && status !== 304) {
|
||||||
return div.innerHTML = "ERROR " + status;
|
return div.innerHTML = "ERROR " + status;
|
||||||
}
|
}
|
||||||
files = JSON.parse(this.response).files;
|
files = this.response.files;
|
||||||
_ref = ['video/mp4', 'video/ogv', 'image/svg+xml', 'image/png', 'image/gif', 'image/jpeg', 'image/svg', 'audio/mpeg'];
|
_ref = ['video/mp4', 'video/ogv', 'image/svg+xml', 'image/png', 'image/gif', 'image/jpeg', 'image/svg', 'audio/mpeg'];
|
||||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||||
type = _ref[_i];
|
type = _ref[_i];
|
||||||
@ -12154,13 +12155,13 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
clean: function() {
|
clean: function() {
|
||||||
var posts, threads;
|
var board;
|
||||||
posts = g.posts, threads = g.threads;
|
|
||||||
g.threads.forEach(function(thread) {
|
g.threads.forEach(function(thread) {
|
||||||
return thread.collect();
|
return thread.collect();
|
||||||
});
|
});
|
||||||
QuoteBacklink.containers = {};
|
QuoteBacklink.containers = {};
|
||||||
return $.rmAll($('.board'));
|
board = $('.board');
|
||||||
|
return $.replace(board, board.cloneNode(false));
|
||||||
},
|
},
|
||||||
features: [['Thread Excerpt', ThreadExcerpt], ['Unread Count', Unread], ['Quote Threading', QuoteThreading], ['Thread Stats', ThreadStats], ['Thread Updater', ThreadUpdater], ['Thread Expansion', ExpandThread]],
|
features: [['Thread Excerpt', ThreadExcerpt], ['Unread Count', Unread], ['Quote Threading', QuoteThreading], ['Thread Stats', ThreadStats], ['Thread Updater', ThreadUpdater], ['Thread Expansion', ExpandThread]],
|
||||||
disconnect: function() {
|
disconnect: function() {
|
||||||
@ -12259,7 +12260,6 @@
|
|||||||
},
|
},
|
||||||
updateBoard: function(boardID) {
|
updateBoard: function(boardID) {
|
||||||
var fullBoardList, onload, req;
|
var fullBoardList, onload, req;
|
||||||
req = null;
|
|
||||||
fullBoardList = $('#full-board-list', Header.boardList);
|
fullBoardList = $('#full-board-list', Header.boardList);
|
||||||
$.rmClass($('.current', fullBoardList), 'current');
|
$.rmClass($('.current', fullBoardList), 'current');
|
||||||
$.addClass($("a[href*='/" + boardID + "/']", fullBoardList), 'current');
|
$.addClass($("a[href*='/" + boardID + "/']", fullBoardList), 'current');
|
||||||
@ -12275,7 +12275,7 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
_ref = JSON.parse(req.response).boards;
|
_ref = req.response.boards;
|
||||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||||
aboard = _ref[_i];
|
aboard = _ref[_i];
|
||||||
if (!(aboard.board === boardID)) {
|
if (!(aboard.board === boardID)) {
|
||||||
|
|||||||
@ -33,15 +33,12 @@ Navigate =
|
|||||||
return
|
return
|
||||||
|
|
||||||
clean: ->
|
clean: ->
|
||||||
{posts, threads} = g
|
|
||||||
|
|
||||||
# Garbage collection
|
# Garbage collection
|
||||||
g.threads.forEach (thread) -> thread.collect()
|
g.threads.forEach (thread) -> thread.collect()
|
||||||
|
|
||||||
QuoteBacklink.containers = {}
|
QuoteBacklink.containers = {}
|
||||||
|
|
||||||
# Delete nodes
|
board = $('.board')
|
||||||
$.rmAll $ '.board'
|
$.replace board, board.cloneNode false
|
||||||
|
|
||||||
features: [
|
features: [
|
||||||
['Thread Excerpt', ThreadExcerpt]
|
['Thread Excerpt', ThreadExcerpt]
|
||||||
@ -112,8 +109,6 @@ Navigate =
|
|||||||
}[g.VIEW]()
|
}[g.VIEW]()
|
||||||
|
|
||||||
updateBoard: (boardID) ->
|
updateBoard: (boardID) ->
|
||||||
req = null
|
|
||||||
|
|
||||||
fullBoardList = $ '#full-board-list', Header.boardList
|
fullBoardList = $ '#full-board-list', Header.boardList
|
||||||
$.rmClass $('.current', fullBoardList), 'current'
|
$.rmClass $('.current', fullBoardList), 'current'
|
||||||
$.addClass $("a[href*='/#{boardID}/']", fullBoardList), 'current'
|
$.addClass $("a[href*='/#{boardID}/']", fullBoardList), 'current'
|
||||||
@ -129,7 +124,7 @@ Navigate =
|
|||||||
return unless req.status is 200
|
return unless req.status is 200
|
||||||
|
|
||||||
try
|
try
|
||||||
for aboard in JSON.parse(req.response).boards when aboard.board is boardID
|
for aboard in req.response.boards when aboard.board is boardID
|
||||||
board = aboard
|
board = aboard
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|||||||
@ -201,7 +201,8 @@ Gallery =
|
|||||||
$.ajax "//api.4chan.org/#{post.board}/res/#{post.thread}.json", onload: ->
|
$.ajax "//api.4chan.org/#{post.board}/res/#{post.thread}.json", onload: ->
|
||||||
return if @status isnt 200
|
return if @status isnt 200
|
||||||
i = 0
|
i = 0
|
||||||
while postObj = JSON.parse(@response).posts[i++]
|
{posts} = @response
|
||||||
|
while postObj = posts[i++]
|
||||||
break if postObj.no is post.ID
|
break if postObj.no is post.ID
|
||||||
unless postObj.no
|
unless postObj.no
|
||||||
return post.kill()
|
return post.kill()
|
||||||
|
|||||||
@ -241,7 +241,7 @@ Linkify =
|
|||||||
service = Linkify.types[key].title
|
service = Linkify.types[key].title
|
||||||
switch response.status
|
switch response.status
|
||||||
when 200, 304
|
when 200, 304
|
||||||
text = "#{service.text JSON.parse response.responseText}"
|
text = "#{service.text response.response}"
|
||||||
if Conf['Embedding']
|
if Conf['Embedding']
|
||||||
embed.dataset.title = text
|
embed.dataset.title = text
|
||||||
when 404
|
when 404
|
||||||
@ -304,7 +304,7 @@ Linkify =
|
|||||||
$.cache "https://mediacru.sh/#{a.dataset.uid}.json", ->
|
$.cache "https://mediacru.sh/#{a.dataset.uid}.json", ->
|
||||||
{status} = @
|
{status} = @
|
||||||
return div.innerHTML = "ERROR #{status}" unless status in [200, 304]
|
return div.innerHTML = "ERROR #{status}" unless status in [200, 304]
|
||||||
{files} = JSON.parse @response
|
{files} = @response
|
||||||
for type in ['video/mp4', 'video/ogv', 'image/svg+xml', 'image/png', 'image/gif', 'image/jpeg', 'image/svg', 'audio/mpeg']
|
for type in ['video/mp4', 'video/ogv', 'image/svg+xml', 'image/png', 'image/gif', 'image/jpeg', 'image/svg', 'audio/mpeg']
|
||||||
for file in files
|
for file in files
|
||||||
if file.type is type
|
if file.type is type
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user