Tighten up Get.threadFromRoom, Get.contextFromNode
This commit is contained in:
parent
5db027356e
commit
3f438d55ff
2
LICENSE
2
LICENSE
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* 4chan X - Version 1.4.1 - 2014-03-10
|
* 4chan X - Version 1.4.1 - 2014-03-11
|
||||||
*
|
*
|
||||||
* Licensed under the MIT license.
|
* Licensed under the MIT license.
|
||||||
* https://github.com/Spittie/4chan-x/blob/master/LICENSE
|
* https://github.com/Spittie/4chan-x/blob/master/LICENSE
|
||||||
|
|||||||
@ -24,7 +24,7 @@
|
|||||||
// ==/UserScript==
|
// ==/UserScript==
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 4chan X - Version 1.4.1 - 2014-03-10
|
* 4chan X - Version 1.4.1 - 2014-03-11
|
||||||
*
|
*
|
||||||
* Licensed under the MIT license.
|
* Licensed under the MIT license.
|
||||||
* https://github.com/Spittie/4chan-x/blob/master/LICENSE
|
* https://github.com/Spittie/4chan-x/blob/master/LICENSE
|
||||||
@ -1087,6 +1087,7 @@
|
|||||||
this.thread.OP = this;
|
this.thread.OP = this;
|
||||||
this.thread.isSticky = !!$('.stickyIcon', info);
|
this.thread.isSticky = !!$('.stickyIcon', info);
|
||||||
this.thread.isClosed = !!$('.closedIcon', info);
|
this.thread.isClosed = !!$('.closedIcon', info);
|
||||||
|
root.parentElement.dataset.fullID = this.fullID;
|
||||||
}
|
}
|
||||||
this.info = {};
|
this.info = {};
|
||||||
if (subject = $('.subject', info)) {
|
if (subject = $('.subject', info)) {
|
||||||
@ -3844,7 +3845,7 @@
|
|||||||
return "/" + thread.board + "/ - " + excerpt;
|
return "/" + thread.board + "/ - " + excerpt;
|
||||||
},
|
},
|
||||||
threadFromRoot: function(root) {
|
threadFromRoot: function(root) {
|
||||||
return g.threads["" + g.BOARD + "." + root.id.slice(1)];
|
return g.threads[root.dataset.fullID];
|
||||||
},
|
},
|
||||||
threadFromNode: function(node) {
|
threadFromNode: function(node) {
|
||||||
return Get.threadFromRoot($.x('ancestor::div[@class="thread"]', node));
|
return Get.threadFromRoot($.x('ancestor::div[@class="thread"]', node));
|
||||||
@ -3862,9 +3863,7 @@
|
|||||||
return Get.postFromRoot($.x('ancestor::div[contains(@class,"postContainer")][1]', node));
|
return Get.postFromRoot($.x('ancestor::div[contains(@class,"postContainer")][1]', node));
|
||||||
},
|
},
|
||||||
contextFromNode: function(node) {
|
contextFromNode: function(node) {
|
||||||
var snapshot;
|
return Get.postFromRoot($.x('ancestor::div[@class="thread"]', node).firstElementChild);
|
||||||
snapshot = $.X('ancestor::div[contains(@class,"postContainer")]', node);
|
|
||||||
return Get.postFromRoot(snapshot.snapshotItem(snapshot.length - 1));
|
|
||||||
},
|
},
|
||||||
postDataFromLink: function(link) {
|
postDataFromLink: function(link) {
|
||||||
var boardID, path, postID, threadID, _ref;
|
var boardID, path, postID, threadID, _ref;
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
// Generated by CoffeeScript
|
// Generated by CoffeeScript
|
||||||
/*
|
/*
|
||||||
* 4chan X - Version 1.4.1 - 2014-03-10
|
* 4chan X - Version 1.4.1 - 2014-03-11
|
||||||
*
|
*
|
||||||
* Licensed under the MIT license.
|
* Licensed under the MIT license.
|
||||||
* https://github.com/Spittie/4chan-x/blob/master/LICENSE
|
* https://github.com/Spittie/4chan-x/blob/master/LICENSE
|
||||||
@ -1141,6 +1141,7 @@
|
|||||||
this.thread.OP = this;
|
this.thread.OP = this;
|
||||||
this.thread.isSticky = !!$('.stickyIcon', info);
|
this.thread.isSticky = !!$('.stickyIcon', info);
|
||||||
this.thread.isClosed = !!$('.closedIcon', info);
|
this.thread.isClosed = !!$('.closedIcon', info);
|
||||||
|
root.parentElement.dataset.fullID = this.fullID;
|
||||||
}
|
}
|
||||||
this.info = {};
|
this.info = {};
|
||||||
if (subject = $('.subject', info)) {
|
if (subject = $('.subject', info)) {
|
||||||
@ -3903,7 +3904,7 @@
|
|||||||
return "/" + thread.board + "/ - " + excerpt;
|
return "/" + thread.board + "/ - " + excerpt;
|
||||||
},
|
},
|
||||||
threadFromRoot: function(root) {
|
threadFromRoot: function(root) {
|
||||||
return g.threads["" + g.BOARD + "." + root.id.slice(1)];
|
return g.threads[root.dataset.fullID];
|
||||||
},
|
},
|
||||||
threadFromNode: function(node) {
|
threadFromNode: function(node) {
|
||||||
return Get.threadFromRoot($.x('ancestor::div[@class="thread"]', node));
|
return Get.threadFromRoot($.x('ancestor::div[@class="thread"]', node));
|
||||||
@ -3921,9 +3922,7 @@
|
|||||||
return Get.postFromRoot($.x('ancestor::div[contains(@class,"postContainer")][1]', node));
|
return Get.postFromRoot($.x('ancestor::div[contains(@class,"postContainer")][1]', node));
|
||||||
},
|
},
|
||||||
contextFromNode: function(node) {
|
contextFromNode: function(node) {
|
||||||
var snapshot;
|
return Get.postFromRoot($.x('ancestor::div[@class="thread"]', node).firstElementChild);
|
||||||
snapshot = $.X('ancestor::div[contains(@class,"postContainer")]', node);
|
|
||||||
return Get.postFromRoot(snapshot.snapshotItem(snapshot.length - 1));
|
|
||||||
},
|
},
|
||||||
postDataFromLink: function(link) {
|
postDataFromLink: function(link) {
|
||||||
var boardID, path, postID, threadID, _ref;
|
var boardID, path, postID, threadID, _ref;
|
||||||
|
|||||||
@ -8,7 +8,7 @@ Get =
|
|||||||
excerpt = "#{excerpt[...67]}..."
|
excerpt = "#{excerpt[...67]}..."
|
||||||
"/#{thread.board}/ - #{excerpt}"
|
"/#{thread.board}/ - #{excerpt}"
|
||||||
threadFromRoot: (root) ->
|
threadFromRoot: (root) ->
|
||||||
g.threads["#{g.BOARD}.#{root.id[1..]}"]
|
g.threads[root.dataset.fullID]
|
||||||
threadFromNode: (node) ->
|
threadFromNode: (node) ->
|
||||||
Get.threadFromRoot $.x 'ancestor::div[@class="thread"]', node
|
Get.threadFromRoot $.x 'ancestor::div[@class="thread"]', node
|
||||||
postFromRoot: (root) ->
|
postFromRoot: (root) ->
|
||||||
@ -17,8 +17,7 @@ Get =
|
|||||||
postFromNode: (node) ->
|
postFromNode: (node) ->
|
||||||
Get.postFromRoot $.x 'ancestor::div[contains(@class,"postContainer")][1]', node
|
Get.postFromRoot $.x 'ancestor::div[contains(@class,"postContainer")][1]', node
|
||||||
contextFromNode: (node) ->
|
contextFromNode: (node) ->
|
||||||
snapshot = $.X 'ancestor::div[contains(@class,"postContainer")]', node
|
Get.postFromRoot $.x('ancestor::div[@class="thread"]', node).firstElementChild
|
||||||
Get.postFromRoot snapshot.snapshotItem(snapshot.length - 1)
|
|
||||||
postDataFromLink: (link) ->
|
postDataFromLink: (link) ->
|
||||||
if link.hostname is 'boards.4chan.org'
|
if link.hostname is 'boards.4chan.org'
|
||||||
path = link.pathname.split '/'
|
path = link.pathname.split '/'
|
||||||
|
|||||||
@ -23,6 +23,7 @@ class Post
|
|||||||
@thread.OP = @
|
@thread.OP = @
|
||||||
@thread.isSticky = !!$ '.stickyIcon', info
|
@thread.isSticky = !!$ '.stickyIcon', info
|
||||||
@thread.isClosed = !!$ '.closedIcon', info
|
@thread.isClosed = !!$ '.closedIcon', info
|
||||||
|
root.parentElement.dataset.fullID = @fullID
|
||||||
|
|
||||||
@info = {}
|
@info = {}
|
||||||
if subject = $ '.subject', info
|
if subject = $ '.subject', info
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user