macro-parameters 0.0.1

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.
Files changed (3) hide show
  1. package/README.md +0 -0
  2. package/index.js +129 -0
  3. package/package.json +11 -0
package/README.md ADDED
File without changes
package/index.js ADDED
@@ -0,0 +1,129 @@
1
+ const PlaceHolders = {
2
+ "[tv_domain]"() {
3
+ return document.domain
4
+ },
5
+ "[app_name]"() {
6
+ return window.externalMacroParam.app_name;
7
+ },
8
+ "[bundle_id]"() {
9
+ return window.externalMacroParam.bundle_id;
10
+ },
11
+ "[app_store_url]"() {
12
+ return window.externalMacroParam.app_store_url;
13
+ },
14
+ "[src_page_url]"() {
15
+ return encodeURIComponent(getLocationOrigin());
16
+ },
17
+ "[player_height]"() {
18
+ return window.externalMacroParam.player_height;
19
+ },
20
+ "[player_width]"() {
21
+ return window.externalMacroParam.player_width;
22
+ },
23
+ "[channel_no]"() {
24
+ return window.externalMacroParam.channel_no;
25
+ },
26
+ "[channel_category]"() {
27
+ return window.externalMacroParam.channel_category;
28
+ },
29
+ "[whale_ad_id]"() {
30
+ return WhaleADID;
31
+ },
32
+ "[relevant_ads]"() {
33
+ if (isWhaleOSGlobal) {
34
+ return "true"
35
+ }
36
+ var reladvertStatus = false;
37
+ var userAgent = navigator.userAgent.toUpperCase();
38
+ if (userAgent.indexOf("AOC") > -1) {
39
+ reladvertStatus = getCookie("relAdvert");
40
+ } else {
41
+ reladvertStatus = getCookie("relAdvert");
42
+ }
43
+
44
+ reladvertStatus = reladvertStatus == null ? false : reladvertStatus;
45
+ return reladvertStatus;
46
+ },
47
+ "[device_dnt]"() {
48
+ return window.externalMacroParam.device_dnt || (getCookie("relAdvert") == 'true' ? 0 : 1);
49
+ },
50
+ "[tv_brand]"() {
51
+ return getTvBrand();
52
+ },
53
+ "[cntry]"() {
54
+ return countryGlobal;
55
+ },
56
+ "[geo_ip_country]"() {
57
+ return geoIpCountryGlobal;
58
+ },
59
+ "[platform_id]"() {
60
+ return getProfileId();
61
+ },
62
+ "[device_user_agent]"() {
63
+ return encodeURIComponent(UA);
64
+ },
65
+ "[device_ip_address]"() {
66
+ return window.externalMacroParam.device_ip_address;
67
+ },
68
+ "[menu_language]"() {
69
+ if (langGlobal) {
70
+ return (langGlobal.length > 2) ? langGlobal.slice(0, 2) : langGlobal;
71
+ } else {
72
+ return 'un';
73
+ }
74
+ },
75
+ "[privacy_policy]"() {
76
+ return window.externalMacroParam.privacy_policy;
77
+ },
78
+ "[whale_gdpr]"() {
79
+ return window.externalMacroParam.whale_gdpr || (getCookie("relAdvert") == 'true' ? 1 : 0);
80
+ },
81
+ "[whale_gdpr_consent]"() {
82
+ return getCookie("tcString") || getLocalStorage('default_tcString') || tc.tcString;
83
+ },
84
+ "[rnd]"() {
85
+ return new Date().getTime();
86
+ },
87
+ "[ad_sdk_ver]"() {
88
+ return ZeasnADVersion;
89
+ },
90
+ "[time_zone]"() {
91
+ return new Date().getTimezoneOffset();
92
+ },
93
+ "[google_pal]"() {
94
+ if (!window.googleNonce && getCookie("googleNonce")) {
95
+ return getCookie("googleNonce");
96
+ }
97
+ if (window.googleNonce) {
98
+ setCookie("googleNonce", window.googleNonce, new Date(new Date().getTime() + 6 * 60 * 60 * 1000));
99
+ }
100
+ return window.googleNonce || '';
101
+ },
102
+ "[device_lmt]"() {
103
+ return getCookie("relAdvert") === 'true' ? 0 : 1
104
+ },
105
+ "[avod_id]"() {
106
+ return ""
107
+ },
108
+ "[avod_title]"() {
109
+ return ""
110
+ },
111
+ "[device_id]"() {
112
+ return getCookie("deviceid") || getCookie("deviceId")
113
+ },
114
+ "[session_id]"() {
115
+ return window.session_id;
116
+ },
117
+ "[usertag]"() {
118
+ return getCookie("usertag")
119
+ }
120
+ };
121
+ function getLocationOrigin() {
122
+ return (
123
+ location.origin ||
124
+ `${location.protocol}//${location.host || location.hostname}${
125
+ location.port
126
+ }`
127
+ );
128
+ }
129
+ console.log(PlaceHolders);
package/package.json ADDED
@@ -0,0 +1,11 @@
1
+ {
2
+ "name": "macro-parameters",
3
+ "version": "0.0.1",
4
+ "description": "Provide unified macro parameter retrieval",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1"
8
+ },
9
+ "author": "caiyuanjia",
10
+ "license": "ISC"
11
+ }