wordpress插件JS禁用

wordpress plugin JS disable

我试图让这个 wordpress 插件(DRIFT 网络聊天)在工作时间之外消失,所以它会在 09:00am(格林威治标准时间)和 17:00PM(格林威治标准时间)的时间显示,但我不能似乎可以正常工作!

<script> var enableDisable = function(){var GMT_hours = new Date().getGMTHours() ;
    if (GMT_hours > 08 && GMT_hours < 16){
        document.getElementById('checktime').disabled = false;
    }
    else
    {
        document.getElementById('checktime').disabled = true;} }; setInterval(enableDisable, 1000*60); enableDisable(); var t = window.driftt = window.drift = window.driftt || [];if (!t.init) {
    if (t.invoked) return void (window.console && console.error && console.error("Drift snippet included twice."));
    t.invoked = !0, t.methods = [ "identify", "config", "track", "reset" "debug", "show", "ping", "page", "hide", "off", "on" ], 
    t.factory = function(e) {
      return function() {
        var n = Array.prototype.slice.call(arguments);
        return n.unshift(e), t.push(n), t;
      };
    }, t.methods.forEach(function(e) {
      t[e] = t.factory(e);
    }), t.load = function(t) {
      var e = 3e5, n = Math.ceil(new Date() / e) * e, o = document.createElement("script");
      o.type = "text/javascript", o.async = !0, o.crossorigin = "anonymous", o.src = "https://js.driftt.com/include/" + n + "/" + t + ".js";
      var i = document.getElementsByTagName("script")[0];
      i.parentNode.insertBefore(o, i);};} }(); drift.SNIPPET_VERSION = '0.3.1'; drift.load('n72gzwytbesr');
</script>

请帮忙! 如果有帮助,下面是一些屏幕截图...

这是DRIFT直接给出的代码...

<!-- Start of Async Drift Code --> 
<script> "use strict"; !function() { var t = window.driftt = window.drift = window.driftt || []; if (!t.init) {
if (t.invoked) return void (window.console && console.error && console.error("Drift snippet included twice."));
t.invoked = !0, t.methods = [ "identify", "config", "track", "reset", "debug", "show", "ping", "page", "hide", "off", "on" ], 
t.factory = function(e) {
  return function() {
    var n = Array.prototype.slice.call(arguments);
    return n.unshift(e), t.push(n), t;
  };
}, t.methods.forEach(function(e) {
  t[e] = t.factory(e);
}), t.load = function(t) {
  var e = 3e5, n = Math.ceil(new Date() / e) * e, o = document.createElement("script");
  o.type = "text/javascript", o.async = !0, o.crossorigin = "anonymous", o.src = "https://js.driftt.com/include/" + n + "/" + t + ".js";
  var i = document.getElementsByTagName("script")[0];
  i.parentNode.insertBefore(o, i); }; } }();drift.SNIPPET_VERSION = '0.3.1'; drift.load('n72gzwytbesr');
</script>
<!-- End of Async Drift Code -->

虽然可以仅使用 javascript 来执行此操作,但使用 PHP.

会更容易

在插件文件 includes/embed.php 中更改为:

        echo "<!-- Start Drift By WP-Plugin: Drift -->\n";
    echo $drift_tag;
    echo"<!-- end: Drift Code. -->\n";

对此:

      if(date("Hi") < 1700 && date("Hi") > 900){
    echo "<!-- Start Drift By WP-Plugin: Drift -->\n";
    echo $drift_tag;
    echo"<!-- end: Drift Code. -->\n";}

这将完全阻止任何其他 JS 从 Drift 中嵌入,而不是简单地不加载嵌入但仍然加载 JS。