调试 Google 广告
This commit is contained in:
@@ -0,0 +1,105 @@
|
||||
(function(window) {
|
||||
window.DocsifyAds = {
|
||||
create(caPub) {
|
||||
return function(hook, vm) {
|
||||
hook.ready(function() {
|
||||
window.DocsifyAds.injectCarbonStyle();
|
||||
});
|
||||
|
||||
hook.doneEach(function() {
|
||||
window.DocsifyAds.injectScript(caPub);
|
||||
});
|
||||
};
|
||||
},
|
||||
|
||||
injectScript(caPub) {
|
||||
const adEl = document.querySelector("#adsense");
|
||||
const scriptID = "_adsense_js";
|
||||
const sidebarEl = document.querySelector(".sidebar-nav");
|
||||
|
||||
if (!adEl && sidebarEl) {
|
||||
let scriptEl = document.querySelector(`#${scriptID}`);
|
||||
|
||||
if (scriptEl) {
|
||||
scriptEl = scriptEl.parentNode.removeChild(scriptEl);
|
||||
} else {
|
||||
scriptEl = document.createElement("script");
|
||||
scriptEl.src = `https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=${caPub}`;
|
||||
scriptEl.async = "async";
|
||||
scriptEl.id = scriptID;
|
||||
}
|
||||
|
||||
sidebarEl.insertBefore(scriptEl, sidebarEl.firstChild);
|
||||
}
|
||||
},
|
||||
|
||||
injectCarbonStyle() {
|
||||
const styleEl = document.createElement("style");
|
||||
|
||||
styleEl.textContent = `
|
||||
#carbonads * {
|
||||
margin: initial;
|
||||
padding: initial;
|
||||
}
|
||||
|
||||
#carbonads {
|
||||
max-width: 330px;
|
||||
background-color: #fafafa;
|
||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
|
||||
Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", Helvetica, Arial,
|
||||
sans-serif;
|
||||
}
|
||||
|
||||
#carbonads a {
|
||||
color: inherit;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
#carbonads a:hover {
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
#carbonads span {
|
||||
display: block;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
#carbonads .carbon-wrap {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
#carbonads .carbon-img img {
|
||||
display: block;
|
||||
}
|
||||
|
||||
#carbonads .carbon-text {
|
||||
align-self: center;
|
||||
margin-bottom: 20px;
|
||||
padding: 8px 10px;
|
||||
font-size: 12px;
|
||||
line-height: 1.5;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
#carbonads .carbon-poweredby {
|
||||
display: block;
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
padding: 6px 8px;
|
||||
border-top-left-radius: 3px;
|
||||
background-color: #f1f1f1;
|
||||
font-size: 8px;
|
||||
font-weight: 600;
|
||||
line-height: 1;
|
||||
letter-spacing: 0.5px;
|
||||
text-align: center;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
`;
|
||||
|
||||
document.head.insertBefore(styleEl, document.querySelector("head style, head link[rel*='stylesheet']"));
|
||||
},
|
||||
};
|
||||
})(window);
|
||||
+4
-2
@@ -43,9 +43,10 @@
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div id="app">Loading ...</div>
|
||||
<script src="//cdn.jsdelivr.net/npm/docsify-plugin-carbon@1"></script>
|
||||
<script src="//cdn.jsdelivr.net/npm/docsify-plugin-adsense@1/index.min.js"></script>
|
||||
<script src="docsify-plugin-ads.js"></script>
|
||||
<script>
|
||||
// Set html "lang" attribute based on URL
|
||||
var lang = location.hash.match(/#\/(de-de|es|ru-ru|zh-cn)\//);
|
||||
@@ -159,7 +160,8 @@
|
||||
},
|
||||
},
|
||||
plugins: [
|
||||
DocsifyAds.create('pub-4797644559430915'),
|
||||
DocsifyAds.create('ca-pub-4797644559430915'),
|
||||
|
||||
function (hook, vm) {
|
||||
hook.beforeEach(function (html) {
|
||||
if (/githubusercontent\.com/.test(vm.route.file)) {
|
||||
|
||||
Reference in New Issue
Block a user