macro-parameters 0.0.9 → 0.0.10
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.d.ts +5 -0
- package/index.js +1 -1
- package/package.json +17 -17
- package/src/main.ts +5 -6
- package/src/replace.ts +2 -2
- package/type/app.ts +9 -6
- package/type/content.ts +11 -11
- package/type/gdpr.ts +1 -1
package/index.d.ts
ADDED
package/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var n=function(){return n=Object.assign||function(n){for(var e,t=1,o=arguments.length;t<o;t++)for(var r in e=arguments[t])Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n},n.apply(this,arguments)};function e(n){var e,t=new RegExp("(^| )"+n+"=([^;]*)(;|$)");return(e=(document.cookie||window.localStorage&&window.localStorage.cookie||"").match(t))?unescape(e[2]):""}function t(n){var e=window.externalMacroParam;return e&&"object"==typeof e&&e.hasOwnProperty(n)?e[n]:""}"function"==typeof SuppressedError&&SuppressedError;var o={"[whale_ad_id]":function(){},"[tv_brand]":function(){return function(){if(localStorage.getItem("brand"))return localStorage.getItem("brand");var n=navigator.userAgent.toUpperCase();return n.indexOf("AOC")>-1?"aoc":n.indexOf("PHILIPS")>-1?"philips":"others"}()},"[cntry]":function(){},"[geo_ip_country]":function(){},"[platform_id]":function(){return(n=e("profileid")||e("profileId"))&&""!=n?n.split("_")[1]:"Unknown";var n},"[device_user_agent]":function(){var n=navigator.userAgent;return encodeURIComponent(n)},"[device_ip_address]":function(){return t("device_ip_address")},"[menu_language]":function(){var n=navigator.language;return n?n.length>2?n.slice(0,2):n:"un"},"[time_zone]":function(){return(new Date).getTimezoneOffset()}},r={"[whale_gdpr]":function(){return t("whale_gdpr")||("true"==e("relAdvert")?1:0)},"[whale_gdpr_consent]":function(){return e("tcString")||(n="default_tcString","object"==typeof localStorage?localStorage.getItem(n):null);var n},"[relevant_ads]":function(){var n="false";return n=null==(n=(navigator.userAgent.toUpperCase().indexOf("AOC"),e("relAdvert")))?"false":n},"[device_dnt]":function(){return t("device_dnt")||("true"==e("relAdvert")?0:1)},"[device_lmt]":function(){return"true"===e("relAdvert")?0:1},"[privacy_policy]":function(){}},i={"[rnd]":function(){return(new Date).getTime()},"[timestamp]":function(){return(new Date).getTime()},"[ad_sdk_ver]":function(){return""},"[google_pal]":function(){return!window.googleNonce&&e("googleNonce")?e("googleNonce"):(window.googleNonce&&(n="googleNonce",t=window.googleNonce,o=new Date((new Date).getTime()+216e5),r=n+"="+escape(t)+(o?";expires="+o.toGMTString():""),document.cookie=r),window.googleNonce||"");var n,t,o,r}},a={"[device_id]":function(){return e("deviceid")||e("deviceId")},"[session_id]":function(){return window.session_id},"[usertag]":function(){return e("usertag")}};var c=n(n(n(n(n(n({},{"[tv_domain]":function(){return document.domain},"[app_name]":function(){},"[bundle_id]":function(){},"[app_store_url]":function(){},"[src_page_url]":function(){return encodeURIComponent(location.origin||"".concat(location.protocol,"//").concat(location.host||location.hostname).concat(location.port))},"[player_height]":function(){},"[player_width]":function(){},"[placement]":function(){},"[app_store]":function(){return t("app_store")||"Zeasn"}}),{"[provider_id]":function(){},"[channel_no]":function(){},"[channel_category]":function(){},"[channel_name]":function(){},"[iab_category]":function(){},"[avod_id]":function(){},"[avod_genre]":function(){},"[avod_title]":function(){},"[oriented_age]":function(){},"[oriented_gender]":function(){},"[ssai_vendor]":function(){}}),o),r),i),a),u=function(){function n(){this.params={}}return n.prototype.set=function(n){if(n)for(var e in n)n.hasOwnProperty(e)&&(this.params[e]=n[e]);else console.log("Invalid settings")},n.prototype.handle=function(n){return function(n,e){for(var t in c){var o=t.replace("[","\\[").replace("]","\\]"),r=t.replace("[","").replace("]","");n=n.replace(new RegExp(o,"g"),e[r]||c[t]()||"")}return i=/\[.*?\]/g,n.replace(i,"");var i}(n,this.params)},n}();export{u as MacroSubstitution};
|
package/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "macro-parameters",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "Provide unified macro parameter retrieval",
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"build": "rollup --config rollup.config.ts --configPlugin typescript2"
|
|
8
|
-
},
|
|
9
|
-
"author": "caiyuanjia",
|
|
10
|
-
"license": "ISC",
|
|
11
|
-
"devDependencies": {
|
|
12
|
-
"@rollup/plugin-terser": "^0.4.4",
|
|
13
|
-
"rollup": "^4.22.4",
|
|
14
|
-
"rollup-plugin-typescript2": "^0.36.0",
|
|
15
|
-
"typescript": "^5.5.4"
|
|
16
|
-
}
|
|
17
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "macro-parameters",
|
|
3
|
+
"version": "0.0.10",
|
|
4
|
+
"description": "Provide unified macro parameter retrieval",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"build": "rollup --config rollup.config.ts --configPlugin typescript2"
|
|
8
|
+
},
|
|
9
|
+
"author": "caiyuanjia",
|
|
10
|
+
"license": "ISC",
|
|
11
|
+
"devDependencies": {
|
|
12
|
+
"@rollup/plugin-terser": "^0.4.4",
|
|
13
|
+
"rollup": "^4.22.4",
|
|
14
|
+
"rollup-plugin-typescript2": "^0.36.0",
|
|
15
|
+
"typescript": "^5.5.4"
|
|
16
|
+
}
|
|
17
|
+
}
|
package/src/main.ts
CHANGED
|
@@ -8,24 +8,23 @@ class MacroSubstitution {
|
|
|
8
8
|
this.params = {}
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
set(params: object) {
|
|
11
|
+
set(params: object): void {
|
|
12
12
|
if (!params) {
|
|
13
13
|
console.log("Invalid settings");
|
|
14
14
|
return;
|
|
15
15
|
}
|
|
16
16
|
for (let key in params) {
|
|
17
17
|
if (params.hasOwnProperty(key)) {
|
|
18
|
-
console.log(key + ": " + params[key]);
|
|
19
18
|
this.params[key] = params[key];
|
|
20
19
|
}
|
|
21
20
|
}
|
|
22
21
|
}
|
|
23
22
|
|
|
24
|
-
handle(str: string) {
|
|
25
|
-
console.log(cleanPlaceholder(str, this.params));
|
|
26
|
-
console.log(this.params)
|
|
23
|
+
handle(str: string): string {
|
|
27
24
|
return cleanPlaceholder(str, this.params)
|
|
28
25
|
}
|
|
29
26
|
|
|
30
27
|
}
|
|
31
|
-
export
|
|
28
|
+
export {
|
|
29
|
+
MacroSubstitution
|
|
30
|
+
}
|
package/src/replace.ts
CHANGED
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
Generic,
|
|
7
7
|
Other
|
|
8
8
|
} from "../type";
|
|
9
|
-
export function cleanPlaceholder(str: string, params: object) {
|
|
9
|
+
export function cleanPlaceholder(str: string, params: object): string {
|
|
10
10
|
for (let k in PlaceHolders) {
|
|
11
11
|
let param = k.replace('[', '\\[').replace(']', '\\]');
|
|
12
12
|
let paramName = k.replace('[', '').replace(']', '');
|
|
@@ -15,7 +15,7 @@ export function cleanPlaceholder(str: string, params: object) {
|
|
|
15
15
|
return replaceEmpty(str);
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
function replaceEmpty(content: string) {
|
|
18
|
+
function replaceEmpty(content: string): string {
|
|
19
19
|
const reg = /\[.*?\]/g;
|
|
20
20
|
return content.replace(reg, "")
|
|
21
21
|
}
|
package/type/app.ts
CHANGED
|
@@ -7,25 +7,28 @@ const App = {
|
|
|
7
7
|
return document.domain
|
|
8
8
|
},
|
|
9
9
|
"[app_name]"() {
|
|
10
|
-
return getExternalMacroParam("app_name");
|
|
10
|
+
// return getExternalMacroParam("app_name");
|
|
11
11
|
},
|
|
12
12
|
"[bundle_id]"() {
|
|
13
|
-
return getExternalMacroParam("bundle_id");
|
|
13
|
+
// return getExternalMacroParam("bundle_id");
|
|
14
14
|
},
|
|
15
15
|
"[app_store_url]"() {
|
|
16
|
-
return getExternalMacroParam("app_store_url");
|
|
16
|
+
// return getExternalMacroParam("app_store_url");
|
|
17
17
|
},
|
|
18
18
|
"[src_page_url]"() {
|
|
19
19
|
return encodeURIComponent(getLocationOrigin());
|
|
20
20
|
},
|
|
21
21
|
"[player_height]"() {
|
|
22
|
-
return getExternalMacroParam("player_height");
|
|
22
|
+
// return getExternalMacroParam("player_height");
|
|
23
23
|
},
|
|
24
24
|
"[player_width]"() {
|
|
25
|
-
return getExternalMacroParam("player_width");
|
|
25
|
+
// return getExternalMacroParam("player_width");
|
|
26
26
|
},
|
|
27
27
|
"[placement]"() {
|
|
28
|
-
return getExternalMacroParam("placement");
|
|
28
|
+
// return getExternalMacroParam("placement");
|
|
29
|
+
},
|
|
30
|
+
"[app_store]"(){
|
|
31
|
+
return getExternalMacroParam("app_store") || "Zeasn";
|
|
29
32
|
}
|
|
30
33
|
};
|
|
31
34
|
export { App }
|
package/type/content.ts
CHANGED
|
@@ -2,37 +2,37 @@
|
|
|
2
2
|
import { getExternalMacroParam } from "../script/utils"
|
|
3
3
|
const Content = {
|
|
4
4
|
"[provider_id]"() {
|
|
5
|
-
return getExternalMacroParam("provider_id");
|
|
5
|
+
// return getExternalMacroParam("provider_id");
|
|
6
6
|
},
|
|
7
7
|
"[channel_no]"() {
|
|
8
|
-
return getExternalMacroParam("channel_no");
|
|
8
|
+
// return getExternalMacroParam("channel_no");
|
|
9
9
|
},
|
|
10
10
|
"[channel_category]"() {
|
|
11
|
-
return getExternalMacroParam("channel_category");
|
|
11
|
+
// return getExternalMacroParam("channel_category");
|
|
12
12
|
},
|
|
13
13
|
"[channel_name]"() {
|
|
14
|
-
return getExternalMacroParam("channel_category");
|
|
14
|
+
// return getExternalMacroParam("channel_category");
|
|
15
15
|
},
|
|
16
16
|
"[iab_category]"() {
|
|
17
|
-
return getExternalMacroParam("iab_category");
|
|
17
|
+
// return getExternalMacroParam("iab_category");
|
|
18
18
|
},
|
|
19
19
|
"[avod_id]"() {
|
|
20
|
-
return getExternalMacroParam("avod_id");
|
|
20
|
+
// return getExternalMacroParam("avod_id");
|
|
21
21
|
},
|
|
22
22
|
"[avod_genre]"() {
|
|
23
|
-
return getExternalMacroParam("avod_genre");
|
|
23
|
+
// return getExternalMacroParam("avod_genre");
|
|
24
24
|
},
|
|
25
25
|
"[avod_title]"() {
|
|
26
|
-
return getExternalMacroParam("avod_title");
|
|
26
|
+
// return getExternalMacroParam("avod_title");
|
|
27
27
|
},
|
|
28
28
|
"[oriented_age]"() {
|
|
29
|
-
return getExternalMacroParam("oriented_age");
|
|
29
|
+
// return getExternalMacroParam("oriented_age");
|
|
30
30
|
},
|
|
31
31
|
"[oriented_gender]"() {
|
|
32
|
-
return getExternalMacroParam("oriented_gender");
|
|
32
|
+
// return getExternalMacroParam("oriented_gender");
|
|
33
33
|
},
|
|
34
34
|
"[ssai_vendor]"() {
|
|
35
|
-
return getExternalMacroParam("ssai_vendor");
|
|
35
|
+
// return getExternalMacroParam("ssai_vendor");
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
export { Content }
|