Bitcoin Forum
October 06, 2024, 03:18:01 PM *
News: Latest Bitcoin Core release: 28.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Help me test something?  (Read 159 times)
PowerGlove (OP)
Hero Member
*****
hacker
Offline Offline

Activity: 583
Merit: 4998



View Profile
September 16, 2024, 06:08:01 AM
Merited by Cyrus (1), garlonicon (1), Learn Bitcoin (1)
 #1

Hey, everybody! Smiley

A while ago, I did a patch to add a "Copy" button to [code] blocks. Thinking about it a little more, I think a "[Select]" link (like the one I've seen in later SMF versions) might actually make more sense...

After coming up with my own implementation of this, I took a peek at what the SMF devs did for 2.x and noticed that they're special-casing things for different browsers. I'd like to know if that special-casing is still necessary these days, so I'd appreciate some help with testing this on different browsers.

Basically, go to any forum page that contains [code] blocks (like the page you're currently on), and then open up the developer console in your browser and paste/run the following code:

Code:
function addSelectionLinksToCodeBlocks() {

    const allCodeDivs = document.querySelectorAll("div.codeheader + div.code");

    for (const codeDiv of allCodeDivs) {

        const codeHeaderDiv = codeDiv.previousElementSibling;

        if (!codeHeaderDiv.querySelector("a.selectionLink")) {

            const selectionLink = document.createElement("a");

            selectionLink.onclick = () => {

                const range = document.createRange();

                const selection = document.getSelection();

                range.selectNodeContents(codeDiv);

                selection.removeAllRanges();

                selection.addRange(range);

                return false;
            };

            selectionLink.className = "selectionLink";

            selectionLink.href = "javascript:void(0);";

            selectionLink.textContent = "[Select]";

            codeHeaderDiv.appendChild(document.createTextNode(" "));

            codeHeaderDiv.appendChild(selectionLink);
        }
    }
}

addSelectionLinksToCodeBlocks();

(Make sure to copy it in its entirety and to hit enter after pasting it.)

You should now see that each [code] block has a little "[Select]" link at the top. Click on that link and check if the code for that block gets correctly selected or not.

If it doesn't work for you, then please post your browser details (just the name and version will do).

If you have thoughts about preferring the "[Select]" link to the "Copy" button (or vice versa), feel free to leave those, too.

Thanks.

(I'm not really looking for code critiques. If you're a programmer and something looks odd to you, probably I'm either sticking to some established SMF 1.x idiom, or it's because I had to write this code in a particular way to get Cloudflare's WAF to stop blocking me from posting it.)
Learn Bitcoin
Hero Member
*****
Offline Offline

Activity: 672
Merit: 988


Vires in numeris


View Profile WWW
September 16, 2024, 06:11:37 AM
Merited by PowerGlove (1)
 #2

It worked like a charm for me.
I guess you don't need my browser details since it worked. But I am using Microsoft Edge.
I have been seeing this feature on another forum. Since then, I was wondering if this forum can add this feature, to help users copy pasting the codes correctly. Mostly the signature participants can't copy paste the code in mobile device. Well done.


▄▄███████▄▄
▄██████████████▄
▄██████████████████▄
▄████▀▀▀▀███▀▀▀▀█████▄
▄█████████████▄█▀████▄
███████████▄███████████
██████████▄█▀███████████
██████████▀████████████
▀█████▄█▀█████████████▀
▀████▄▄▄▄███▄▄▄▄████▀
▀██████████████████▀
▀███████████████▀
▀▀███████▀▀
.
 MΞTAWIN  THE FIRST WEB3 CASINO   
.
.. PLAY NOW ..
garlonicon
Copper Member
Legendary
*
Offline Offline

Activity: 877
Merit: 2114


Pawns are the soul of chess


View Profile
September 16, 2024, 07:40:19 AM
Last edit: September 16, 2024, 08:00:31 AM by garlonicon
Merited by PowerGlove (3)
 #3

It works for me:
Code:
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:130.0) Gecko/20100101 Firefox/130.0
Edit: Also works here:
Code:
User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:109.0) Gecko/20100101 Firefox/115.0
Edit: More working browsers:
Code:
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:130.0) Gecko/20100101 Firefox/130.0
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36 Edg/128.0.0.0

Alpha Marine
Sr. Member
****
Offline Offline

Activity: 686
Merit: 331



View Profile
September 16, 2024, 01:17:13 PM
Merited by PowerGlove (1)
 #4

It worked just fine on my Google Chrome browser.
I used Chrome Version 128.0.6613.138

R


▀▀▀▀▀▀▀██████▄▄
████████████████
▀▀▀▀█████▀▀▀█████
████████▌███▐████
▄▄▄▄█████▄▄▄█████
████████████████
▄▄▄▄▄▄▄██████▀▀
LLBIT|
4,000+ GAMES
███████████████████
██████████▀▄▀▀▀████
████████▀▄▀██░░░███
██████▀▄███▄▀█▄▄▄██
███▀▀▀▀▀▀█▀▀▀▀▀▀███
██░░░░░░░░█░░░░░░██
██▄░░░░░░░█░░░░░▄██
███▄░░░░▄█▄▄▄▄▄████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
█████████
▀████████
░░▀██████
░░░░▀████
░░░░░░███
▄░░░░░███
▀█▄▄▄████
░░▀▀█████
▀▀▀▀▀▀▀▀▀
█████████
░░░▀▀████
██▄▄▀░███
█░░█▄░░██
░████▀▀██
█░░█▀░░██
██▀▀▄░███
░░░▄▄████
▀▀▀▀▀▀▀▀▀
|||
▄▄████▄▄
▀█▀
▄▀▀▄▀█▀
▄░░▄█░██░█▄░░▄
█░▄█░▀█▄▄█▀░█▄░█
▀▄░███▄▄▄▄███░▄▀
▀▀█░░░▄▄▄▄░░░█▀▀
░░██████░░█
█░░░░▀▀░░░░█
▀▄▀▄▀▄▀▄▀▄
▄░█████▀▀█████░▄
▄███████░██░███████▄
▀▀██████▄▄██████▀▀
▀▀████████▀▀
.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
░▀▄░▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄░▄▀
███▀▄▀█████████████████▀▄▀
█████▀▄░▄▄▄▄▄███░▄▄▄▄▄▄▀
███████▀▄▀██████░█▄▄▄▄▄▄▄▄
█████████▀▄▄░███▄▄▄▄▄▄░▄▀
███████████░███████▀▄▀
███████████░██▀▄▄▄▄▀
███████████░▀▄▀
████████████▄▀
███████████
▄▄███████▄▄
▄████▀▀▀▀▀▀▀████▄
▄███▀▄▄███████▄▄▀███▄
▄██▀▄█▀▀▀█████▀▀▀█▄▀██▄
▄██▀▄███░░░▀████░███▄▀██▄
███░████░░░░░▀██░████░███
███░████░█▄░░░░▀░████░███
███░████░███▄░░░░████░███
▀██▄▀███░█████▄░░███▀▄██▀
▀██▄▀█▄▄▄██████▄██▀▄██▀
▀███▄▀▀███████▀▀▄███▀
▀████▄▄▄▄▄▄▄████▀
▀▀███████▀▀
OFFICIAL PARTNERSHIP
SOUTHAMPTON FC
FAZE CLAN
SSC NAPOLI
examplens
Legendary
*
Offline Offline

Activity: 3430
Merit: 3438


Crypto Swap Exchange


View Profile WWW
September 16, 2024, 01:51:42 PM
Merited by PowerGlove (1)
 #5

It works fine for all code tags on this page.
It's latest Chrome Version 128.0.6613.138


█▀▀▀











█▄▄▄
▀▀▀▀▀▀▀▀▀▀▀
e
▄▄▄▄▄▄▄▄▄▄▄
█████████████
████████████▄███
██▐███████▄█████▀
█████████▄████▀
███▐████▄███▀
████▐██████▀
█████▀█████
███████████▄
████████████▄
██▄█████▀█████▄
▄█████████▀█████▀
███████████▀██▀
████▀█████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
c.h.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀█











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
UserU
Hero Member
*****
Offline Offline

Activity: 2184
Merit: 534


FREE passive income eBook @ tinyurl.com/PIA10


View Profile WWW
September 17, 2024, 03:22:40 PM
Merited by PowerGlove (1)
 #6

So far so good, works on Brave browser (v1.69.168)


.
.500 CASINO.██

  ▄

.
THE HOTTEST CRYPTO
CASINO & SPORTSBOOK
         ▄▄▄███████████
 ▄▄▄████████████████

▐████████████████████
 ██████████████████
 ▐██████████████████
 ▐█████████████████
  ██████████████████
  ██████▀█████▀█████
  ▐████████████████
  ▐██████████████
   █████████████████
   ▐██████████████████
    ▀██████▀▀▀▀▀▀   ▀▀▀█

▄▄▄██████████▄▄▄
████████▀██▀▀██▄▄
 █
█████████████████▄
 █
████████████████████
  █
██▄████▄███████▄███
  █
████████████████████
  █
███▀████▀███████▀███
 █
████████████████████
 █
█████████████████▀
█████████▄██▄▄██▀▀
 ▀▀▀██████████▀▀▀

ORIGINALS

SLOTS

LIVE GAMES

SPORTSBOOK



.
██..PLAY NOW..
un_rank
Hero Member
*****
Offline Offline

Activity: 868
Merit: 840


- Jay -


View Profile WWW
September 18, 2024, 02:59:09 PM
Merited by PowerGlove (1)
 #7

Works well on Firefox and Tor



Copying the code for this made me realize why this code will be useful.

If you have thoughts about preferring the "[Select]" link to the "Copy" button (or vice versa), feel free to leave those, too.
Both work very fine, but the tricky part is selecting the entire text a it is, hitting ctrl C is easy.

- Jay -

██
██
██
██
██
██
██
██
██
██
██
██
██
... LIVECASINO.io    Play Live Games with up to 20% cashback!...██
██
██
██
██
██
██
██
██
██
██
██
██
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!