AdguardTeam / AdguardTeam/Scriptlets

Improve `disable-newtab-links` - allow to prevent specific link

Ouverte
#579 0 commentaires 0 réactions 1 personne assignée Réclamée par @maximtop Voir sur GitHub
Priority: P4
Langage dominant
JavaScript
Étoiles
195
Forks
33
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

Currently it prevents opening new tabs and windows only if there is `target` attribute in element.
Sometimes `target` attribute can be used in legitimate links, so I think that it would be nice to have an option to prevent only specific links.
Something similar like in `prevent-window-open` with ability to use `!` as negation - https://github.com/AdguardTeam/Scriptlets/blob/master/wiki/about-scriptlets.md#prevent-window-open

Example case:
```js
function simulateModifiedClick(url) {
try {
const link = document.createElement("a");
link.href = url;
link.rel = "noopener";

link.onclick = e => e.stopPropagation();
document.body.appendChild(link);

link.dispatchEvent(new MouseEvent("click", {
bubbles: true,
cancelable: true,
view: window,
ctrlKey: true,
metaKey: true,
button: 0
}));

link.remove();
} catch {
// Do nothing
}
}
simulateModifiedClick('test');
```

So for instance, `#%#//scriptlet('disable-newtab-links', 'test')` should allow to prevent all links with `test`.

Guide de contribution

Aucun guide de contribution indexé pour ce dépôt

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.