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

Function addLocation

source/features/linkify-user-location.tsx:9–27  ·  view source on GitHub ↗
({nextElementSibling, nextSibling}: SVGElement)

Source from the content-addressed store, hash-verified

7import observe from '../helpers/selector-observer.js';
8
9function addLocation({nextElementSibling, nextSibling}: SVGElement): Element {
10 // `nextSibling` alone might point to an empty TextNode before an element, if there’s an element
11 const userLocation = nextElementSibling ?? nextSibling as Element;
12
13 const locationName = userLocation.textContent.trim();
14 const mapLink = `https://www.openstreetmap.org/search?query=${encodeURIComponent(locationName)}`;
15
16 userLocation.before(' '); // Keeps the link’s underline from extending out to the icon
17 const link = <a className="Link--primary" href={mapLink} />;
18
19 if (closestElementOptional('.Popover', userLocation.parentElement!)) {
20 // Match the style of other links in the hovercard
21 link.classList.add('text-underline');
22 }
23
24 wrap(userLocation, link);
25
26 return link;
27}
28
29function initOnce(): void {
30 observe([

Callers

nothing calls this directly

Calls 1

wrapFunction · 0.85

Tested by

no test coverage detected