AdguardTeam / AdguardTeam/Scriptlets

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

オープン
#579 コメント 0 件 リアクション 0 件 担当者 1 名 @maximtop が担当を希望しています GitHub で見る
Priority: P4
主要言語
JavaScript
スター
195
フォーク
33
PR マージ指標
30日以内にマージされた PR はありません

説明

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`.

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。