@temple-wallet/extension-ads 17.0.0-beta.1 → 18.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ads-actions/crypto-keywords.json +464 -0
- package/dist/ads-actions/helpers.d.ts +3 -0
- package/dist/ads-actions/helpers.js +91 -1
- package/dist/ads-actions/helpers.js.map +1 -1
- package/dist/ads-actions/index.d.ts +2 -1
- package/dist/ads-actions/index.js +27 -23
- package/dist/ads-actions/index.js.map +1 -1
- package/dist/ads-actions/process-providers-ads.js +2 -1
- package/dist/ads-actions/process-providers-ads.js.map +1 -1
- package/dist/ads-actions/process-youtube-home-ads.d.ts +20 -0
- package/dist/ads-actions/process-youtube-home-ads.js +139 -0
- package/dist/ads-actions/process-youtube-home-ads.js.map +1 -0
- package/dist/ads-actions/process-youtube-search-ads.d.ts +3 -0
- package/dist/ads-actions/process-youtube-search-ads.js +115 -0
- package/dist/ads-actions/process-youtube-search-ads.js.map +1 -0
- package/dist/ads-actions/process-youtube-watch-ads.d.ts +3 -0
- package/dist/ads-actions/process-youtube-watch-ads.js +115 -0
- package/dist/ads-actions/process-youtube-watch-ads.js.map +1 -0
- package/dist/ads-configuration.d.ts +8 -3
- package/dist/ads-configuration.js +7 -3
- package/dist/ads-configuration.js.map +1 -1
- package/dist/ads-flows/youtube-home.d.ts +2 -0
- package/dist/ads-flows/youtube-home.js +27 -0
- package/dist/ads-flows/youtube-home.js.map +1 -0
- package/dist/ads-flows/youtube-search.d.ts +2 -0
- package/dist/ads-flows/youtube-search.js +23 -0
- package/dist/ads-flows/youtube-search.js.map +1 -0
- package/dist/ads-flows/youtube-watch.d.ts +2 -0
- package/dist/ads-flows/youtube-watch.js +23 -0
- package/dist/ads-flows/youtube-watch.js.map +1 -0
- package/dist/execute-ads-actions/ads-views/make-ads-tw-view.js +2 -1
- package/dist/execute-ads-actions/ads-views/make-ads-tw-view.js.map +1 -1
- package/dist/execute-ads-actions/index.d.ts +1 -1
- package/dist/execute-ads-actions/index.js +9 -2
- package/dist/execute-ads-actions/index.js.map +1 -1
- package/dist/execute-ads-actions/process-insert-ad-action.d.ts +1 -1
- package/dist/execute-ads-actions/process-insert-ad-action.js +30 -9
- package/dist/execute-ads-actions/process-insert-ad-action.js.map +1 -1
- package/dist/index.js +11 -11
- package/dist/index.js.map +1 -1
- package/dist/referrals/common.d.ts +1 -2
- package/dist/referrals/common.js.map +1 -1
- package/dist/referrals/index.d.ts +1 -25
- package/dist/referrals/index.js +5 -11
- package/dist/referrals/index.js.map +1 -1
- package/dist/temple-ads-api.d.ts +2 -1
- package/dist/temple-ads-api.js +4 -0
- package/dist/temple-ads-api.js.map +1 -1
- package/dist/types/ads-actions.d.ts +30 -4
- package/dist/types/ads-actions.js +2 -0
- package/dist/types/ads-actions.js.map +1 -1
- package/dist/types/temple-ads-api.d.ts +36 -0
- package/package.json +1 -1
- package/src/execute-ads-actions/children-add-or-remove-changes.ts +43 -0
- package/src/execute-ads-actions/index.ts +8 -3
- package/src/execute-ads-actions/process-insert-ad-action.ts +26 -2
- package/src/referrals/common.ts +1 -2
- package/src/referrals/index.ts +0 -4
- package/src/transform-raw-rules.ts +6 -1
- package/src/referrals/replace-takeads.ts +0 -52
- package/src/referrals/takeads.ts +0 -44
|
@@ -14,6 +14,7 @@ import { AdActionType, InsertAdAction } from 'src/types/ads-actions';
|
|
|
14
14
|
import { AdDimensions } from 'src/types/ads-meta';
|
|
15
15
|
import { doAfterSuccessfulPing } from 'src/utils';
|
|
16
16
|
|
|
17
|
+
import { ChildrenAddOrRemoveChanges } from './children-add-or-remove-changes';
|
|
17
18
|
import { observeNodeMutations, subscribeToAdsStackIframeLoadIfNecessary, unobserveNodeMutations } from './observing';
|
|
18
19
|
import { overrideElementStyles } from './override-element-styles';
|
|
19
20
|
import { getAdThemingParams } from './theming-params';
|
|
@@ -46,6 +47,7 @@ const getWrapperDimensions = (action: InsertAdAction) => {
|
|
|
46
47
|
|
|
47
48
|
const processInsertAdActionOnce = async (
|
|
48
49
|
action: InsertAdAction,
|
|
50
|
+
childrenAddOrRemoveChanges: ChildrenAddOrRemoveChanges,
|
|
49
51
|
wrapperElement: HTMLDivElement,
|
|
50
52
|
insertionPoint: HTMLDivElement | HTMLTableCellElement,
|
|
51
53
|
onAdsStackLoad: () => void,
|
|
@@ -94,15 +96,31 @@ const processInsertAdActionOnce = async (
|
|
|
94
96
|
switch (action.type) {
|
|
95
97
|
case AdActionType.ReplaceAllChildren:
|
|
96
98
|
stylesOverridesCurrentElement = action.parent;
|
|
99
|
+
for (const child of action.parent.children) {
|
|
100
|
+
childrenAddOrRemoveChanges.beforeChildRemoved(child);
|
|
101
|
+
}
|
|
97
102
|
action.parent.innerHTML = '';
|
|
98
103
|
action.parent.appendChild(wrapperElement);
|
|
104
|
+
childrenAddOrRemoveChanges.onChildAdded(wrapperElement);
|
|
99
105
|
break;
|
|
100
106
|
case AdActionType.ReplaceElement:
|
|
101
107
|
stylesOverridesCurrentElement = action.element.parentElement;
|
|
102
108
|
action.element.replaceWith(wrapperElement);
|
|
103
109
|
break;
|
|
104
110
|
default:
|
|
105
|
-
|
|
111
|
+
let insertionIndex = action.insertionIndex;
|
|
112
|
+
childrenAddOrRemoveChanges.get(action.parent).forEach(change => {
|
|
113
|
+
if (change.index >= insertionIndex) {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (change.type === 'remove') {
|
|
118
|
+
insertionIndex--;
|
|
119
|
+
} else {
|
|
120
|
+
insertionIndex++;
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
const nextSibling = action.parent.children[insertionIndex];
|
|
106
124
|
if (action.isSiblingReplacement) {
|
|
107
125
|
wrapperElement.setAttribute(SIBLING_REPLACEMENT_ATTRIBUTE_NAME, 'true');
|
|
108
126
|
const observer = new MutationObserver(mutations => {
|
|
@@ -111,6 +129,7 @@ const processInsertAdActionOnce = async (
|
|
|
111
129
|
);
|
|
112
130
|
|
|
113
131
|
if (hasRemoveSiblingMutation) {
|
|
132
|
+
childrenAddOrRemoveChanges.beforeChildRemoved(wrapperElement);
|
|
114
133
|
wrapperElement.remove();
|
|
115
134
|
observer.disconnect();
|
|
116
135
|
}
|
|
@@ -119,6 +138,7 @@ const processInsertAdActionOnce = async (
|
|
|
119
138
|
}
|
|
120
139
|
stylesOverridesCurrentElement = action.parent;
|
|
121
140
|
action.parent.insertBefore(wrapperElement, nextSibling);
|
|
141
|
+
childrenAddOrRemoveChanges.onChildAdded(wrapperElement);
|
|
122
142
|
break;
|
|
123
143
|
}
|
|
124
144
|
|
|
@@ -234,7 +254,10 @@ const hidingStylesOverrides = {
|
|
|
234
254
|
'min-width': '0px'
|
|
235
255
|
};
|
|
236
256
|
|
|
237
|
-
export const processInsertAdAction = async (
|
|
257
|
+
export const processInsertAdAction = async (
|
|
258
|
+
action: InsertAdAction,
|
|
259
|
+
childrenAddOrRemoveChanges: ChildrenAddOrRemoveChanges
|
|
260
|
+
) => {
|
|
238
261
|
const { wrapperStyle = {}, adsMetadata, wrapperType = 'div', colsAfter = 0, colsBefore = 0, colspan = 1 } = action;
|
|
239
262
|
const isNativeAd = adsMetadata.every(adMetadata => typeof adMetadata === 'object');
|
|
240
263
|
|
|
@@ -274,6 +297,7 @@ export const processInsertAdAction = async (action: InsertAdAction) => {
|
|
|
274
297
|
|
|
275
298
|
await processInsertAdActionOnce(
|
|
276
299
|
action,
|
|
300
|
+
childrenAddOrRemoveChanges,
|
|
277
301
|
wrapperElement,
|
|
278
302
|
insertionPoint,
|
|
279
303
|
() => {
|
package/src/referrals/common.ts
CHANGED
|
@@ -7,7 +7,6 @@ import { getCurrentPageDomain, ReferralTextIconRule, stripSubdomain } from './ut
|
|
|
7
7
|
const TEMPLE_WALLET_ANCHOR_ATTRIBUTE = 'data-tw-referral';
|
|
8
8
|
|
|
9
9
|
export interface AdsBrowserExtensionMessageTypeI {
|
|
10
|
-
FetchTakeAdsReferrals: string;
|
|
11
10
|
ReferralClick: string;
|
|
12
11
|
}
|
|
13
12
|
|
|
@@ -42,7 +41,7 @@ export function processAnchorElement(
|
|
|
42
41
|
item: PreppedItem,
|
|
43
42
|
textIconRules: ReferralTextIconRule[],
|
|
44
43
|
AdsBrowserExtensionMessageType: AdsBrowserExtensionMessageTypeI,
|
|
45
|
-
provider: '
|
|
44
|
+
provider: 'Temple',
|
|
46
45
|
redirectUrl?: string
|
|
47
46
|
) {
|
|
48
47
|
const { aElem, urlDomain, referralUrl, imageUrl } = item;
|
package/src/referrals/index.ts
CHANGED
|
@@ -107,7 +107,12 @@ const buildAdPlacesRules = (
|
|
|
107
107
|
const ruleToComplementIndex = acc.findIndex(({ selector: candidateSelector, ...candidateRestProps }) => {
|
|
108
108
|
const { cssString: _candidateCssString, ...restCandidateSelectorProps } = candidateSelector;
|
|
109
109
|
|
|
110
|
-
return
|
|
110
|
+
return (
|
|
111
|
+
isEqual(restSelectorProps, restCandidateSelectorProps) &&
|
|
112
|
+
isEqual(restProps, candidateRestProps) &&
|
|
113
|
+
restSelectorProps.isMultiple &&
|
|
114
|
+
restCandidateSelectorProps.isMultiple
|
|
115
|
+
);
|
|
111
116
|
});
|
|
112
117
|
if (ruleToComplementIndex === -1) {
|
|
113
118
|
acc.push({ selector, ...restProps });
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import browser from 'webextension-polyfill';
|
|
2
|
-
|
|
3
|
-
import { IS_DEV } from 'src/utils';
|
|
4
|
-
|
|
5
|
-
import { AdsBrowserExtensionMessageTypeI, getItemsToReplace, processAnchorElement } from './common';
|
|
6
|
-
import type { TekeadsAffiliateResponse } from './takeads';
|
|
7
|
-
import { ReferralTextIconRule } from './utils';
|
|
8
|
-
|
|
9
|
-
export async function processTakeAdsAnchors(
|
|
10
|
-
supportedDomains: Set<string>,
|
|
11
|
-
textIconRules: ReferralTextIconRule[],
|
|
12
|
-
AdsBrowserExtensionMessageType: AdsBrowserExtensionMessageTypeI,
|
|
13
|
-
redirectUrl?: string
|
|
14
|
-
) {
|
|
15
|
-
const items = getItemsToReplace(supportedDomains);
|
|
16
|
-
|
|
17
|
-
if (!items.length) return void (IS_DEV && console.info('Nothing to replace'));
|
|
18
|
-
|
|
19
|
-
const links = items.map(l => l.iri);
|
|
20
|
-
|
|
21
|
-
// Not requesting directly in content script because of CORS.
|
|
22
|
-
const takeadsItems: TekeadsAffiliateResponse = await browser.runtime.sendMessage({
|
|
23
|
-
type: AdsBrowserExtensionMessageType.FetchTakeAdsReferrals,
|
|
24
|
-
links
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
if (!takeadsItems.data.length) return void (IS_DEV && console.info('No referrals received'));
|
|
28
|
-
|
|
29
|
-
IS_DEV && console.info('Replacing', takeadsItems.data.length, 'referralas');
|
|
30
|
-
|
|
31
|
-
for (const { iri, aElem, urlDomain } of items) {
|
|
32
|
-
const data = takeadsItems.data.find(item => item.iri === iri);
|
|
33
|
-
const referralUrl = data?.trackingLink;
|
|
34
|
-
|
|
35
|
-
if (!referralUrl) {
|
|
36
|
-
IS_DEV && console.warn('No affiliate link for', aElem);
|
|
37
|
-
continue;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const imageUrl = data.imageUrl;
|
|
41
|
-
|
|
42
|
-
processAnchorElement(
|
|
43
|
-
{ iri, aElem, urlDomain, referralUrl, imageUrl },
|
|
44
|
-
textIconRules,
|
|
45
|
-
AdsBrowserExtensionMessageType,
|
|
46
|
-
'TakeAds',
|
|
47
|
-
redirectUrl
|
|
48
|
-
);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return;
|
|
52
|
-
}
|
package/src/referrals/takeads.ts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import axios, { AxiosInstance } from 'axios';
|
|
2
|
-
import memoizee from 'memoizee';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* API docs: https://docs.takeads.com
|
|
6
|
-
*/
|
|
7
|
-
class TakeAdsClient {
|
|
8
|
-
private axios: AxiosInstance;
|
|
9
|
-
|
|
10
|
-
constructor(
|
|
11
|
-
private publicKey: string,
|
|
12
|
-
readonly apiUrl: string = 'https://api.takeads.com'
|
|
13
|
-
) {
|
|
14
|
-
this.axios = axios.create({
|
|
15
|
-
baseURL: apiUrl,
|
|
16
|
-
headers: {
|
|
17
|
-
Authorization: `Bearer ${this.publicKey}`
|
|
18
|
-
},
|
|
19
|
-
adapter: 'fetch'
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
async affiliateLinks(websiteUrls: string[], subId?: string) {
|
|
24
|
-
const response = await this.axios.put<TekeadsAffiliateResponse>('/v1/product/monetize-api/v2/resolve', {
|
|
25
|
-
iris: websiteUrls,
|
|
26
|
-
subId,
|
|
27
|
-
withImages: true
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
return response.data;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export const buildTakeadsClient = memoizee((publicKey: string) => new TakeAdsClient(publicKey), { max: 2 });
|
|
35
|
-
|
|
36
|
-
export interface TekeadsAffiliateResponse {
|
|
37
|
-
data: AffiliateLink[];
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
interface AffiliateLink {
|
|
41
|
-
iri: string;
|
|
42
|
-
trackingLink: string;
|
|
43
|
-
imageUrl: string | null;
|
|
44
|
-
}
|