|
@@ -1,6 +1,25 @@
|
|
|
var _hmt = _hmt || [];
|
|
|
var advUrl = window.location.href;
|
|
|
|
|
|
+// 判断是否已加载 head.js
|
|
|
+function isHeadJSLoaded() {
|
|
|
+ var scripts = document.getElementsByTagName('script');
|
|
|
+ for (var i = 0; i < scripts.length; i++) {
|
|
|
+ if (scripts[i].src.indexOf('/common-module/public/head.js') !== -1) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+}
|
|
|
+
|
|
|
+// 如果未加载 head.js,则通过 append 添加
|
|
|
+if (!isHeadJSLoaded()) {
|
|
|
+ const scriptElement = document.createElement('script');
|
|
|
+ scriptElement.src = '/common-module/public/head.js';
|
|
|
+ scriptElement.defer = true;
|
|
|
+ document.head.appendChild(scriptElement);
|
|
|
+}
|
|
|
+
|
|
|
// 原业务,百度SDK已迁移到Head
|
|
|
if (is_weixin()) {
|
|
|
if (window.location.pathname.indexOf("/article/content/") > -1) {
|
|
@@ -111,3 +130,4 @@ function grafana_statistics(advName) {
|
|
|
}
|
|
|
|
|
|
|
|
|
+
|