News for hackers. Stuff that matters.
Re:Show HN: Pinpointer – A Firefox extension to share links ... by dmortin on Wednesday July 18, 2018 @07:41AM (#17557381)
You should post such a generated link here as an example, so people can immediately try it by clicking on it.
Re:Show HN: Pinpointer – A Firefox extension to share links ... by Rumperuu on Wednesday July 18, 2018 @07:59AM (#17557507)
Good point. https://en.wikipedia.org/wiki/Nelson_Mandela#aHRtbCA%2BIGJvZ...

(I wasn't kidding about needing to shorten those links.)

Re:Show HN: Pinpointer – A Firefox extension to share links ... by yorwba on Wednesday July 18, 2018 @08:25AM (#17557686)
Shorter link that still works with your addon: https://en.wikipedia.org/wiki/Nelson_Mandela#cDpudGgtb2YtdHl...

I simply tried to find a suffix of the path that still identifies the element uniquely. Turns out that p:nth-of-type(3) is good enough already. If you want to be a bit more robust to changes on the page, you could also search for the last element with an ID in the path, i.e. #mw-content-text > div.mw-parser-output > p:nth-of-type(3).

Re:Show HN: Pinpointer – A Firefox extension to share links ... by supermdguy on Wednesday July 18, 2018 @10:27AM (#17558694)
Cypress (the testing framework) has a way to get a short, unique selector for any element on a page. It's even in its own npm package: https://www.npmjs.com/package/@cypress/unique-selector
Re:Show HN: Pinpointer – A Firefox extension to share links ... by dmortin on Wednesday July 18, 2018 @08:56AM (#17557921)
It kind of defeats the point that you need the extension to view the generated links.

You may want to add an option to select only from the anchors/ids from the page to generate links which work in any browser.

Though there may already be an extension for this.

Re:Show HN: Pinpointer – A Firefox extension to share links ... by Rumperuu on Wednesday July 18, 2018 @09:25AM (#17558144)
If you mean what I think you mean, you can already send a link that specifies a valid element ID on the page to anybody and have their browser focus on it — that's what fragment identifiers are for. However, if the page designer has neglected to provide a unique ID for each page element (and they probably have), you're out of luck. Ideally, you'd be able to specify any valid CSS selector that only selects one element as a fragment identifier, but that's not the case (and is basically what this extension makes possible).
Re:Show HN: Pinpointer – A Firefox extension to share links ... by idbehold on Wednesday July 18, 2018 @12:39PM (#17559865)
Would an XPath work for this? Seems like that would be easiest considering Firefox already has built-in support for getting the XPath from an element on the page.