调试 Google 广告
This commit is contained in:
Generated
+24
-2
@@ -5,6 +5,8 @@
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="fa3ca596-285f-4ed7-a3a4-7b1482493fd4" name="Changes" comment="测试调用 Google 广告">
|
||||
<change afterPath="$PROJECT_DIR$/docs/docsify-plugin-ads.js" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/docs/index.html" beforeDir="false" afterPath="$PROJECT_DIR$/docs/index.html" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
@@ -15,6 +17,13 @@
|
||||
<component name="ComposerSettings">
|
||||
<execution />
|
||||
</component>
|
||||
<component name="FileTemplateManagerImpl">
|
||||
<option name="RECENT_TEMPLATES">
|
||||
<list>
|
||||
<option value="JavaScript File" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="Git.Settings">
|
||||
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
||||
</component>
|
||||
@@ -62,6 +71,11 @@
|
||||
"vue.rearranger.settings.migration": "true"
|
||||
}
|
||||
}]]></component>
|
||||
<component name="RecentsManager">
|
||||
<key name="MoveFile.RECENT_KEYS">
|
||||
<recent name="D:\WorkDir\iSharkFly\Docs\docsify-docs\docs" />
|
||||
</key>
|
||||
</component>
|
||||
<component name="SharedIndexes">
|
||||
<attachedChunks>
|
||||
<set>
|
||||
@@ -77,7 +91,7 @@
|
||||
<option name="presentableId" value="Default" />
|
||||
<updated>1716613044992</updated>
|
||||
<workItem from="1770483844428" duration="453000" />
|
||||
<workItem from="1770641739752" duration="1579000" />
|
||||
<workItem from="1770641739752" duration="3816000" />
|
||||
</task>
|
||||
<task id="LOCAL-00001" summary="更新編輯按鈕">
|
||||
<option name="closed" value="true" />
|
||||
@@ -103,7 +117,15 @@
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1770644382498</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="4" />
|
||||
<task id="LOCAL-00004" summary="测试调用 Google 广告">
|
||||
<option name="closed" value="true" />
|
||||
<created>1770644466170</created>
|
||||
<option name="number" value="00004" />
|
||||
<option name="presentableId" value="LOCAL-00004" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1770644466170</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="5" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="TypeScriptGeneratedFilesManager">
|
||||
|
||||
@@ -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