mirror of
https://github.com/viq/NewsBlur.git
synced 2025-09-18 21:43:31 +00:00
Tightening up story finding.
This commit is contained in:
parent
2e3cbdb0ce
commit
33edc9683a
1 changed files with 22 additions and 8 deletions
|
@ -494,11 +494,25 @@
|
||||||
var self = this;
|
var self = this;
|
||||||
var $iframe = $('.NB-feed-frame');
|
var $iframe = $('.NB-feed-frame');
|
||||||
var title = story_title.replace('^\s+|\s+$', '');
|
var title = story_title.replace('^\s+|\s+$', '');
|
||||||
var $story, $stories = [], title_words;
|
var $story, $stories = [], title_words, $reduced_stories = [];
|
||||||
|
|
||||||
$iframe.contents().find(':contains('+title+')').each(function(){
|
NEWSBLUR.log(['SS:', story_title, title]);
|
||||||
$stories.push(this);
|
$stories = $iframe.contents().find(':contains('+title+')');
|
||||||
|
NEWSBLUR.log(['SS 1:', {'stories': $stories}, $stories.slice(-1), $stories.length]);
|
||||||
|
|
||||||
|
if ($stories.length) {
|
||||||
|
// Reduce stories down to children only
|
||||||
|
$stories.each(function() {
|
||||||
|
var $parent = $(this);
|
||||||
|
|
||||||
|
if ($stories.not($parent.parents()).length) {
|
||||||
|
NEWSBLUR.log(['P/C:', $stories, $parent, $stories.not($parent.parents())]);
|
||||||
|
$reduced_stories.push($parent);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
$stories = $reduced_stories;
|
||||||
|
NEWSBLUR.log(['SS 2:', {'stories': $stories}, $stories.slice(-1), $stories.length]);
|
||||||
|
|
||||||
if (!$stories.length) {
|
if (!$stories.length) {
|
||||||
// Try slicing words off the title, from the end.
|
// Try slicing words off the title, from the end.
|
||||||
|
@ -506,7 +520,7 @@
|
||||||
if (title_words.length > 2) {
|
if (title_words.length > 2) {
|
||||||
var shortened_title = title_words.slice(0,-1).join(' ');
|
var shortened_title = title_words.slice(0,-1).join(' ');
|
||||||
$iframe.contents().find(':contains('+shortened_title+')').each(function(){
|
$iframe.contents().find(':contains('+shortened_title+')').each(function(){
|
||||||
$stories.push(this);
|
$stories.push($(this));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -517,7 +531,7 @@
|
||||||
if (title_words.length > 2) {
|
if (title_words.length > 2) {
|
||||||
var shortened_title = title_words.slice(1).join(' ');
|
var shortened_title = title_words.slice(1).join(' ');
|
||||||
$iframe.contents().find(':contains('+shortened_title+')').each(function(){
|
$iframe.contents().find(':contains('+shortened_title+')').each(function(){
|
||||||
$stories.push(this);
|
$stories.push($(this));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -528,7 +542,7 @@
|
||||||
if (content_words.length > 2) {
|
if (content_words.length > 2) {
|
||||||
var shortened_content = content_words.slice(0, 6).join(' ');
|
var shortened_content = content_words.slice(0, 6).join(' ');
|
||||||
$iframe.contents().find(':contains('+shortened_content+')').each(function(){
|
$iframe.contents().find(':contains('+shortened_content+')').each(function(){
|
||||||
$stories.push(this);
|
$stories.push($(this));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue