File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -87,7 +87,9 @@ export function initBackground() {
8787 // Remove DOM-dependent setFaviconCode since it's not needed in service worker
8888
8989 const fetchOpenReviewNoteJSON = async ( url ) => {
90- const id = url . match ( / i d = ( [ \w - ] + ) / ) [ 1 ] ;
90+ const match = url . match ( / i d = ( [ \w - ] + ) / ) ;
91+ if ( ! match ) return ;
92+ const id = match [ 1 ] ;
9193 const api = `https://api.openreview.net/notes?id=${ id } ` ;
9294 let response = await fetch ( api ) ;
9395 let json = await response . json ( ) ;
@@ -101,7 +103,9 @@ export function initBackground() {
101103 } ;
102104
103105 const fetchOpenReviewForumJSON = async ( url ) => {
104- const id = url . match ( / i d = ( [ \w - ] + ) / ) [ 1 ] ;
106+ const match = url . match ( / i d = ( [ \w - ] + ) / ) ;
107+ if ( ! match ) return ;
108+ const id = match [ 1 ] ;
105109 const api = `https://api.openreview.net/notes?forum=${ id } ` ;
106110 let response = await fetch ( api ) ;
107111 let json = await response . json ( ) ;
Original file line number Diff line number Diff line change @@ -136,7 +136,6 @@ $.extend($.easing, {
136136 } ,
137137} ) ;
138138
139- var PDF_TITLE_ITERS = 0 ;
140139
141140/**
142141 * Centralizes HTML svg codes
@@ -450,12 +449,13 @@ const contentScriptMain = async ({
450449 const paper = state . papers [ id ] ;
451450 const maxWait = 60 * 1000 ;
452451 const maxIters = 20 ;
453- while ( PDF_TITLE_ITERS < maxIters ) {
454- const waitTime = Math . min ( maxWait , 250 * 2 ** PDF_TITLE_ITERS ) ;
452+ let pdfTitleIters = 0 ;
453+ while ( pdfTitleIters < maxIters ) {
454+ const waitTime = Math . min ( maxWait , 250 * 2 ** pdfTitleIters ) ;
455455 await sleep ( waitTime ) ;
456456 document . title = "" ;
457457 document . title = paper . title ;
458- PDF_TITLE_ITERS ++ ;
458+ pdfTitleIters ++ ;
459459 }
460460 } ;
461461 makeTitle ( id ) ;
@@ -660,6 +660,7 @@ const huggingfacePapers = (paper, url) => {
660660 const abstractH2 = queryAll ( "h2" ) . find ( ( h ) => h . innerText . trim ( ) === "Abstract" ) ;
661661 if ( ! abstractH2 ) {
662662 log ( "Missing 'Abstract' h2 title on HuggingFace paper page." ) ;
663+ return ;
663664 }
664665 const authorDiv = abstractH2 . parentElement . previousElementSibling ;
665666 log ( "Adding venue to HuggingFace paper page." ) ;
Original file line number Diff line number Diff line change @@ -919,7 +919,7 @@ const setupSync = async () => {
919919
920920 if ( ! ok ) {
921921 if ( error ) {
922- setHTML ( "pat-feedback" , "Invalid PAT" + "<br/><br/>" + error ) ;
922+ setHTML ( "pat-feedback" , "Invalid PAT" + "<br/><br/>" + escapeHtml ( String ( error ) ) ) ;
923923 }
924924 hideId ( "pat-loader" ) ;
925925 await toggleSync ( { hideAll : true } ) ;
@@ -944,7 +944,7 @@ const setupSync = async () => {
944944 const { ok, payload, error } = await getGist ( { pat } ) ;
945945 if ( ! ok ) {
946946 logError ( error ) ;
947- setHTML ( "pat-feedback" , error . response . data . message ) ;
947+ setHTML ( "pat-feedback" , escapeHtml ( String ( error . response . data . message ) ) ) ;
948948 } else {
949949 const { file, pat, gistId } = payload ;
950950 log ( "Gist ID" , gistId ) ;
Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ export const getPaperInfoTable = (paper) => {
2121 if ( paper . venue )
2222 tableData . push ( [
2323 "Publication" ,
24- `<strong>${ paper . venue } ${ paper . year } </strong>` ,
24+ `<strong>${ escapeHtml ( paper . venue ) } ${ escapeHtml ( String ( paper . year ) ) } </strong>` ,
2525 ] ) ;
2626 return /*html*/ `
2727 <table class="paper-info-table">
Original file line number Diff line number Diff line change @@ -1928,14 +1928,10 @@ export const autoTagPaper = async (paper) => {
19281928 let authorMatch = true ;
19291929 try {
19301930 if ( at . title ) {
1931- titleMatch = paper . title
1932- . toLowerCase ( )
1933- . includes ( at . title . toLowerCase ( ) ) ;
1931+ titleMatch = new RegExp ( at . title , "i" ) . test ( paper . title ) ;
19341932 }
19351933 if ( at . author ) {
1936- authorMatch = paper . author
1937- . toLowerCase ( )
1938- . includes ( at . author . toLowerCase ( ) ) ;
1934+ authorMatch = new RegExp ( at . author , "i" ) . test ( paper . author ) ;
19391935 }
19401936 } catch ( e ) {
19411937 continue ;
You can’t perform that action at this time.
0 commit comments