0

此应用程序的任务是识别 URL(引用链接)并将站点内的电话号码或图像替换为另一个电话号码或图像。例如,如果一个人从站点 A 进入我们的站点,请将我们站点上的电话号码替换为 X ,如果有人从站点 B 进入我们的站点,请将我们站点上的电话号码替换为 Y 。我的代码如下,但它不起作用。请指导我。

安装.json

{
"resources": {
    "body": [{
        "type": "script",
        "src": "./app.js"
    }]
},
    "options": {
        "properties": {
            "referrer": {
                "order": 1,
                "type": "string",
                "title": "The refferer url : "
            },
            "text": {
                "order" : 2,
                "type": "string",
                "title": "Enter the phone number you want to replace",
                "products": ["plus", "pro"]
            },
            "location": {
                "title": "Location",
                "description": "Select the part of your page which contains a Text ( for example : phone number) you’d like to change",
                "type": "object",
                "format": "element",
                "default": {
                    "selector": "body",
                    "method": "prepend"
                  },
                "order": 1
            },
            "slides": {
                "title": "Slides",
                "type": "array",
                "maxItems": 10,
                "order": 2,
                "items": {
                  "type": "object",
                  "title": "Slide",
                  "properties": {
                    "image": {
                      "title": "Image",
                      "type": "string",
                      "order": 1,
                      "format": "image"
                    },
                    "description": {
                      "title": "Description",
                      "description": "This text is used as the image’s title and alt text, important for SEO.",
                      "default": "A wonderful image portraying a better future.",
                      "order": 2,
                      "type": "string",
                      "maxLength": 200
                    }
            }
        }
    }
        }       
    }

应用程序.js

(function () {
'use strict'

var options = INSTALL_OPTIONS
var element

if (document.referrer.trim() == option.refferer.trim()) {

function updateElements () {
 element = INSTALL.createElement(options.location, element);
    if (!element) return
    element.textContent = options.text;
 }

}
}())
4

1 回答 1

0

如果仅适用于您自己的站点,则 Cloudflare 应用程序不是答案。请改为在您的站点上使用 Cloudflare 工作器。

Cloudflare 工作人员可以在用户第一次访问您的站点时将引荐来源网址保存在 cookie 中,然后显示相应的电话号码

于 2019-10-04T11:23:30.557 回答