diff --git a/Existing_API_Collection/Dog-API/Dog.png b/Existing_API_Collection/Dog-API/Dog.png new file mode 100644 index 0000000..8247062 Binary files /dev/null and b/Existing_API_Collection/Dog-API/Dog.png differ diff --git a/Existing_API_Collection/Dog-API/Dogs.jpg b/Existing_API_Collection/Dog-API/Dogs.jpg new file mode 100644 index 0000000..82c5768 Binary files /dev/null and b/Existing_API_Collection/Dog-API/Dogs.jpg differ diff --git a/Existing_API_Collection/Dog-API/index.html b/Existing_API_Collection/Dog-API/index.html new file mode 100644 index 0000000..e11a9d6 --- /dev/null +++ b/Existing_API_Collection/Dog-API/index.html @@ -0,0 +1,40 @@ + + + + + + + Random Dog + + +
+

Loading...

+
+ + + diff --git a/Existing_API_Collection/Dog-API/manifest.json b/Existing_API_Collection/Dog-API/manifest.json new file mode 100644 index 0000000..75c5f0a --- /dev/null +++ b/Existing_API_Collection/Dog-API/manifest.json @@ -0,0 +1,12 @@ +{ + "name": "Dog facts", + "version": "0.0.1", + "manifest_version": 2, + "browser_action": { + "default_popup": "index.html", + "default_icon": "Dog.png" + }, + "icons": { + "128": "Dog.png" + } +} \ No newline at end of file diff --git a/Existing_API_Collection/Dog-API/readme.md b/Existing_API_Collection/Dog-API/readme.md new file mode 100644 index 0000000..8b8ca1e --- /dev/null +++ b/Existing_API_Collection/Dog-API/readme.md @@ -0,0 +1,40 @@ +# Random Dog Facts Extension + +This extension generates a random dog fact whenever it is clicked. + +## Installation Instructions + +1. **Open your browser**: Launch your preferred web browser (e.g., Chrome, Edge). + +2. **Enable Developer Mode**: + - Navigate to the extensions page. You can typically do this by typing `chrome://extensions/` in the address bar for Chrome or `edge://extensions/` for Edge. + - Toggle the **Developer mode** switch in the top right corner of the extensions page. + +3. **Load the Extension**: + - Click on the **Load unpacked** button. + - In the file dialog that appears, navigate to the directory where your project files are located and select the folder containing `manifest.json`. + +4. **Activate the Extension**: + - After loading the extension, an icon will appear in the extensions toolbar. + - Click on this icon to generate and view a random dog fact. + +## Screenshot + +Here is what the extension looks like when activated: + +![Random Dog Facts Extension Screenshot](screenshot.jpg) + +## Project Structure + +- `manifest.json`: The manifest file that contains metadata about the extension. +- `index.html`: The HTML file for the extension's popup interface. +- `script.js`: The JavaScript file that handles the logic to fetch and display random dog facts. + +## Additional Information + +- Ensure all necessary files (`manifest.json`, `index.html`, `script.js`, and any additional assets) are in the same directory. +- If you make any changes to the code, you will need to reload the extension by clicking the reload icon next to the extension on the extensions page. + +--- + +Enjoy your random dog facts! diff --git a/Existing_API_Collection/Dog-API/screenshot.jpg b/Existing_API_Collection/Dog-API/screenshot.jpg new file mode 100644 index 0000000..3e7d626 Binary files /dev/null and b/Existing_API_Collection/Dog-API/screenshot.jpg differ diff --git a/Existing_API_Collection/Dog-API/script.js b/Existing_API_Collection/Dog-API/script.js new file mode 100644 index 0000000..61e9da0 --- /dev/null +++ b/Existing_API_Collection/Dog-API/script.js @@ -0,0 +1,10 @@ +document.addEventListener('DOMContentLoaded', () => { + fetch('https://dogapi.dog/api/v2/facts') + .then(response => response.json()) + .then(DogData => { + const DogText = DogData.data[0].attributes.body; + const DogElement = document.getElementById('DogElement'); + DogElement.innerHTML = DogText; + }) + .catch(error => console.error('Error fetching the Dog:', error)); +});