Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Bring 'Open Links to subreddits in a New Tab' & 'Open Posts in New Tab' to New New UI! #105

Open
sliceanddice9 opened this issue Dec 15, 2024 · 3 comments

Comments

@sliceanddice9
Copy link

sliceanddice9 commented Dec 15, 2024

The 'Open Links to subreddits in a New Tab' & 'Open Posts in New Tab' are feature requests I made a while back for the Old New UI

Could we please have: 'Open Links to subreddits in a New Tab' & 'Open Posts in New Tab' back for the New New UI as well?

I know 'Open Posts in New Tab' can be enabled officially within Reddit Settings itself, but I still think your implementation of 'Open Posts in New Tab' is important to keep inside the 'Reddit Enhancer' add-on, because with your version of 'Open Posts in New Tab' I can choose to keep the feature enabled using the Reddit website with the 'Reddit Enhancer' add-on from one web browser, while keeping the feature disabled in the Reddit website with the 'Reddit Enhancer' add-on from another web browser. This offers great flexibility.

For example: I like to keep 'Open Posts in New Tab' enabled using Firefox for the Reddit website, but disabled using Microsoft Edge for the Reddit PWA.

With the default built-in feature of 'Open Links To Posts In New Tab' in reddit.com/settings/feed - the setting, once enabled, is obviously tied to your actual Reddit account profile, meaning it is universally triggered globally on all web browsers you use the Reddit website/PWA. This is quite annoying IMO.

@sliceanddice9
Copy link
Author

sliceanddice9 commented Dec 29, 2024

I have found a workaround by running a custom AI generated script via Tampermonky which enables 'Open Links to subreddits in a New Tab' & 'Open Posts in New Tab' functionality on the New New UI.

@joelacus
Copy link
Owner

I'll reopen this issue as I want to bring this functionality to the New New UI as well.

Would you mind sharing the Tampermonkey code? It might speed up me adding this feature into the extension, thanks.
If not, no worries.

@joelacus joelacus reopened this Jan 21, 2025
@sliceanddice9
Copy link
Author

Yes absolutely. Here you are:

// ==UserScript==

// @name Open Reddit Buttons/Links in New Tabs EVERYWHERE
// @namespace http://tampermonkey.net/
// @Version 0.4
// @description Open subreddit and post links in new tabs like Firefox's built-in function
// @author You
// @match https://sh.reddit.com/*
// @match https://www.reddit.com/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
// Function to open links in new tabs
function openLinksInNewTabs(event) {
event.preventDefault();
const url = this.href;
window.open(url, '_blank');
}
// Function to add event listeners to links
function addEventListeners() {
const links = document.querySelectorAll('a[href*="/r/"], a[href*="/comments/"]');
links.forEach(link => {
link.removeEventListener('click', openLinksInNewTabs); // Remove existing listener to avoid duplicates
link.addEventListener('click', openLinksInNewTabs);
});
}
// Initial call to add event listeners
addEventListeners();
// Observe changes to the document to handle dynamically loaded content
const observer = new MutationObserver(addEventListeners);
observer.observe(document.body, { childList: true, subtree: true });
})();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants