Skip to content

Commit 241348c

Browse files
committed
Merge pull request #2182.
Fix style problems and the "open results in new browser windows" setting on Google Search.
2 parents 47548ae + 8a191bd commit 241348c

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/js/firstparties/google-search.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@ let trap_link = "a[onmousedown^='return rwt(this,'], a[ping]";
55

66
// Remove excessive attributes and event listeners from link a
77
function cleanLink(a) {
8-
// remove all attributes from a link except for href
8+
// remove all attributes from a link except for href,
9+
// target (to support "Open each selected result in a new browser window"),
10+
// class and ARIA attributes
911
for (let i = a.attributes.length - 1; i >= 0; --i) {
1012
const attr = a.attributes[i];
11-
if (attr.name !== 'href') {
13+
if (attr.name !== 'href' && attr.name !== 'target' &&
14+
attr.name !== 'class' && !attr.name.startsWith('aria-')) {
1215
a.removeAttribute(attr.name);
1316
}
1417
}

src/js/firstparties/google-static.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,13 @@ function unwrapLink(a) {
77
return;
88
}
99

10-
// remove all attributes from a link except for target
10+
// remove all attributes from a link except for target, class, and aria-*
11+
// attributes. This should prevent the script from breaking styles and
12+
// features for people with disabilities.
1113
for (let i = a.attributes.length - 1; i >= 0; --i) {
1214
const attr = a.attributes[i];
13-
if (attr.name !== "target") {
15+
if (attr.name !== 'target' && attr.name !== 'class' &&
16+
!attr.name.startsWith('aria-')) {
1417
a.removeAttribute(attr.name);
1518
}
1619
}

0 commit comments

Comments
 (0)