I would like different button style for button in div#scrolltop // ==UserScript== //…
- User
I would like different button style for button in div#scrolltop
// ==UserScript== // @name Auto-Rate Posts with Close Handling // @namespace http://tampermonkey.net/ // @version 1.5 // @description Automatically rate posts in a forum thread and handle already rated posts // @author Your Name // @match https://141love.net/* // @grant none // ==/UserScript==
(function() { 'use strict';
// Function to update input values in the rate form and click the correct submit button function updateInputsAndSubmit() { const score1 = document.querySelector('input#score1.px.z'); const score2 = document.querySelector('input#score2.px.z'); const score4 = document.querySelector('input#score4.px.z'); if (score1 && score2 && score4) { // Set the desired values score1.value = 2; score2.value = 20; score4.value = 2; console.log('Values set. Attempting to click the correct submit button.'); // Find and click the correct submit button const submitButton = document.querySelector('button.pn.pnc:not(.z)'); if (submitButton) { setTimeout(() => { submitButton.click(); }, 200); } else { console.log('Submit button not found. Retrying...'); setTimeout(updateInputsAndSubmit, 200); // Retry if the button isn't found } } else { console.log('One or more inputs not found. Retrying...'); setTimeout(updateInputsAndSubmit, 200); } } // Function to close the window if already rated function closeFwinWindow() { const closeButton = document.querySelector('button#closebtn.pn.pnc'); if (closeButton) { console.log('Already rated window detected. Closing it.'); closeButton.click(); } } // Observe changes to detect when a rate form or already rated window is opened const observer = new MutationObserver((mutations) => { mutations.forEach((mutation) => { if (mutation.addedNodes) { mutation.addedNodes.forEach((node) => { if (node.id === 'fwin_rate') { console.log('Rate window detected. Updating inputs...'); setTimeout(updateInputsAndSubmit, 500); } if (node.tagName === 'TABLE' && node.classList.contains('fwin')) { console.log('Already rated window detected. Attempting to close.'); setTimeout(closeFwinWindow, 500); } }); } }); }); function automateRating() { // Find all rate buttons and click them one by one const rateButtons = document.querySelectorAll('a.rateb'); rateButtons.forEach((button, index) => { setTimeout(() => { console.log(`Clicking rate button for post index ${index}`); button.click(); }, index * 1000); // Delay each click by 1 second }); } // Create and append a button for starting the automation function addAutomationButton(container, buttonText, styles) { if (container) { const autoButton = document.createElement('button'); autoButton.innerText = buttonText; autoButton.onclick = automateRating; Object.assign(autoButton.style, styles); container.appendChild(autoButton); } } // Add the automation buttons on page load window.addEventListener('load', () => { const buttonStyles = { backgroundColor: '#FE9500', color: 'white', border: 'none', borderRadius: '4px', padding: '7px 10px', fontSize: '14.5px', cursor: 'pointer', margin: '0px' }; addAutomationButton(document.querySelector('div#pgt.pgs.cl'), '自動評分', buttonStyles); addAutomationButton(document.querySelector('div#scrolltop'), '評分', buttonStyles); // Start observing the document for rate windows observer.observe(document.body, { childList: true, subtree: true }); }); - Assistant
- User
const scrollTopButtonStyles = { backgroundColor: '#F4F4F4', // Change color for the button in #scrolltop color: '#BBBBBB', // Text color borderTop: '1px solid #BBBBBB', borderLeft: '0px solid #BBBBBB', borderBottom: '0px solid #BBBBBB', borderRight: '0px solid #BBBBBB', borderRadius: '0px', padding: '7px 10px', fontSize: '11px', cursor: 'pointer', margin: '0px' };
How do I bold the font?
- Assistant
To make the font bold in CSS, you can set the
fontWeightproperty of your button's style object. You can addfontWeight: 'bold'to yourscrollTopButtonStylesobject.Here's how you can modify your
scrollTopButtonStyles:const scrollTopButtonStyles = { backgroundColor: '#F4F4F4', // Change color for the button in #scrolltop color: '#BBBBBB', // Text color borderTop: '1px solid #BBBBBB', borderLeft: '0px solid #BBBBBB', borderBottom: '0px solid #BBBBBB', borderRight: '0px solid #BBBBBB', borderRadius: '0px', padding: '7px 10px', fontSize: '11px', fontWeight: 'bold', // Set font weight to bold cursor: 'pointer', margin: '0px' };With
fontWeight: 'bold'added, the text in the button will be bold. This is how the complete style looks with the bold font included. - User
How do I change the orientation of the title to horizontal?
- Assistant
If by "change the orientation of the title to horizontal," you mean that you want to ensure that the text appears horizontally (which is the default behavior for text in HTML), you don't need to make any changes since all text is typically rendered horizontally by default.
- User
const scrollTopButtonStyles = { backgroundColor: '#F4F4F4', // Change color for the button in #scrolltop color: '#BBBBBB', // Text color borderTop: '1px solid #BBBBBB', borderLeft: '0px solid #BBBBBB', borderBottom: '0px solid #BBBBBB', borderRight: '0px solid #BBBBBB', borderRadius: '0px', padding: '7px 10px', fontSize: '11px', fontWeight: 'bold', // Set font weight to bold cursor: 'pointer', margin: '0px' };
How do I change the orientation of the chinese characters in this button?
- Assistant
- User
- Assistant