HNPES allows you to search for the current URL on Hacker News and view the top results directly from the extension's popup.
Since i became a user of hackernews ( like ten or eleven years ago ) i used a bookmarklet to see if the URL i am browsing has already been submitted to hackernews:
(function() {
var request = new XMLHttpRequest();
request.open("GET", "https://hn.algolia.com/api/v1/search?query=" + encodeURIComponent(location.href), true);
request.onreadystatechange = function() {
if(request.readyState == 4 && request.status == 200) {
var response = JSON.parse(request.responseText);
if(response.nbHits > 0) {
location.href = "https://news.ycombinator.com/item?id=" + response.hits[0].objectID;
} else {
alert("this url has not been submitted yet");
}
}
};
request.send();
})();
Due to some CSP and CORS nonsense a lot of sites have been breaking this script, looking for solutions i found that the only way to bypass that is using a chrome extension ( A Browser extension, but i am a chrome user ), so that's what i did!
- Search for the current URL on Hacker News.
- Display the top results from Hacker News in the extension's popup.
- Configurable number of results to display.
- Configurable number of pagination pages to follow.
- Show the number of comments in each post
- Show the date of creation of each post
- A debug feature enabled by the config
- If the link was never posted on hackernews, a option to post there will appear
- And in any case, you can also share it on twitter and reddit
- Clone or download this repository to your local machine.
- Open Google Chrome and navigate to
chrome://extensions
. - Enable "Developer mode" using the toggle switch in the top right corner.
- Click on the "Load unpacked" button.
- Select the folder containing the extension files.
- The extension should now be installed and visible in the list of installed extensions.
- Navigate to a webpage you want to search on Hacker News.
- Click on the extension icon in the Chrome toolbar to open the popup.
- The extension will automatically fetch the top results from Hacker News related to the current URL.
- The results will be displayed in the popup.
- Click on a result to open it in a new tab.
The extension allows you to configure the following options:
- Number of results to show: Set the number of results to display in the popup. Default is 3.
- Number of pagination pages to follow: Set the number of pagination pages to fetch from Hacker News. Default is 1.
- Debug function: Check it for the extension to post the response from algolia to http://localhost:8080/debug
To configure these options:
- Click on the extension icon in the Chrome toolbar to open the popup.
- Click on the gear icon in the top right corner to open the options page.
- Adjust the desired settings.
- Click the "Save" button to save the settings.
Contributions are welcome! If you encounter any issues or have suggestions for improvements, please open an issue or submit a pull request.
This extension uses the Algolia Search API to search for URLs on Hacker News.
This project is not affiliated with or endorsed by Hacker News or Algolia.