调试 Google 广告

This commit is contained in:
2026-02-09 11:15:11 -05:00
parent 0292928a25
commit 9d78387fd5
2 changed files with 41 additions and 9 deletions
+14 -6
View File
@@ -4,10 +4,9 @@
<option name="autoReloadType" value="SELECTIVE" />
</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" />
<list default="true" id="fa3ca596-285f-4ed7-a3a4-7b1482493fd4" name="Changes" comment="调试 Google 广告">
<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" />
<change beforePath="$PROJECT_DIR$/docs/docsify-plugin-ads.js" beforeDir="false" afterPath="$PROJECT_DIR$/docs/docsify-plugin-ads.js" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -91,7 +90,7 @@
<option name="presentableId" value="Default" />
<updated>1716613044992</updated>
<workItem from="1770483844428" duration="453000" />
<workItem from="1770641739752" duration="3816000" />
<workItem from="1770641739752" duration="9981000" />
</task>
<task id="LOCAL-00001" summary="更新編輯按鈕">
<option name="closed" value="true" />
@@ -125,7 +124,15 @@
<option name="project" value="LOCAL" />
<updated>1770644466170</updated>
</task>
<option name="localTasksCounter" value="5" />
<task id="LOCAL-00005" summary="调试 Google 广告">
<option name="closed" value="true" />
<created>1770646708279</created>
<option name="number" value="00005" />
<option name="presentableId" value="LOCAL-00005" />
<option name="project" value="LOCAL" />
<updated>1770646708279</updated>
</task>
<option name="localTasksCounter" value="6" />
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
@@ -134,6 +141,7 @@
<component name="VcsManagerConfiguration">
<MESSAGE value="更新編輯按鈕" />
<MESSAGE value="测试调用 Google 广告" />
<option name="LAST_COMMIT_MESSAGE" value="测试调用 Google 广告" />
<MESSAGE value="调试 Google 广告" />
<option name="LAST_COMMIT_MESSAGE" value="调试 Google 广告" />
</component>
</project>
+27 -3
View File
@@ -17,8 +17,11 @@
const scriptID = "_adsense_js";
const sidebarEl = document.querySelector(".sidebar-nav");
if (!adEl && sidebarEl) {
let scriptEl = document.querySelector(`#${scriptID}`);
let scriptIns = document.querySelector(`#${scriptID}`);
let scriptAdPush = document.querySelector(`#${scriptID}`);
if (scriptEl) {
scriptEl = scriptEl.parentNode.removeChild(scriptEl);
@@ -27,10 +30,27 @@
scriptEl.src = `https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=${caPub}`;
scriptEl.async = "async";
scriptEl.id = scriptID;
scriptEl.crossOrigin = "anonymous";
scriptIns = document.createElement("ins");
scriptIns.className = `adsbygoogle`;
scriptIns.style = `display:block`;
scriptIns.setAttribute("data-ad-client", "ca-pub-4797644559430915");
scriptIns.setAttribute("data-ad-slot", "4417932244");
scriptIns.setAttribute("data-ad-format", "auto");
scriptIns.setAttribute("data-full-width-responsive", true);
scriptAdPush = document.createElement("script");
scriptAdPush.text = "(adsbygoogle = window.adsbygoogle || []).push({});";
}
sidebarEl.insertBefore(scriptEl, sidebarEl.firstChild);
sidebarEl.insertBefore(scriptIns, sidebarEl.lastChild);
sidebarEl.insertBefore(scriptAdPush, sidebarEl.lastChild);
}
},
injectCarbonStyle() {
@@ -50,9 +70,13 @@
sans-serif;
}
#carbonads a {
color: inherit;
text-decoration: none;
#carbonads ins {
class="adsbygoogle";
style="display:block";
data-ad-client="ca-pub-4797644559430915";
data-ad-slot="3324230529";
data-ad-format="auto";
data-full-width-responsive="true";
}
#carbonads a:hover {