This repository has been archived by the owner on Aug 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
disable-topsite-sponsors.diff
162 lines (156 loc) · 5.38 KB
/
disable-topsite-sponsors.diff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
--- a/browser/components/newtab/lib/AboutPreferences.jsm.orig 2021-04-20 19:45:48.762626291 +0000
+++ b/browser/components/newtab/lib/AboutPreferences.jsm 2021-04-20 19:46:41.841783544 +0000
@@ -48,18 +48,7 @@
? "home-prefs-shortcuts-description"
: "home-prefs-topsites-description",
get nestedPrefs() {
- return Services.prefs.getBoolPref("browser.topsites.useRemoteSetting")
- ? [
- {
- name: "showSponsoredTopSites",
- titleString:
- newNewtabExperienceEnabled || customizationMenuEnabled
- ? "home-prefs-shortcuts-by-option-sponsored"
- : "home-prefs-topsites-by-option-sponsored",
- eventSource: "SPONSORED_TOP_SITES",
- },
- ]
- : [];
+ return [];
},
},
icon: "topsites",
--- a/browser/components/newtab/lib/TopSitesFeed.jsm.orig 2021-09-03 10:50:59.318426528 +0000
+++ b/browser/components/newtab/lib/TopSitesFeed.jsm 2021-09-03 10:56:08.302926467 +0000
@@ -321,32 +321,6 @@
// Read defaults from contile.
const contileEnabled = Services.prefs.getBoolPref(CONTILE_ENABLED_PREF);
let hasContileTiles = false;
- if (contileEnabled) {
- let sponsoredPosition = 1;
- for (let site of this._contile.sites) {
- let hostname = shortURL(site);
- let link = {
- isDefault: true,
- url: site.url,
- hostname,
- sendAttributionRequest: false,
- label: site.name,
- show_sponsored_label: hostname !== "yandex",
- sponsored_position: sponsoredPosition++,
- sponsored_click_url: site.click_url,
- sponsored_impression_url: site.impression_url,
- sponsored_tile_id: site.id,
- };
- if (site.image_url && site.image_size >= MIN_FAVICON_SIZE) {
- // Only use the image from Contile if it's hi-res, otherwise, fallback
- // to the built-in favicons.
- link.favicon = site.image_url;
- link.faviconSize = site.image_size;
- }
- DEFAULT_TOP_SITES.push(link);
- }
- hasContileTiles = sponsoredPosition > 1;
- }
// Read defaults from remote settings.
this._useRemoteSetting = true;
@@ -356,60 +330,6 @@
Services.prefs.getStringPref(TOP_SITES_BLOCKED_SPONSORS_PREF, "[]")
);
- for (let siteData of remoteSettingData) {
- let hostname = shortURL(siteData);
- // Drop default sites when Contile already provided a sponsored one with
- // the same host name.
- if (
- contileEnabled &&
- DEFAULT_TOP_SITES.findIndex(site => site.hostname === hostname) > -1
- ) {
- continue;
- }
- // Also drop those sponsored sites that were blocked by the user before
- // with the same hostname.
- if (
- siteData.sponsored_position &&
- sponsoredBlocklist.includes(hostname)
- ) {
- continue;
- }
- let link = {
- isDefault: true,
- url: siteData.url,
- hostname,
- sendAttributionRequest: !!siteData.send_attribution_request,
- };
- if (siteData.url_urlbar_override) {
- link.url_urlbar = siteData.url_urlbar_override;
- }
- if (siteData.title) {
- link.label = siteData.title;
- }
- if (siteData.search_shortcut) {
- link = await this.topSiteToSearchTopSite(link);
- } else if (siteData.sponsored_position) {
- if (contileEnabled && hasContileTiles) {
- continue;
- }
- const {
- sponsored_position,
- sponsored_tile_id,
- sponsored_impression_url,
- sponsored_click_url,
- } = siteData;
- link = {
- sponsored_position,
- sponsored_tile_id,
- sponsored_impression_url,
- sponsored_click_url,
- show_sponsored_label: link.hostname !== "yandex",
- ...link,
- };
- }
- DEFAULT_TOP_SITES.push(link);
- }
-
this.refresh({ broadcast: true, isStartup });
}
@@ -712,22 +632,6 @@
) {
continue;
}
- if (link.sponsored_position) {
- if (!prefValues[SHOW_SPONSORED_PREF]) {
- continue;
- }
- sponsored[link.sponsored_position - 1] = link;
-
- // Unpin search shortcut if present for the sponsored link to be shown
- // instead.
- this._unpinSearchShortcut(link.hostname);
- } else {
- notBlockedDefaultSites.push(
- searchShortcutsExperiment
- ? await this.topSiteToSearchTopSite(link)
- : link
- );
- }
}
// Get pinned links augmented with desired properties
@@ -811,20 +715,6 @@
// Insert the original pinned sites into the deduped frecent and defaults.
let withPinned = insertPinned(checkedAdult, pinned);
- // Insert sponsored sites at their desired position.
- dedupedSponsored.forEach(link => {
- if (!link) {
- return;
- }
- let index = link.sponsored_position - 1;
- if (index > withPinned.length) {
- withPinned[index] = link;
- } else {
- withPinned.splice(index, 0, link);
- }
- });
- // Remove excess items after we inserted sponsored ones.
- withPinned = withPinned.slice(0, numItems);
// Now, get a tippy top icon, a rich icon, or screenshot for every item
for (const link of withPinned) {