Skip to content

Open external links in new windows. Also check every few seconds for … #10

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion Providers/FreeHelpServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,29 @@ public function boot() {
* Remove the "target=_blank" attribute for all links.
* @see https://github.com/freescout-helpdesk/freescout/issues/2914
*/
$('[target="_blank"]').attr("target", null );
/* $('[target="_blank"]').attr("target", null ); // i like external links to open in new window */

function updateExternalLinks() {
document.querySelectorAll('a[href]').forEach(function(link) {
let href = link.getAttribute('href');

// Ignore links that are internal, anchor (`#`), or JavaScript actions
if (href.startsWith('#') || href.startsWith('javascript:') || href.includes(location.hostname)) {
return;
}

// Set target="_blank" and security attributes
link.setAttribute("target", "_blank");
link.setAttribute("rel", "noopener noreferrer");
});
}

// Run immediately on page load
updateExternalLinks();

// Run every 3 seconds in case new links are dynamically added and to account for sidebar webhooks
setInterval(updateExternalLinks, 3000);


// Let's use better terminology.
$('a[href*=whitelist]').text(function ( index, text ) {
Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

FreeHelp makes FreeScout look and feel more like Help Scout, adding many small quality-of-life improvements.

- Don't open anything in new tabs/windows! [#2914](https://github.com/freescout-helpdesk/freescout/issues/2914)
- Open external links in new windows
- Shift-click checkboxes to select a range of conversations at once [#1312](https://github.com/freescout-helpdesk/freescout/issues/1312)
- Convert Dropdown-type Custom Fields to Select2 inputs
- Type `Escape` to close dropdowns, cancel editing conversation titles, and cancel editing a note
Expand Down Expand Up @@ -38,6 +38,10 @@ FreeHelp makes FreeScout look and feel more like Help Scout, adding many small q

## Changelog

### 1.0.4 - TBD

- Open external links in new windows. Also check every few seconds for new links that may have been loaded such as from sidebar addons.

### 1.0.3 on August 4, 2023

- Update fonts to make the editor text feel more like Help Scout's
Expand Down