1
0
mirror of https://github.com/alexandrev/xslt-lab.git synced 2026-09-20 04:23:16 +00:00

Ads: add placement ID and refresh on interval + transform

- Add id="xsltplayground-main" to EthicalAds div for Placements report
- Refresh ad every 30s via setInterval
- Also refresh on each successful transform (throttled to 30s minimum)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
alexandrev-tibco
2026-04-16 11:29:45 +02:00
parent 02dc29db82
commit 12321a50c0
+15
View File
@@ -295,6 +295,14 @@ export default function App() {
const workspaceImportRef = useRef(null);
const resultResizeState = useRef({ startY: 0, startHeight: MIN_RESULT_HEIGHT });
const paramResizeState = useRef({ startX: 0, startWidth: DEFAULT_PARAM_WIDTH });
const lastAdRefreshRef = useRef(0);
const maybeRefreshAd = () => {
const now = Date.now();
if (now - lastAdRefreshRef.current >= 30_000 && window.ethicalads) {
window.ethicalads.reload();
lastAdRefreshRef.current = now;
}
};
const [resultHeight, setResultHeight] = useState(() => {
try {
const stored = localStorage.getItem(RESULT_HEIGHT_KEY);
@@ -443,6 +451,11 @@ export default function App() {
}
}, [traceCollapsed]);
useEffect(() => {
const id = setInterval(maybeRefreshAd, 30_000);
return () => clearInterval(id);
}, []);
useEffect(() => {
setWorkspaceStatus((prev) => {
let changed = false;
@@ -1024,6 +1037,7 @@ export default function App() {
const data = await res.json();
const defaultView = looksLikeHtml(data.result) ? "render" : "source";
setTransformCount((prev) => prev + 1);
maybeRefreshAd();
updateWorkspaceStatus(tabId, {
result: data.result,
duration: data.duration_ms,
@@ -1344,6 +1358,7 @@ export default function App() {
{ethicalAdsEnabled && (
<div
ref={ethicalSlotRef}
id="xsltplayground-main"
className="ethical-ad-placeholder"
data-ea-publisher={ethicalAdsPublisher}
data-ea-type={ethicalAdType}