Bloquear o botão direito

2 participantes

Ver o tópico anterior Ver o tópico seguinte Ir para baixo

Tópico resolvido Bloquear o botão direito

Mensagem por Heikki 29.10.17 14:37

Detalhes da questão


Endereço do fórum: http://rolling-ballas.forumeiros.com/
Versão do fórum: phpBB3

Descrição


Eu queria este código para meu fórum.

Código:
/**
 * Bloqueio de seleção de texto no fórum e alerta para avisos.
 * @author: Luiz~
 * @author: Kyo Panda
 * @see: <a href="http://ajuda.forumeiros.com/">Fórum dos Fóruns</a>
 * @licence: MIT
 */
(function ($) {
  'use strict';
 
  /**
   * Edite abaixo o título e o texto de sua alerta. (HTML É PERMITIDO!)
   */
  var alertConfig = {
    'title': 'ATENÇÃO!',
    'text': 'Olá, <br>Lamentamos, mas a cópia de conteúdo neste fórum <strong>não é permitida</strong>.<br>Recomendamos a leitura de nossas <a href="/f2-regras">regras</a> para saber mais.',
  };
 
  var styles = [
    '',
    '.alert-wrap {',
    '  position: fixed;',
    '  top: 100px;',
    '  width: 40%;',
    '  background-color: rgb(255, 223, 218);',
    '  border: solid 3px #E9553C;',
    '  background-image: url(https://i39.servimg.com/u/f39/15/88/72/83/warnin10.png);',
    '  background-repeat: no-repeat;',
    '  background-position: 15px center;',
    '  padding: 23px;',
    '  padding-left: 120px;',
    '  font-size: 13px!important;',
    '  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif!important;',
    '  left: 50%;',
    '  transform: translateX(-50%);',
    '  z-index: 99999;',
    '  border-radius: 5px;',
    '}',
    '',
    '.alert-wrap a {',
    '  color: #de5038;',
    '  border-bottom: solid 1px #e9553c;',
    '  transition: all ease-in 150ms;',
    '}',
    '',
    '.alert-wrap strong, .alert-wrap b {',
    '  color: #e9553c;',
    '}',
    '',
    '.alert-wrap a:hover {',
    '  color: #fff;',
    '  box-shadow: inset 0px -20px #e9553c;',
    '}',
    '',
    '.alert-wrap h1 {',
    '  border: solid 0px transparent;',
    '  color: #e9553c;',
    '  font-weight: bold;',
    '  font-size: 15px!important;',
    '}',
    '',
    'div.alert-wrap span.close-alert {',
    '  position: absolute;',
    '  right: 8px;',
    '  top: 5px;',
    '  font-weight: bold;',
    '  font-size: 14px;',
    '  color: #e9573b;',
    '}',
    '',
    'div.alert-wrap span.close-alert:hover {',
    '  text-decoration: underline;',
    '  cursor: pointer;',
    '}',
    '',
  ].join('\n');
 
  $(function () {
 
    // Place the styles on <head>:
    $('<style>', {
      text: styles
    }).appendTo('head');
 
    // Alert:
    $([
      '<div class="alert-wrap">',
      '  <span class="close-alert">x</span>',
      '  <div class="content">',
      '    <h1>' + alertConfig.title + '</h1>',
      '    ' + alertConfig.text,
      '  </div>',
      '</div>',
    ].join('\n'))
      .hide()
      .appendTo('body')
    ;
   
   $(document).on('copy', function(event) {
      event.preventDefault();
   });
 
    // Select Event:
    $(document).on('mouseup', function() {
      var selection;
      
      if (document.selection) {
         selection = document.selection.createRange().text;
      } else if (window.getSelection) {
         selection = window.getSelection().toString();
      } else {
         return;
      }
      
      if (selection) {
         $('.alert-wrap').show();
      }
      
      if (document.selection) {
         document.selection.clear();
         return;
      }
      
      window.getSelection().empty();
   });
 
    // Close alert function:
    $('.close-alert')
      .on('click', function () {
        $('.alert-wrap').hide();
      })
    ;
  });
 
  $(function () {
    $('body').on('contextmenu', function () {
      return false;
    });
  });
}(jQuery));
Heikki

Heikki
***

Membro desde : 31/10/2016
Mensagens : 171
Pontos : 328

https://ajuda.forumeiros.com

Ir para o topo Ir para baixo

Membro Entusiasta

Tópico resolvido Re: Bloquear o botão direito

Mensagem por Luiz 29.10.17 17:05

Olá,

Crie um novo JavaScript investido em todas as páginas com este código:
Código:
/**
 * Bloqueio de seleção de texto no fórum e alerta para avisos.
 * @author: Luiz~
 * @author: Kyo Panda
 * @see: <a href="http://ajuda.forumeiros.com/">Fórum dos Fóruns</a>
 * @licence: MIT
 */
(function ($) {
  'use strict';
 
  /**
  * Edite abaixo o título e o texto de sua alerta. (HTML É PERMITIDO!)
  */
  var alertConfig = {
    'title': 'ATENÇÃO!',
    'text': 'Olá, <br>Lamentamos, mas a cópia de conteúdo neste fórum <strong>não é permitida</strong>.<br>Recomendamos a leitura de nossas <a href="/f2-regras">regras</a> para saber mais.',
  };
 
  var styles = [
    '',
    '.alert-wrap {',
    '  position: fixed;',
    '  top: 100px;',
    '  width: 40%;',
    '  background-color: rgb(255, 223, 218);',
    '  border: solid 3px #E9553C;',
    '  background-image: url(https://i39.servimg.com/u/f39/15/88/72/83/warnin10.png);',
    '  background-repeat: no-repeat;',
    '  background-position: 15px center;',
    '  padding: 23px;',
    '  padding-left: 120px;',
    '  font-size: 13px!important;',
    '  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif!important;',
    '  left: 50%;',
    '  transform: translateX(-50%);',
    '  z-index: 99999;',
    '  border-radius: 5px;',
    '}',
    '',
    '.alert-wrap a {',
    '  color: #de5038;',
    '  border-bottom: solid 1px #e9553c;',
    '  transition: all ease-in 150ms;',
    '}',
    '',
    '.alert-wrap strong, .alert-wrap b {',
    '  color: #e9553c;',
    '}',
    '',
    '.alert-wrap a:hover {',
    '  color: #fff;',
    '  box-shadow: inset 0px -20px #e9553c;',
    '}',
    '',
    '.alert-wrap h1 {',
    '  border: solid 0px transparent;',
    '  color: #e9553c;',
    '  font-weight: bold;',
    '  font-size: 15px!important;',
    '}',
    '',
    'div.alert-wrap span.close-alert {',
    '  position: absolute;',
    '  right: 8px;',
    '  top: 5px;',
    '  font-weight: bold;',
    '  font-size: 14px;',
    '  color: #e9573b;',
    '}',
    '',
    'div.alert-wrap span.close-alert:hover {',
    '  text-decoration: underline;',
    '  cursor: pointer;',
    '}',
    '',
  ].join('\n');
 
  $(function () {
 
    // Place the styles on <head>:
    $('<style>', {
      text: styles
    }).appendTo('head');
 
    // Alert:
    $([
      '<div class="alert-wrap">',
      '  <span class="close-alert">x</span>',
      '  <div class="content">',
      '    <h1>' + alertConfig.title + '</h1>',
      '    ' + alertConfig.text,
      '  </div>',
      '</div>',
    ].join('\n'))
      .hide()
      .appendTo('body')
    ;
 
    // Close alert function:
    $('.close-alert')
      .on('click', function () {
        $('.alert-wrap').hide();
      })
    ;
  });
 
  $(function () {
    $('body').on('contextmenu', function () {
      $('.alert-wrap').show();
      return false;
    });
  });
}(jQuery));

Ele não irá mais permitir o uso do botão direito. Feliz

o/
Luiz

Luiz
Membro Entusiasta
Membro Entusiasta

Membro desde : 23/04/2016
Mensagens : 6645
Pontos : 7451

https://luizfelipe.dev

Ir para o topo Ir para baixo

Tópico resolvido Re: Bloquear o botão direito

Mensagem por Heikki 29.10.17 18:36

Funcionou perfeitamente  Muito feliz

Obrigado.  Rosa
Heikki

Heikki
***

Membro desde : 31/10/2016
Mensagens : 171
Pontos : 328

https://ajuda.forumeiros.com

Ir para o topo Ir para baixo

Membro Entusiasta

Tópico resolvido Re: Bloquear o botão direito

Mensagem por Luiz 29.10.17 18:48

Questão marcada como Resolvida ou o Autor solicitou que ela fosse arquivada.
Tópico marcado como Resolvido e movido para Questões resolvidas.
Luiz

Luiz
Membro Entusiasta
Membro Entusiasta

Membro desde : 23/04/2016
Mensagens : 6645
Pontos : 7451

https://luizfelipe.dev

Ir para o topo Ir para baixo

Ver o tópico anterior Ver o tópico seguinte Ir para o topo

- Tópicos semelhantes

Permissões neste sub-fórum
Não podes responder a tópicos