Fix camwhoresbay.com (IMG and Anchors)

9/11/2023, 10:58:58 PM

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

You will need to install an extension such as Tampermonkey to install this script.

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name        Fix camwhoresbay.com (IMG and Anchors)
// @namespace   Violentmonkey Scripts
// @match       https://www.camwhoresbay.com/*
// @grant       none
// @version     1.0
// @author      -
// @description 9/11/2023, 10:58:58 PM
// @license MIT
// ==/UserScript==

// Find the element to remove using its CSS selector
var elementToRemove = document.querySelector('div.content div#block-chat.block-video div.table');

// Check if the element exists before attempting to remove it
if (elementToRemove) {
  elementToRemove.remove(); // Remove the element from the DOM
} else {
  console.log("Element not found.");
}

// Select all IMG elements
var imgElements = document.querySelectorAll('img');

// Loop through each IMG element
imgElements.forEach(function (img) {

  // Check if the IMG element has a data-original attribute
  if (img.hasAttribute('data-original')) {
    // Get the value of the data-original attribute
    var dataValue = img.getAttribute('data-original');

    // Add "https:" to the data-original value and set it as the src value
    img.setAttribute('src', 'https:' + dataValue);
  }
});

// Select all anchor elements
var anchorElements = document.querySelectorAll('a');

// Loop through each anchor element
anchorElements.forEach(function (anchor) {
  // Check if the anchor element has a data-href attribute
  if (anchor.hasAttribute('data-href')) {
    // Get the value of the data-href attribute
    var dataValue = anchor.getAttribute('data-href');

    // Add "https:" to the data-href value and set it as the href value
    anchor.setAttribute('href', dataValue);
  }
});


// Function to force anchor elements to use the href attribute
function forceHrefUsage(event) {
  event.preventDefault(); // Prevent the default behavior (navigation)
  var href = event.currentTarget.getAttribute('href');
  if (href) {
    // You can perform custom actions here with the href value if needed
    console.log('Using href:', href);
    // You can navigate to the href value programmatically if desired
    window.location.href = href;
  }
}

anchorElements.forEach(function (anchor) {
  anchor.addEventListener('click', forceHrefUsage);
});