macro-parameters 0.0.6 → 0.0.8

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/index.js CHANGED
@@ -1,229 +1 @@
1
- function getCookie(name) {
2
- var reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
3
- var arr;
4
- var source = document.cookie ||
5
- (window.localStorage && window.localStorage.cookie) ||
6
- "";
7
- return (arr = source.match(reg)) ? unescape(arr[2]) : "";
8
- }
9
- function getLocalStorage(name) {
10
- if (typeof localStorage === "object") {
11
- return localStorage.getItem(name);
12
- }
13
- return null;
14
- }
15
- function getTvBrand() {
16
- if (localStorage.getItem("brand")) { //TODO: 处理whaleos的一些特殊情况,后期可以考虑去除
17
- return localStorage.getItem("brand");
18
- }
19
- var userAgent = navigator.userAgent.toUpperCase();
20
- var _tvBrand = "others";
21
- if (userAgent.indexOf("AOC") > -1) {
22
- _tvBrand = "aoc";
23
- }
24
- else if (userAgent.indexOf("PHILIPS") > -1) {
25
- _tvBrand = "philips";
26
- }
27
- else {
28
- _tvBrand = "others";
29
- }
30
- return _tvBrand;
31
- }
32
- function getProfileId() {
33
- //Get the profile id from cookie
34
- var _profileId = getCookie("profileid") || getCookie("profileId");
35
- var items = [];
36
- if (_profileId && _profileId != "") {
37
- // if profile id exists split it with underscore
38
- items = _profileId.split("_");
39
- return items[1];
40
- }
41
- else {
42
- return "Unknown";
43
- }
44
- }
45
- function setCookie(name, value, expires, path, domain, secure) {
46
- var cookieString = name +
47
- "=" +
48
- escape(value) +
49
- (expires ? ";expires=" + expires.toGMTString() : "") +
50
- ("") +
51
- ("") +
52
- ("");
53
- document.cookie = cookieString;
54
- }
55
- function getLocationOrigin() {
56
- return (location.origin ||
57
- "".concat(location.protocol, "//").concat(location.host || location.hostname).concat(location.port));
58
- }
59
-
60
- function cleanPlaceholder(str, params) {
61
- for (var k in PlaceHolders) {
62
- var param = k.replace('[', '\\[').replace(']', '\\]');
63
- var paramName = k.replace('[', '').replace(']', '');
64
- str = str.replace(new RegExp(param, 'g'), params[paramName] || PlaceHolders[k]() || "");
65
- }
66
- return replaceEmpty(str);
67
- }
68
- function replaceEmpty(content) {
69
- var reg = /\[.*?\]/g;
70
- return content.replace(reg, "");
71
- }
72
- var PlaceHolders = {
73
- "[tv_domain]": function () {
74
- return document.domain;
75
- },
76
- "[app_name]": function () {
77
- return getExternalMacroParam("app_name");
78
- },
79
- "[bundle_id]": function () {
80
- return getExternalMacroParam("bundle_id");
81
- },
82
- "[app_store_url]": function () {
83
- return getExternalMacroParam("app_store_url");
84
- },
85
- "[src_page_url]": function () {
86
- return encodeURIComponent(getLocationOrigin());
87
- },
88
- "[player_height]": function () {
89
- return getExternalMacroParam("player_height");
90
- },
91
- "[player_width]": function () {
92
- return getExternalMacroParam("player_width");
93
- },
94
- "[channel_no]": function () {
95
- return getExternalMacroParam("channel_no");
96
- },
97
- "[channel_category]": function () {
98
- return getExternalMacroParam("channel_category");
99
- },
100
- "[whale_ad_id]": function () {
101
- // return WhaleADID;
102
- },
103
- "[relevant_ads]": function () {
104
- // if (isWhaleOSGlobal) {
105
- // return "true"
106
- // }
107
- var reladvertStatus = "false";
108
- var userAgent = navigator.userAgent.toUpperCase();
109
- if (userAgent.indexOf("AOC") > -1) {
110
- reladvertStatus = getCookie("relAdvert");
111
- }
112
- else {
113
- reladvertStatus = getCookie("relAdvert");
114
- }
115
- reladvertStatus = reladvertStatus == null ? "false" : reladvertStatus;
116
- return reladvertStatus;
117
- },
118
- "[device_dnt]": function () {
119
- return getExternalMacroParam("device_dnt") || (getCookie("relAdvert") == 'true' ? 0 : 1);
120
- },
121
- "[tv_brand]": function () {
122
- return getTvBrand();
123
- },
124
- "[cntry]": function () {
125
- //return countryGlobal;
126
- },
127
- "[geo_ip_country]": function () {
128
- //return geoIpCountryGlobal;
129
- },
130
- "[platform_id]": function () {
131
- return getProfileId();
132
- },
133
- "[device_user_agent]": function () {
134
- var UA = navigator.userAgent;
135
- return encodeURIComponent(UA);
136
- },
137
- "[device_ip_address]": function () {
138
- return getExternalMacroParam("device_ip_address");
139
- },
140
- "[menu_language]": function () {
141
- var lang = navigator.language;
142
- if (lang) {
143
- return (lang.length > 2) ? lang.slice(0, 2) : lang;
144
- }
145
- else {
146
- return 'un';
147
- }
148
- },
149
- "[privacy_policy]": function () {
150
- return getExternalMacroParam("privacy_policy");
151
- },
152
- "[whale_gdpr]": function () {
153
- return getExternalMacroParam("whale_gdpr") || (getCookie("relAdvert") == 'true' ? 1 : 0);
154
- },
155
- "[whale_gdpr_consent]": function () {
156
- return getCookie("tcString") || getLocalStorage('default_tcString');
157
- },
158
- "[rnd]": function () {
159
- return new Date().getTime();
160
- },
161
- "[ad_sdk_ver]": function () {
162
- return "";
163
- },
164
- "[time_zone]": function () {
165
- return new Date().getTimezoneOffset();
166
- },
167
- "[google_pal]": function () {
168
- if (!window.googleNonce && getCookie("googleNonce")) {
169
- return getCookie("googleNonce");
170
- }
171
- if (window.googleNonce) {
172
- setCookie("googleNonce", window.googleNonce, new Date(new Date().getTime() + 6 * 60 * 60 * 1000));
173
- }
174
- return window.googleNonce || '';
175
- },
176
- "[device_lmt]": function () {
177
- return getCookie("relAdvert") === 'true' ? 0 : 1;
178
- },
179
- "[avod_id]": function () {
180
- return "";
181
- },
182
- "[avod_title]": function () {
183
- return "";
184
- },
185
- "[device_id]": function () {
186
- return getCookie("deviceid") || getCookie("deviceId");
187
- },
188
- "[session_id]": function () {
189
- return window.session_id;
190
- },
191
- "[usertag]": function () {
192
- return getCookie("usertag");
193
- }
194
- };
195
- function getExternalMacroParam(name) {
196
- var externalMacroParam = window.externalMacroParam;
197
- if (externalMacroParam && typeof externalMacroParam === "object" && externalMacroParam.hasOwnProperty(name)) {
198
- return externalMacroParam[name];
199
- }
200
- else {
201
- return "";
202
- }
203
- }
204
-
205
- var MacroSubstitution = /** @class */ (function () {
206
- function MacroSubstitution() {
207
- this.params = {};
208
- }
209
- MacroSubstitution.prototype.set = function (params) {
210
- if (!params) {
211
- console.log("Invalid settings");
212
- return;
213
- }
214
- for (var key in params) {
215
- if (params.hasOwnProperty(key)) {
216
- console.log(key + ": " + params[key]);
217
- this.params[key] = params[key];
218
- }
219
- }
220
- };
221
- MacroSubstitution.prototype.handle = function (str) {
222
- console.log(cleanPlaceholder(str, this.params));
223
- console.log(this.params);
224
- return cleanPlaceholder(str, this.params);
225
- };
226
- return MacroSubstitution;
227
- }());
228
-
229
- export { MacroSubstitution as default };
1
+ var e=function(){return e=Object.assign||function(e){for(var n,r=1,t=arguments.length;r<t;r++)for(var o in n=arguments[r])Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o]);return e},e.apply(this,arguments)};function n(e){var n,r=new RegExp("(^| )"+e+"=([^;]*)(;|$)");return(n=(document.cookie||window.localStorage&&window.localStorage.cookie||"").match(r))?unescape(n[2]):""}function r(e){var n=window.externalMacroParam;return n&&"object"==typeof n&&n.hasOwnProperty(e)?n[e]:""}"function"==typeof SuppressedError&&SuppressedError;var t={"[provider_id]":function(){return r("provider_id")},"[channel_no]":function(){return r("channel_no")},"[channel_category]":function(){return r("channel_category")},"[channel_name]":function(){return r("channel_category")},"[iab_category]":function(){return r("iab_category")},"[avod_id]":function(){return r("avod_id")},"[avod_genre]":function(){return r("avod_genre")},"[avod_title]":function(){return r("avod_title")},"[oriented_age]":function(){return r("oriented_age")},"[oriented_gender]":function(){return r("oriented_gender")},"[ssai_vendor]":function(){return r("ssai_vendor")}},o={"[whale_ad_id]":function(){},"[tv_brand]":function(){return function(){if(localStorage.getItem("brand"))return localStorage.getItem("brand");var e=navigator.userAgent.toUpperCase();return e.indexOf("AOC")>-1?"aoc":e.indexOf("PHILIPS")>-1?"philips":"others"}()},"[cntry]":function(){},"[geo_ip_country]":function(){},"[platform_id]":function(){return(e=n("profileid")||n("profileId"))&&""!=e?e.split("_")[1]:"Unknown";var e},"[device_user_agent]":function(){var e=navigator.userAgent;return encodeURIComponent(e)},"[device_ip_address]":function(){return r("device_ip_address")},"[menu_language]":function(){var e=navigator.language;return e?e.length>2?e.slice(0,2):e:"un"},"[time_zone]":function(){return(new Date).getTimezoneOffset()}},i={"[whale_gdpr]":function(){return r("whale_gdpr")||("true"==n("relAdvert")?1:0)},"[whale_gdpr_consent]":function(){return n("tcString")||(e="default_tcString","object"==typeof localStorage?localStorage.getItem(e):null);var e},"[relevant_ads]":function(){var e="false";return e=null==(e=(navigator.userAgent.toUpperCase().indexOf("AOC"),n("relAdvert")))?"false":e},"[device_dnt]":function(){return r("device_dnt")||("true"==n("relAdvert")?0:1)},"[device_lmt]":function(){return"true"===n("relAdvert")?0:1},"[privacy_policy]":function(){return r("privacy_policy")}},a={"[rnd]":function(){return(new Date).getTime()},"[timestamp]":function(){return(new Date).getTime()},"[ad_sdk_ver]":function(){return""},"[google_pal]":function(){return!window.googleNonce&&n("googleNonce")?n("googleNonce"):(window.googleNonce&&(e="googleNonce",r=window.googleNonce,t=new Date((new Date).getTime()+216e5),o=e+"="+escape(r)+(t?";expires="+t.toGMTString():""),document.cookie=o),window.googleNonce||"");var e,r,t,o}},c={"[device_id]":function(){return n("deviceid")||n("deviceId")},"[session_id]":function(){return window.session_id},"[usertag]":function(){return n("usertag")}};function u(e,n){for(var r in l){var t=r.replace("[","\\[").replace("]","\\]"),o=r.replace("[","").replace("]","");e=e.replace(new RegExp(t,"g"),n[o]||l[r]()||"")}return i=/\[.*?\]/g,e.replace(i,"");var i}var l=e(e(e(e(e(e({},{"[tv_domain]":function(){return document.domain},"[app_name]":function(){return r("app_name")},"[bundle_id]":function(){return r("bundle_id")},"[app_store_url]":function(){return r("app_store_url")},"[src_page_url]":function(){return encodeURIComponent(location.origin||"".concat(location.protocol,"//").concat(location.host||location.hostname).concat(location.port))},"[player_height]":function(){return r("player_height")},"[player_width]":function(){return r("player_width")},"[placement]":function(){return r("placement")}}),t),o),i),a),c),d=function(){function e(){this.params={}}return e.prototype.set=function(e){if(e)for(var n in e)e.hasOwnProperty(n)&&(console.log(n+": "+e[n]),this.params[n]=e[n]);else console.log("Invalid settings")},e.prototype.handle=function(e){return console.log(u(e,this.params)),console.log(this.params),u(e,this.params)},e}();export{d as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "macro-parameters",
3
- "version": "0.0.6",
3
+ "version": "0.0.8",
4
4
  "description": "Provide unified macro parameter retrieval",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -9,6 +9,7 @@
9
9
  "author": "caiyuanjia",
10
10
  "license": "ISC",
11
11
  "devDependencies": {
12
+ "@rollup/plugin-terser": "^0.4.4",
12
13
  "rollup": "^4.21.1",
13
14
  "rollup-plugin-typescript2": "^0.36.0",
14
15
  "typescript": "^5.5.4"
package/rollup.config.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import typescript2 from 'rollup-plugin-typescript2';
2
+ import terser from '@rollup/plugin-terser';
2
3
 
3
4
  export default {
4
5
  input: 'src/main.ts',
@@ -8,6 +9,7 @@ export default {
8
9
  name: 'AdMacro'
9
10
  },
10
11
  plugins: [
11
- typescript2()
12
+ typescript2(),
13
+ terser()
12
14
  ]
13
15
  };
package/script/utils.ts CHANGED
@@ -61,10 +61,19 @@ export function setCookie(
61
61
  document.cookie = cookieString;
62
62
  }
63
63
 
64
- export function getLocationOrigin() {
64
+ export function getLocationOrigin() {
65
65
  return (
66
66
  location.origin ||
67
67
  `${location.protocol}//${location.host || location.hostname}${location.port
68
68
  }`
69
69
  );
70
+ }
71
+
72
+ export function getExternalMacroParam(name: string): string {
73
+ const externalMacroParam = (window as any).externalMacroParam;
74
+ if (externalMacroParam && typeof externalMacroParam === "object" && externalMacroParam.hasOwnProperty(name)) {
75
+ return externalMacroParam[name];
76
+ } else {
77
+ return "";
78
+ }
70
79
  }
package/src/replace.ts CHANGED
@@ -1,11 +1,11 @@
1
1
  import {
2
- getCookie,
3
- getLocalStorage,
4
- getLocationOrigin,
5
- getTvBrand,
6
- getProfileId,
7
- setCookie
8
- } from "../script/utils"
2
+ App,
3
+ Content,
4
+ Device,
5
+ GDPR,
6
+ Generic,
7
+ Other
8
+ } from "../type";
9
9
  export function cleanPlaceholder(str: string, params: object) {
10
10
  for (let k in PlaceHolders) {
11
11
  let param = k.replace('[', '\\[').replace(']', '\\]');
@@ -21,133 +21,16 @@ function replaceEmpty(content: string) {
21
21
  }
22
22
 
23
23
  const PlaceHolders: any = {
24
- "[tv_domain]"() {
25
- return document.domain
26
- },
27
- "[app_name]"() {
28
- return getExternalMacroParam("app_name");
29
- },
30
- "[bundle_id]"() {
31
- return getExternalMacroParam("bundle_id");
32
- },
33
- "[app_store_url]"() {
34
- return getExternalMacroParam("app_store_url");
35
- },
36
- "[src_page_url]"() {
37
- return encodeURIComponent(getLocationOrigin());
38
- },
39
- "[player_height]"() {
40
- return getExternalMacroParam("player_height");
41
- },
42
- "[player_width]"() {
43
- return getExternalMacroParam("player_width");
44
- },
45
- "[channel_no]"() {
46
- return getExternalMacroParam("channel_no");
47
- },
48
- "[channel_category]"() {
49
- return getExternalMacroParam("channel_category");
50
- },
51
- "[whale_ad_id]"() {
52
- // return WhaleADID;
53
- },
54
- "[relevant_ads]"() {
55
- // if (isWhaleOSGlobal) {
56
- // return "true"
57
- // }
58
- let reladvertStatus = "false";
59
- const userAgent = navigator.userAgent.toUpperCase();
60
- if (userAgent.indexOf("AOC") > -1) {
61
- reladvertStatus = getCookie("relAdvert");
62
- } else {
63
- reladvertStatus = getCookie("relAdvert");
64
- }
65
-
66
- reladvertStatus = reladvertStatus == null ? "false" : reladvertStatus;
67
- return reladvertStatus;
68
- },
69
- "[device_dnt]"() {
70
- return getExternalMacroParam("device_dnt") || (getCookie("relAdvert") == 'true' ? 0 : 1);
71
- },
72
- "[tv_brand]"() {
73
- return getTvBrand();
74
- },
75
- "[cntry]"() {
76
- //return countryGlobal;
77
- },
78
- "[geo_ip_country]"() {
79
- //return geoIpCountryGlobal;
80
- },
81
- "[platform_id]"() {
82
- return getProfileId();
83
- },
84
- "[device_user_agent]"() {
85
- const UA = navigator.userAgent;
86
- return encodeURIComponent(UA);
87
- },
88
- "[device_ip_address]"() {
89
- return getExternalMacroParam("device_ip_address");
90
- },
91
- "[menu_language]"() {
92
- const lang = navigator.language;
93
- if (lang) {
94
- return (lang.length > 2) ? lang.slice(0, 2) : lang;
95
- } else {
96
- return 'un';
97
- }
98
- },
99
- "[privacy_policy]"() {
100
- return getExternalMacroParam("privacy_policy");
101
- },
102
- "[whale_gdpr]"() {
103
- return getExternalMacroParam("whale_gdpr") || (getCookie("relAdvert") == 'true' ? 1 : 0);
104
- },
105
- "[whale_gdpr_consent]"() {
106
- return getCookie("tcString") || getLocalStorage('default_tcString');
107
- },
108
- "[rnd]"() {
109
- return new Date().getTime();
110
- },
111
- "[ad_sdk_ver]"() {
112
- return "";
113
- },
114
- "[time_zone]"() {
115
- return new Date().getTimezoneOffset();
116
- },
117
- "[google_pal]"() {
118
- if (!(window as any).googleNonce && getCookie("googleNonce")) {
119
- return getCookie("googleNonce");
120
- }
121
- if ((window as any).googleNonce) {
122
- setCookie("googleNonce", (window as any).googleNonce, new Date(new Date().getTime() + 6 * 60 * 60 * 1000));
123
- }
124
- return (window as any).googleNonce || '';
125
- },
126
- "[device_lmt]"() {
127
- return getCookie("relAdvert") === 'true' ? 0 : 1
128
- },
129
- "[avod_id]"() {
130
- return ""
131
- },
132
- "[avod_title]"() {
133
- return ""
134
- },
135
- "[device_id]"() {
136
- return getCookie("deviceid") || getCookie("deviceId")
137
- },
138
- "[session_id]"() {
139
- return (window as any).session_id;
140
- },
141
- "[usertag]"() {
142
- return getCookie("usertag")
143
- }
144
- };
145
-
146
- function getExternalMacroParam(name: string): string {
147
- const externalMacroParam = (window as any).externalMacroParam;
148
- if (externalMacroParam && typeof externalMacroParam === "object" && externalMacroParam.hasOwnProperty(name)) {
149
- return externalMacroParam[name];
150
- } else {
151
- return "";
152
- }
153
- }
24
+ //Type: APP
25
+ ...App,
26
+ //Type: Content
27
+ ...Content,
28
+ //Type: Device
29
+ ...Device,
30
+ //Type: GDPR
31
+ ...GDPR,
32
+ //Type: Generic
33
+ ...Generic,
34
+ //Type: Other
35
+ ...Other
36
+ };
package/type/app.ts ADDED
@@ -0,0 +1,31 @@
1
+ import {
2
+ getExternalMacroParam,
3
+ getLocationOrigin
4
+ } from "../script/utils"
5
+ const App = {
6
+ "[tv_domain]"() {
7
+ return document.domain
8
+ },
9
+ "[app_name]"() {
10
+ return getExternalMacroParam("app_name");
11
+ },
12
+ "[bundle_id]"() {
13
+ return getExternalMacroParam("bundle_id");
14
+ },
15
+ "[app_store_url]"() {
16
+ return getExternalMacroParam("app_store_url");
17
+ },
18
+ "[src_page_url]"() {
19
+ return encodeURIComponent(getLocationOrigin());
20
+ },
21
+ "[player_height]"() {
22
+ return getExternalMacroParam("player_height");
23
+ },
24
+ "[player_width]"() {
25
+ return getExternalMacroParam("player_width");
26
+ },
27
+ "[placement]"() {
28
+ return getExternalMacroParam("placement");
29
+ }
30
+ };
31
+ export { App }
@@ -0,0 +1,38 @@
1
+
2
+ import { getExternalMacroParam } from "../script/utils"
3
+ const Content = {
4
+ "[provider_id]"() {
5
+ return getExternalMacroParam("provider_id");
6
+ },
7
+ "[channel_no]"() {
8
+ return getExternalMacroParam("channel_no");
9
+ },
10
+ "[channel_category]"() {
11
+ return getExternalMacroParam("channel_category");
12
+ },
13
+ "[channel_name]"() {
14
+ return getExternalMacroParam("channel_category");
15
+ },
16
+ "[iab_category]"() {
17
+ return getExternalMacroParam("iab_category");
18
+ },
19
+ "[avod_id]"() {
20
+ return getExternalMacroParam("avod_id");
21
+ },
22
+ "[avod_genre]"() {
23
+ return getExternalMacroParam("avod_genre");
24
+ },
25
+ "[avod_title]"() {
26
+ return getExternalMacroParam("avod_title");
27
+ },
28
+ "[oriented_age]"() {
29
+ return getExternalMacroParam("oriented_age");
30
+ },
31
+ "[oriented_gender]"() {
32
+ return getExternalMacroParam("oriented_gender");
33
+ },
34
+ "[ssai_vendor]"() {
35
+ return getExternalMacroParam("ssai_vendor");
36
+ }
37
+ }
38
+ export { Content }
package/type/device.ts ADDED
@@ -0,0 +1,42 @@
1
+ import {
2
+ getExternalMacroParam,
3
+ getTvBrand,
4
+ getProfileId
5
+ } from "../script/utils"
6
+ const Device = {
7
+ "[whale_ad_id]"() {
8
+ // return WhaleADID;
9
+ },
10
+ "[tv_brand]"() {
11
+ return getTvBrand();
12
+ },
13
+ "[cntry]"() {
14
+ //return countryGlobal;
15
+ },
16
+ "[geo_ip_country]"() {
17
+ //return geoIpCountryGlobal;
18
+ },
19
+ "[platform_id]"() {
20
+ return getProfileId();
21
+ },
22
+ "[device_user_agent]"() {
23
+ const UA = navigator.userAgent;
24
+ return encodeURIComponent(UA);
25
+ },
26
+ "[device_ip_address]"() {
27
+ return getExternalMacroParam("device_ip_address");
28
+ },
29
+ "[menu_language]"() {
30
+ const lang = navigator.language;
31
+ if (lang) {
32
+ return (lang.length > 2) ? lang.slice(0, 2) : lang;
33
+ } else {
34
+ return 'un';
35
+ }
36
+ },
37
+ "[time_zone]"() {
38
+ return new Date().getTimezoneOffset();
39
+ },
40
+ }
41
+
42
+ export { Device }
package/type/gdpr.ts ADDED
@@ -0,0 +1,40 @@
1
+
2
+ import {
3
+ getCookie,
4
+ getExternalMacroParam,
5
+ getLocalStorage
6
+ } from "../script/utils"
7
+ const GDPR = {
8
+ "[whale_gdpr]"() {
9
+ return getExternalMacroParam("whale_gdpr") || (getCookie("relAdvert") == 'true' ? 1 : 0);
10
+ },
11
+ "[whale_gdpr_consent]"() {
12
+ return getCookie("tcString") || getLocalStorage('default_tcString');
13
+ },
14
+ "[relevant_ads]"() {
15
+ // if (isWhaleOSGlobal) {
16
+ // return "true"
17
+ // }
18
+ let reladvertStatus = "false";
19
+ const userAgent = navigator.userAgent.toUpperCase();
20
+ if (userAgent.indexOf("AOC") > -1) {
21
+ reladvertStatus = getCookie("relAdvert");
22
+ } else {
23
+ reladvertStatus = getCookie("relAdvert");
24
+ }
25
+
26
+ reladvertStatus = reladvertStatus == null ? "false" : reladvertStatus;
27
+ return reladvertStatus;
28
+ },
29
+ "[device_dnt]"() {
30
+ return getExternalMacroParam("device_dnt") || (getCookie("relAdvert") == 'true' ? 0 : 1);
31
+ },
32
+ "[device_lmt]"() {
33
+ return getCookie("relAdvert") === 'true' ? 0 : 1
34
+ },
35
+ "[privacy_policy]"() {
36
+ return getExternalMacroParam("privacy_policy");
37
+ },
38
+ }
39
+
40
+ export { GDPR }
@@ -0,0 +1,26 @@
1
+ import {
2
+ getCookie,
3
+ setCookie
4
+ } from "../script/utils"
5
+ const Generic = {
6
+ "[rnd]"() {
7
+ return new Date().getTime();
8
+ },
9
+ "[timestamp]"() {
10
+ return new Date().getTime();
11
+ },
12
+ "[ad_sdk_ver]"() {
13
+ return "";
14
+ },
15
+ "[google_pal]"() {
16
+ if (!(window as any).googleNonce && getCookie("googleNonce")) {
17
+ return getCookie("googleNonce");
18
+ }
19
+ if ((window as any).googleNonce) {
20
+ setCookie("googleNonce", (window as any).googleNonce, new Date(new Date().getTime() + 6 * 60 * 60 * 1000));
21
+ }
22
+ return (window as any).googleNonce || '';
23
+ },
24
+ }
25
+
26
+ export { Generic }
package/type/index.ts ADDED
@@ -0,0 +1,15 @@
1
+ import { App } from "./app"
2
+ import { Content } from "./content"
3
+ import { Device } from "./device"
4
+ import { GDPR } from "./gdpr"
5
+ import { Generic } from "./generic"
6
+ import { Other } from "./other"
7
+
8
+ export {
9
+ App,
10
+ Content,
11
+ Device,
12
+ GDPR,
13
+ Generic,
14
+ Other
15
+ }
package/type/other.ts ADDED
@@ -0,0 +1,15 @@
1
+ //非WhaleAdsMacros定义,但是实际需要用到的参数
2
+ import { getCookie } from "../script/utils"
3
+ const Other = {
4
+ "[device_id]"() {
5
+ return getCookie("deviceid") || getCookie("deviceId")
6
+ },
7
+ "[session_id]"() {
8
+ return (window as any).session_id;
9
+ },
10
+ "[usertag]"() {
11
+ return getCookie("usertag")
12
+ }
13
+ }
14
+
15
+ export { Other }