question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`stop-redirecting-in-notification-bar` automatically when possible

See original GitHub issue

As discussed in https://github.com/sindresorhus/refined-github/issues/2952 and https://github.com/sindresorhus/refined-github/pull/3036

I think stop-redirecting-in-notification-bar can be done automatically if the user opened the notification in a new tab.

For example:

  1. disable automatic redirect for all buttons, always
  2. try calling history.back() (unless alt is pressed)

If you opened the notification in a new tab, history.back() won’t have any effect.

IMHO this makes sense since in that case, the notifications list is still open in its own tab.

PR welcome if you test that this works as expected in both browsers.

cc @FloEdelmann @karlhorky @tonglil

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:14 (14 by maintainers)

github_iconTop GitHub Comments

2reactions
karlhorkycommented, Jun 5, 2020

Got it, so something like the following?

function handleClick(event: delegate.Event<MouseEvent, HTMLButtonElement>): void {
    // Disable the redirect to the Notifications inbox if either:
    // 1. The alt key was held down during click
    // 2. The notification has been opened in a new tab
    const redirectDisabled = event.alt || sessionStorage.rghIsNewTab;
    event.delegateTarget.form!.toggleAttribute('data-redirect-to-inbox-on-submit', !redirectDisabled);
    delete sessionStorage.rghIsNewTab;
}

async function init(): Promise<void> {
    // If the history length is `1` on init, the
    // notification has been opened in a new tab
    sessionStorage.rghIsNewTab = history.length === 1;
	delegate(document, '.notification-shelf .js-notification-action button', 'click', handleClick);
}
2reactions
karlhorkycommented, Jun 4, 2020

Another option would be to leave all of the existing code as it is, and only add the condition of history.length === 1.

So something like:

function handleClick(event: delegate.Event<MouseEvent, HTMLButtonElement>): void {
    // Disable the redirect to the Notifications inbox if either:
    // 1. The alt key was held down during click
    // 2. The history length is `1` (a new tab)
    const redirectDisabled = event.alt || history.length === 1;
    event.delegateTarget.form!.toggleAttribute('data-redirect-to-inbox-on-submit', !redirectDisabled);
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Block or allow pop-ups in Chrome - Computer - Google Support
Manage pop-ups & redirects for a specific site · On your computer, open Chrome Chrome . · Go to a page where pop-ups...
Read more >
Enable/disable automatic redirect. | Firefox Support Forum
So I was having some trouble a few days ago with a website that automatically re-directed as soon as I landed on it...
Read more >
Turn off notifications in Windows during certain times
Turn off notifications in Windows during certain times · Select Start > Settings > System > Notifications . · To turn on Do...
Read more >
How to stop an automatic redirect from “http://” to “https://” in ...
As the other answer said, the only way to stop this once it starts is to clear the browser cache (or wait for...
Read more >
How To Fix Google Chrome Redirects - YouTube
How To Fix Google Chrome Redirects - Remove Chrome Redirect Virus.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found