Skip to content

Commit 4d93f45

Browse files
committed
Add a[rel] and a[class] methods of finding the anchor
1 parent d8bb937 commit 4d93f45

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

content-script.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,24 @@ Repaginator.prototype = {
244244
}
245245
}
246246

247+
// Fourth: See if there is rel=next or rel=prev
248+
let rel = (el.getAttribute("rel") || "").trim();
249+
if (rel && (rel.contains("next") || rel.contains("prev"))) {
250+
this.query += "//a[@rel='" + escapeXStr(rel) + "']";
251+
// no point in checking for numbers
252+
this.attemptToIncrement = false;
253+
log(LOG_DEBUG, "using a[@rel]");
254+
return;
255+
}
256+
257+
// Fifth: See if there is a class we may use
258+
if (el.className) {
259+
this.query += "//a[@class='" + escapeXStr(el.className) + "']";
260+
this.numberToken = /(\[@class='.*?)(\d+)(.*?'\])/;
261+
log(LOG_DEBUG, "using a[@class]");
262+
return;
263+
}
264+
247265
throw new Error("No anchor expression found!");
248266
}).call(this);
249267
}).call(this);

0 commit comments

Comments
 (0)