News:

Want to get involved in developing SMF? Why not lend a hand on our GitHub!

Main Menu

disable text selection for guests?

Started by razzy, March 07, 2021, 03:01:22 PM

Previous topic - Next topic

razzy

I tried searching to see if there was another solution to the issue I'm having and didn't find anything. Apologies if this was already covered.

I had managed to do this once and didn't leave my future self any notes. (of course). It's disabling text selection for guests. I have installed the mod that disables right-click, but that doesn't make it hard to select text and ctrl+c things. I understand that there is no perfect way to completely protect things, I just want to make it more difficult for things to be selected, copied, and saved by not to savvy people.

so I have this:
.notxt {
  -webkit-touch-callout: none; /* iOS Safari */
    -webkit-user-select: none; /* Safari */
     -khtml-user-select: none; /* Konqueror HTML */
       -moz-user-select: none; /* Firefox */
        -ms-user-select: none; /* Internet Explorer/Edge */
            user-select: none; /* Non-prefixed version, currently
                                  supported by Chrome and Opera */
}


Although it does nothing because I don't know where to put this..
<p class="notxt">

Thanks for any and all suggestions. I've been trying to figure out how I managed to do it before and am pulling up a blank.

Kindred

That is completely pointless and useless, as is the no right click
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

razzy

#2
yes, it is. especially for anyone who actually knows how to use the internet, it's not difficult to bypass and scrape all the information anyways. I have been around long enough to know that there is no full way to protect something but that's not why I'm looking for help with this for.
Although for where I'd require it to be implemented it would be very helpful. I'd appreciate any help on this. as it's a pain to keep selecting everything including posts, and I'd love to be able to implement it on just certain areas of posts to make things easier for members.

landyvlad

I fail to see how it makes anything easier for members?

Out of interest - what are the reasons you are trying to stop text selection?
"Put as much effort into your question as you'd expect someone to give in an answer"

Please do not PM, IM or Email me with questions on astrophysics or theology.  You will get better and faster responses by asking homeless people in the street. Thank you.

Be the person your dog thinks you are.

Kindred

#4
So, you acknowledge that it is pointless and useless and still continue to try to do it? Why? Exactly what problem are you trying to solve by preventing people from right clicking or selecting the text? Especially when you can't actually prevent them from doing either.


Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Ninja ZX-10RR

The user has been warned about how pointless this can be multiple times, I think it's no use to argue any further given she seems to know exactly what she wants.

So if you want to make stuff unselectable within *posts* (I can only assume this, you didn't specify where :P), simply change the:
.notxt {
  -webkit-touch-callout: none; /* iOS Safari */
    -webkit-user-select: none; /* Safari */
     -khtml-user-select: none; /* Konqueror HTML */
       -moz-user-select: none; /* Firefox */
        -ms-user-select: none; /* Internet Explorer/Edge */
            user-select: none; /* Non-prefixed version, currently
                                  supported by Chrome and Opera */
}

to
Code (replace with) Select
.inner {
  -webkit-touch-callout: none; /* iOS Safari */
    -webkit-user-select: none; /* Safari */
     -khtml-user-select: none; /* Konqueror HTML */
       -moz-user-select: none; /* Firefox */
        -ms-user-select: none; /* Internet Explorer/Edge */
            user-select: none; /* Non-prefixed version, currently
                                  supported by Chrome and Opera */
}

Untested but should work really. Again, as correctly pointed out above, it's not gonna be any useful for someone with a bit of knowledge, and whenever I find right click blocking scripts I personally leave the site no matter the content, so do keep these things into consideration :)
Quote from: BeastMode topic=525177.msg3720020#msg3720020
It's so powerful that on this post and even in the two PMs you sent me,you still answered my question very quickly and you're apologizing for the delay. You're the #1 support I've probably ever encountered man, so much respect for that. Thank you, and get better soon.

I'll keep this in my siggy for a while just to remind me that someone appreciated what I did while others didn't.

♥ Jess ♥

STOP EDITING MY PROFILE

Sir Osis of Liver

It's long been my opinion that if someone asks for something that appears unreasonable, give fair warning, then give them the solution, as long as it doesn't damage the forum.  Let OP and her forum members decide whether it's useful or not.
Even if the whole world has forgotten,
The song remembers when.

                              - H. Prestwood

Ninja ZX-10RR

Turns out I was slightly inaccurate, given the fact that she said she wanted it for guests... So you could do like...
File Themes/whatever theme you have/index.template.php
Code (add) Select
if ($context['user']['is_guest']) echo '<link rel="stylesheet" type="text/css" href="', $settings['theme_url'], '/css/guests', $context['theme_variant'], '.css?fin20" />';
As for where to put it, it's gonna be huh... About after all other css files, so it gets loaded last and supersedes everything else, but before the javascript so we keep some kind of logic/order. On default theme, you look for:
// Here comes the JavaScript bits!
You add an empty row before that, and then paste the code I typed above into that, making sure you leave an empty row between that code and the "Here comes the JavaScript bits!", like so:
if ($context['user']['is_guest']) echo '<link rel="stylesheet" type="text/css" href="', $settings['theme_url'], '/css/guests', $context['theme_variant'], '.css?fin20" />';

// Here comes the JavaScript bits!


You then go to /Themes/your theme/css/ and create a file called "guests.css", open it, put
.inner {
  -webkit-touch-callout: none; /* iOS Safari */
    -webkit-user-select: none; /* Safari */
     -khtml-user-select: none; /* Konqueror HTML */
       -moz-user-select: none; /* Firefox */
        -ms-user-select: none; /* Internet Explorer/Edge */
            user-select: none; /* Non-prefixed version, currently
                                  supported by Chrome and Opera */
}

this inside of it, save it. And you should be good, text inside posts won't be selectable for guests but it will be for anyone logged in :)
Quote from: BeastMode topic=525177.msg3720020#msg3720020
It's so powerful that on this post and even in the two PMs you sent me,you still answered my question very quickly and you're apologizing for the delay. You're the #1 support I've probably ever encountered man, so much respect for that. Thank you, and get better soon.

I'll keep this in my siggy for a while just to remind me that someone appreciated what I did while others didn't.

♥ Jess ♥

STOP EDITING MY PROFILE

Advertisement: