MCPcopy Index your code
hub / github.com/refined-github/refined-github / linkify

Function linkify

source/features/last-notification-page-button.tsx:13–26  ·  view source on GitHub ↗
(nextButton: HTMLAnchorElement)

Source from the content-addressed store, hash-verified

11const itemsPerNotificationsPage = 25;
12
13function linkify(nextButton: HTMLAnchorElement): void {
14 const totalNotificationsNode = $('.js-notifications-list-paginator-counts').lastChild!;
15 assertNodeContent(totalNotificationsNode, /^of \d+$/);
16 const totalNotificationsNumber = looseParseInt(totalNotificationsNode);
17 const lastCursor = Math.floor((totalNotificationsNumber - 1) / itemsPerNotificationsPage) * itemsPerNotificationsPage;
18 const nextButtonSearch = new URLSearchParams(nextButton.search);
19 nextButtonSearch.set('after', stringToBase64(`cursor:${lastCursor}`));
20 totalNotificationsNode.replaceWith(
21 ' of ',
22 <a href={'?' + String(nextButtonSearch)}>
23 {totalNotificationsNumber}
24 </a>,
25 );
26}
27
28function init(signal: AbortSignal): void {
29 // When there's no "next page", this element becomes `<button disabled>`

Callers

nothing calls this directly

Calls 3

assertNodeContentFunction · 0.85
looseParseIntFunction · 0.85
setMethod · 0.80

Tested by

no test coverage detected