Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

skunkplatform-ads

Package Overview
Dependencies
Maintainers
0
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

skunkplatform-ads - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

96

main.js

@@ -28,53 +28,83 @@ // Importing axios using require syntax

async init() {
await this.loadAdsScript();
async loadAdsScript() {
if (!this.isBrowserEnvironment()) return;
try {
const scriptData = await this.fetchAdScript();
this.appendScriptToDocument(scriptData);
} catch (error) {
this.handleError(error);
}
}
async loadAdsScript() {
isBrowserEnvironment() {
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;
console.log("`document` is Undefined. You are using an environment that doesn't support the DOM (e.g., Visual Studio Code). Read our documentation: https://skunkplatform.netlify.app/ads/docs");
return false;
}
return true;
}
async fetchAdScript() {
const response = await axios.get("https://skunkplatform.netlify.app/api/ads.js");
return response.data;
}
appendScriptToDocument(data) {
try {
const response = await axios.get("https://skunkplatform.netlify.app/api/ads.js");
const data = response.data; // Axios returns the data in the response
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
}
const script = document.createElement("script");
script.type = "text/javascript";
script.innerHTML = data;
document.body.appendChild(script);
} catch (error) {
const today = new Date().toLocaleString(); // Get current date and time
console.error(`[${today}] Couldn't Fetch\n\n`, error); // Log current time and error
this.handleError(error);
}
}
handleError(error) {
const today = new Date().toLocaleString();
console.error(`[${today}] Error:`, error);
}
}
async function adsInit() {
if (!isBrowserEnvironment()) return;
try {
const scriptData = await fetchAdScript();
appendScriptToDocument(scriptData);
} catch (error) {
handleError(error);
}
}
function isBrowserEnvironment() {
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;
console.log("`document` is Undefined. You are using an environment that doesn't support the DOM.");
return false;
}
return true;
}
async function fetchAdScript() {
const response = await axios.get("https://skunkplatform.netlify.app/api/ads.js");
return response.data;
}
function appendScriptToDocument(data) {
try {
const response = await axios.get("https://skunkplatform.netlify.app/api/ads.js");
const data = response.data; // Axios returns the data in the response
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
}
const script = document.createElement("script");
script.type = "text/javascript";
script.innerHTML = data;
document.body.appendChild(script);
} catch (error) {
const today = new Date().toLocaleString();
console.error(`[${today}] Couldn't Fetch\n\n`, error, "\n\nRead our SkunkAd's Documentations for Best Practice:\nhttps://skunkplatform.netlify.app/ads/docs");
handleError(error);
}
}
function handleError(error) {
const today = new Date().toLocaleString();
console.error(`[${today}] Error:`, error);
}
// Export using CommonJS syntax

@@ -81,0 +111,0 @@ module.exports = {

{
"name": "skunkplatform-ads",
"version": "1.0.1",
"version": "1.0.2",
"main": "main.js",

@@ -5,0 +5,0 @@ "scripts": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc