@@ -689,7 +689,7 @@ var debug = {
689689 } ;
690690 var text = this . format ;
691691 for ( var key in params ) {
692- text = text . replace ( '$' + key + '$' , params [ key ] ) ;
692+ text = text . replace ( '$' + key + '$' , params [ key ] || '?' ) ;
693693 }
694694 console . log ( text ) ;
695695 return this ;
@@ -1037,8 +1037,8 @@ function getWatchlist(e) {
10371037 .then(convertToJSON) */
10381038 return fetch ( 'https://www.furaffinity.net/watchlist/by/' + username + ( p > 1 ?'/' + p + '/' :'' ) )
10391039 . then ( function ( x ) { return x . text ( ) } )
1040- . then ( function ( x ) { return x . html ( ) } )
1041- . then ( function ( $dom ) { return $A ( $dom . querySelectorAll ( '#userpage-budlist>tbody>tr>td>a,div.watch-row>a' ) ) . pluck ( 'textContent' ) } )
1040+ . then ( parseHTML )
1041+ . then ( function ( $dom ) { return $A ( $dom . querySelectorAll ( 'div.watch-list-items>a, #userpage-budlist>tbody>tr>td>a,div.watch-row>a' ) ) . pluck ( 'textContent' ) } )
10421042 . then ( function ( users ) {
10431043 $btn . textContent = 'Fetching (page ' + p + ')...' ;
10441044 debug . log ( 'Got page ' + p + ' of ' + username + '\'s watchlist, ' + users . length + ' items' ) ;
@@ -1646,6 +1646,7 @@ Target.addMethods({
16461646 } ,
16471647 addNode : function ( node , type , useSelf ) {
16481648 if ( this . hasNode ( node ) ) return ;
1649+ if ( ! node ) throw 'cannot add empty node of type ' + type + ' to ' + this . id ;
16491650 if ( Object . isElement ( node ) ) {
16501651 node = new TypeNode ( node , type , this , useSelf ) ;
16511652 }
@@ -1847,7 +1848,7 @@ function scrape() {
18471848 return id in submissions ? submissions [ id ] : ( submissions [ id ] = new Submission ( id ) ) ;
18481849 }
18491850
1850- function processLinks ( $link ) {
1851+ function processLink ( $link ) {
18511852 if ( / [ ? # @ ] / . test ( $link . href ) || ( $link . innerHTML == 'News and Updates' ) ) return ;
18521853 try {
18531854 var name = resolveUsername ( $link ) ;
@@ -1873,23 +1874,23 @@ function scrape() {
18731874 console . error ( 'Invalid link:' , $link , e ) ;
18741875 }
18751876 }
1876- function processThings ( $thing ) {
1877+ function processThing ( $thing ) {
18771878 try {
18781879 var name = Utils . sanitizeUsername ( $thing . textContent ) ;
18791880 users [ name ] . addNode ( $thing , 'username' ) ;
18801881 } catch ( e ) {
18811882 console . error ( 'Invalid username container:' , $thing , e ) ;
18821883 }
18831884 }
1884- function processAvatars ( $avatar ) {
1885+ function processAvatar ( $avatar ) {
18851886 try {
18861887 var name = resolveUsername ( $avatar . parentElement ) ;
18871888 users [ name ] . addNode ( $avatar , 'avatar' ) ;
18881889 } catch ( e ) {
18891890 console . error ( 'Invalid avatar:' , $avatar , e ) ;
18901891 }
18911892 }
1892- function processComments ( $comment ) {
1893+ function processComment ( $comment ) {
18931894 try {
18941895 var name = resolveUsername ( $comment . querySelector ( 'a' ) ) ;
18951896 // avoid using a large swath of the dom as the hover parent
@@ -1898,7 +1899,7 @@ function scrape() {
18981899 console . error ( 'Invalid comment:' , $comment , e ) ;
18991900 }
19001901 }
1901- function processGalleryFigures ( $figure ) {
1902+ function processGalleryFigure ( $figure ) {
19021903 try {
19031904 var $thumbnail = $figure . querySelector ( 'img' ) ; // figure>b>u[>s]>a>img
19041905 var $caption = $figure . querySelector ( 'figcaption' ) ; // figure>figcaption
@@ -1916,7 +1917,7 @@ function scrape() {
19161917 console . error ( 'Invalid figure:' , $figure , e ) ;
19171918 }
19181919 }
1919- function processProfileFigures ( $figure ) {
1920+ function processProfileFigure ( $figure ) {
19201921 var $a = $figure . querySelector ( SUBMISSION_LINK ) ;
19211922 var id = resolveSubmission ( $a ) ;
19221923 var submission = submissions [ id ] ;
@@ -1931,7 +1932,7 @@ function scrape() {
19311932 //console.log($figure,'is a user submission');
19321933 }
19331934 }
1934- function processSubmissionFigures ( $figure ) {
1935+ function processSubmissionFigure ( $figure ) {
19351936 var $thumbnail = $figure . querySelector ( 'img' ) ;
19361937 var $a = $figure . querySelector ( SUBMISSION_LINK ) ;
19371938 var id = resolveSubmission ( $a ) ;
@@ -1943,16 +1944,16 @@ function scrape() {
19431944 }
19441945
19451946 // build user and submission tables using the links
1946- body . select ( 'a' ) . forEach ( processLinks ) ;
1947+ body . select ( 'a' ) . forEach ( processLink ) ;
19471948
19481949 // parse things that aren't links but contain one's username
1949- body . select ( 'li>div.info>span' , 'b.replyto-name' ) . forEach ( processThings ) ;
1950+ body . select ( 'li>div.info>span' , 'b.replyto-name' ) . forEach ( processThing ) ;
19501951
19511952 // parse avatar images (all usernames should exist in the table); avatars are always wrapped in links
1952- body . select ( 'img.avatar' , 'img.comment_useravatar' , 'a.iconusername>img' ) . forEach ( processAvatars ) ;
1953+ body . select ( 'img.avatar' , 'img.comment_useravatar' , 'a.iconusername>img' , 'div.submission-id-avatar>a>img' ) . forEach ( processAvatar ) ;
19531954
19541955 // parse comments and shouts (all usernames should exist in the table)
1955- body . select ( 'comment-container' , 'table[id*="shout"]' , 'table.container-comment' ) . forEach ( processComments ) ;
1956+ body . select ( 'comment-container' , 'table[id*="shout"]' , 'table.container-comment' ) . forEach ( processComment ) ;
19561957
19571958 // parse content figures
19581959 var $contentItems = body . select ( 'figure' , 'b[id*="sid_"]' , 'div.preview-gallery-container' ) ;
@@ -1967,7 +1968,7 @@ function scrape() {
19671968 case 'search' :
19681969 case 'msg' :
19691970 // submissions with titles/by creators
1970- $contentItems . forEach ( processGalleryFigures ) ;
1971+ $contentItems . forEach ( processGalleryFigure ) ;
19711972 break ;
19721973 case 'user' :
19731974 profileName = URL [ 3 ] ;
@@ -1978,7 +1979,7 @@ function scrape() {
19781979 var $firstFaveSubmission = body . select ( 'center.userpage-first-favorite>b' ) [ 0 ] ;
19791980
19801981 // profile submissions and favorites
1981- $contentItems . forEach ( processProfileFigures ) ;
1982+ $contentItems . forEach ( processProfileFigure ) ;
19821983 if ( $featuredSubmission ) {
19831984 var $a = $featuredSubmission . querySelector ( 'a' ) || $featuredSubmission . parentElement ;
19841985 var id = resolveSubmission ( $a ) ;
@@ -2022,19 +2023,22 @@ function scrape() {
20222023 case 'full' :
20232024 try {
20242025 var $submissionImg = $ ( 'submissionImg' ) ;
2025- var $submissionTags = $ ( ' keywords') ;
2026+ var $submissionTags = body . select ( 'section.tags-row' , '# keywords') [ 0 ] ;
20262027 var id = URL [ 3 ] ;
20272028 var submission = getSubmission ( id ) ;
20282029 submission . addNode ( $submissionImg , 'thumbnail' , true ) ;
20292030 submission . addNode ( $submissionTags , 'link' ) ;
2030-
2031- var $submissionOwner = body . select ( 'div.submission-id-container>' + USER_LINK , 'div.classic-submission-title>' + USER_LINK , 'div.submission-title>span>a' ) [ 0 ] ;
2031+
2032+ var $submissionIdContainer = body . select ( 'div.submission-id-container' , 'div.classic-submission-title' , 'div.submission-title' ) [ 0 ] ;
2033+ var $submissionOwner = $submissionIdContainer . select ( USER_LINK ) [ 0 ] ;
2034+
20322035 profileName = resolveUsername ( $submissionOwner ) ;
20332036 profileUser = users [ profileName ] ;
2037+
20342038 profileUser . addSubmission ( submission ) ;
20352039
20362040 // submission previews
2037- $contentItems . forEach ( processSubmissionFigures ) ;
2041+ $contentItems . forEach ( processSubmissionFigure ) ;
20382042 } catch ( e ) {
20392043 console . error ( e ) ;
20402044 }
0 commit comments