skunkplatform-ads
Advanced tools
Comparing version 1.0.0 to 1.0.1
43
main.js
@@ -1,2 +0,2 @@ | ||
// Importing axios using require | ||
// Importing axios using require syntax | ||
const axios = require('axios'); | ||
@@ -8,3 +8,3 @@ | ||
- Used: | ||
Node.js | ||
CommonJS · Node.js | ||
- Example Usage: | ||
@@ -34,9 +34,18 @@ // Use this Example | ||
async loadAdsScript() { | ||
if (typeof document === 'undefined') { | ||
console.log("`document` is Undefined. You are using an environment that doesn't support the DOM (e.g., Visual Studio Code) using Terminal will not be executed this variable.\nThe `document` requires in the Website for Google Cloud, Github Pages, Netlify, Namecheap Domain, etc.\nRead the Best of Pratice by Documentations: https://skunkplatform.netlify.app/ads/docs"); | ||
return; | ||
} | ||
try { | ||
const response = await axios.get("https://skunkplatform.netlify.app/api/ads.js"); | ||
const data = response.data; // Axios returns the data in the response | ||
const script = document.createElement("script"); | ||
script.type = "text/javascript"; | ||
script.innerHTML = data; // Set the fetched script content | ||
document.body.appendChild(script); // Append the script to the body | ||
try { | ||
const script = document.createElement("script"); | ||
script.type = "text/javascript"; | ||
script.innerHTML = data; // Set the fetched script content | ||
document.body.appendChild(script); // Append the script to the body | ||
} catch (error) { | ||
const today = new Date().toLocaleString(); // Get current date and time | ||
console.error(`[${today}] Couldn't Add the Script\n\n`, error, "\n\nRead our SkunkAd's Documentations for Best Practice:\nhttps://skunkplatform.netlify.app/ads/docs"); // Log current time and error | ||
} | ||
} catch (error) { | ||
@@ -47,12 +56,21 @@ const today = new Date().toLocaleString(); // Get current date and time | ||
} | ||
}; | ||
} | ||
async function adsInit() { | ||
if (typeof document === 'undefined') { | ||
console.log("`document` is Undefined. You are using an environment that doesn't support the DOM (e.g., Visual Studio Code) using Terminal will not be executed this variable.\nThe `document` requires in the Website for Google Cloud, Github Pages, Netlify, Namecheap Domain, etc.\nRead the Best of Pratice by Documentations: https://skunkplatform.netlify.app/ads/docs"); | ||
return; | ||
} | ||
try { | ||
const response = await axios.get("https://skunkplatform.netlify.app/api/ads.js"); | ||
const data = response.data; // Axios returns the data in the response | ||
const script = document.createElement("script"); | ||
script.type = "text/javascript"; | ||
script.innerHTML = data; | ||
document.body.appendChild(script); | ||
try { | ||
const script = document.createElement("script"); | ||
script.type = "text/javascript"; | ||
script.innerHTML = data; // Set the fetched script content | ||
document.body.appendChild(script); // Append the script to the body | ||
} catch (error) { | ||
const today = new Date().toLocaleString(); // Get current date and time | ||
console.error(`[${today}] Couldn't Add the Script\n\n`, error, "\n\nRead our SkunkAd's Documentations for Best Practice:\nhttps://skunkplatform.netlify.app/ads/docs"); // Log current time and error | ||
} | ||
} catch (error) { | ||
@@ -64,5 +82,6 @@ const today = new Date().toLocaleString(); | ||
// Export using CommonJS syntax | ||
module.exports = { | ||
Client, | ||
adsInit | ||
} | ||
}; |
{ | ||
"name": "skunkplatform-ads", | ||
"version": "1.0.0", | ||
"main": "index.js", | ||
"dependencies": { | ||
"axios": "^1.7.8" | ||
}, | ||
"version": "1.0.1", | ||
"main": "main.js", | ||
"scripts": { | ||
@@ -14,3 +11,7 @@ "test": "echo \"Error: no test specified\" && exit 1" | ||
"license": "MIT", | ||
"description": "SkunkAds is an API for Advertisement." | ||
"description": "SkunkAds is an API for Advertisement.", | ||
"type": "commonjs", | ||
"dependencies": { | ||
"axios": "^1.7.8" | ||
} | ||
} |
@@ -16,3 +16,3 @@ # SkunkAds | ||
```bash | ||
npm i skunkplatform-ads@1.0.0 # For Node.js | ||
npm i skunkplatform-ads@1.0.1 # For Node.js (Fixed for the Main File Package) | ||
``` | ||
@@ -19,0 +19,0 @@ |
6838
5
98