Welcome to the Adult Content Warning Extension Wiki!

Installation

Follow these steps to install the Adult Content Warning Extension:

  1. Download the Extension: Clone or download the extension files from our GitHub repository.
  2. Load the Extension in Chrome:
    • Open Chrome and navigate to chrome://extensions/.
    • Enable Developer Mode.
    • Click "Load unpacked" and select the downloaded extension directory.
  3. Confirm Installation: The extension should now be active in Chrome.

Usage

After installing the extension, it will automatically scan each website you visit. If it detects the RTA meta tag, indicating adult content, it will display an overlay with a warning message. You can choose to continue on the site or be redirected to Google.

Code Explanation

// Listen for the DOMContentLoaded event, which fires when the page is fully loaded
document.addEventListener('DOMContentLoaded', function () {
    // Query for the RTA meta tag
    var isAdultContent = document.querySelector("meta[name='rating']");

    // Check if the RTA meta tag exists and its content value
    if (isAdultContent && isAdultContent.content === 'RTA-5042-1996-1400-1577-RTA') {
        // Change the background color to black
        document.body.style.backgroundColor = 'black';

        // Create an overlay div element
        var overlay = document.createElement('div');
        overlay.style.position = 'fixed';
        overlay.style.top = '0';
        overlay.style.left = '0';
        overlay.style.height = '100%';
        overlay.style.width = '100%';
        overlay.style.backgroundColor = 'rgba(0, 0, 0, 0.8)';
        overlay.style.zIndex = '1000';
        overlay.style.display = 'flex';
        overlay.style.justifyContent = 'center';
        overlay.style.alignItems = 'center';
        document.body.appendChild(overlay);

        // Create a div for the warning message
        var warningMessage = document.createElement('div');
        warningMessage.innerText = 'This site contains adult content. Do you wish to proceed?';
        warningMessage.style.color = 'white';
        warningMessage.style.fontSize = '30px';
        warningMessage.style.textAlign = 'center';
        warningMessage.style.marginBottom = '20px';
        overlay.appendChild(warningMessage);

        // Create 'Yes' button
        var yesButton = document.createElement('button');
        yesButton.innerText = 'Yes';
        yesButton.style.fontSize = '20px';
        yesButton.style.marginRight = '10px';
        yesButton.onclick = function () {
            overlay.style.display = 'none'; // Hide overlay on click
        };
        overlay.appendChild(yesButton);

        // Create 'No' button
        var noButton = document.createElement('button');
        noButton.innerText = 'No';
        noButton.style.fontSize = '20px';
        noButton.onclick = function () {
            window.location.href = 'https://www.google.com'; // Redirect to Google on click
        };
        overlay.appendChild(noButton);
    }
});

Limitations and Future Improvements

Current limitations of the extension include:

Planned improvements include:

Frequently Asked Questions (FAQ)

Q: Does the extension block adult content?
A: No, it does not block content. It merely warns the user and offers a choice to proceed or redirect.
Q: Can I contribute to the project?
A: Absolutely! Contributions are welcome. You can fork the repository, make changes, and submit a pull request.
Q: Will the extension work on all websites?
A: The extension works on sites that use the RTA meta tag. Its effectiveness on sites without this tag is limited.