Skip to content

Commit

Permalink
AG-37650 Add the '/NewsViewAmp/' pattern for AMP pages #105.
Browse files Browse the repository at this point in the history
Squashed commit of the following:

commit 2a2a5ff
Author: jellizaveta <[email protected]>
Date:   Fri Nov 15 17:44:45 2024 +0300

    update changelog

commit b98dd09
Author: jellizaveta <[email protected]>
Date:   Fri Nov 15 17:44:05 2024 +0300

    add selector for google news links

commit 2f4b830
Author: Slava Leleka <[email protected]>
Date:   Wed Nov 13 14:01:42 2024 +0300

    CHANGELOG.md edited online with Bitbucket

commit 4847e3d
Author: jellizaveta <[email protected]>
Date:   Wed Nov 13 13:36:57 2024 +0300

    update changelog

commit b4bf027
Author: jellizaveta <[email protected]>
Date:   Wed Nov 13 13:35:10 2024 +0300

    AG-37650 Add the '/NewsViewAmp/' pattern for AMP pages
  • Loading branch information
jellizaveta committed Nov 15, 2024
1 parent 9309c6f commit 482ee08
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ The format is based on [Keep a Changelog], and this project adheres to [Semantic
[Keep a Changelog]: https://keepachangelog.com/en/1.0.0/
[Semantic Versioning]: https://semver.org/spec/v2.0.0.html

## [1.0.57] - 2024-11-15

### Added

- `/NewsViewAmp/` pattern for AMP pages [#105].

[1.0.57]: https://github.com/AdguardTeam/DisableAMP/compare/v1.0.56...v1.0.57
[#105]: https://github.com/AdguardTeam/DisableAMP/issues/105

## [1.0.56] - 2024-11-13

### Fixed
Expand Down
1 change: 1 addition & 0 deletions meta.template.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
// @include https://*/*?amp=1*
// @include https://*/amp-*/*
// @include https://*/ampNews/*
// @include https://*/NewsViewAmp/*
// @include https://*/*/?noamp=*
// @exclude
// @run-at document-end
Expand Down
11 changes: 8 additions & 3 deletions src/google-amp.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ const AMP_ATTRIBUTES_TO_REMOVE = [
'jsaction',
];
const AMP_IMAGE_LINK_SELECTOR = 'a[data-ved]:has(> div[class] > span + svg)';
const AMP_LINK_SELECTOR = 'a[data-amp]';
const AMP_SEARCH_LINK_SELECTOR = 'a[data-amp]';
const AMP_NEWS_LINK_SELECTOR = 'a[data-amp-vgi]';

/**
* Prevent AMP links from Google News, Search, and Images from opening within Google's iframe
Expand All @@ -34,9 +35,13 @@ export const cleanAmpLink = () => {
siblingAmpLinks.push(siblingAmpLink);
});

const ampLinks = document.querySelectorAll(AMP_LINK_SELECTOR);
const ampSearchLinks = document.querySelectorAll(AMP_SEARCH_LINK_SELECTOR);

const ampNewsLinks = document.querySelectorAll(AMP_NEWS_LINK_SELECTOR);

const allAmpLinks = [
...ampLinks,
...ampSearchLinks,
...ampNewsLinks,
...ampImageLinks,
...siblingAmpLinks,
];
Expand Down

0 comments on commit 482ee08

Please sign in to comment.