Created
May 21, 2024 00:20
-
-
Save sagarishere/d60ad61bde18dd4ad85acc06f0f361bd to your computer and use it in GitHub Desktop.
Replace Class Values in Article at Nextjs website
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Replace Class Values in Article at Nextjs website | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description Replace min-w-0 with min-w-10xl and max-w-6xl with max-w-12xl in article tags | |
// @author Sagar Yadav | |
// @match https://nextjs.org/* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
// Function to replace class values | |
function replaceClassValues() { | |
// Get all article elements | |
let articles = document.querySelectorAll('article'); | |
// Iterate over each article element | |
articles.forEach(article => { | |
// Get the current class attribute value | |
let classValue = article.getAttribute('class'); | |
// Replace min-w-0 with min-w-10xl and max-w-6xl with max-w-12xl | |
if (classValue) { | |
classValue = classValue.replace('min-w-0', 'min-w-10xl').replace('max-w-6xl', 'max-w-12xl'); | |
// Update the class attribute with the new value | |
article.setAttribute('class', classValue); | |
} | |
}); | |
} | |
// Run the function to replace class values when the document is fully loaded | |
window.addEventListener('load', replaceClassValues); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In Next.js Docs, article width is too less so the horizontal scroll appears.
The script makes the article have enough width to actually read the code and prevent horizontal scroll, when not necessary.
This increases user-experience.