Перейти из форума на сайт.

НовостиФайловые архивы
ПоискАктивные темыТоп лист
ПравилаКто в on-line?
Вход Забыли пароль? Первый раз на этом сайте? Регистрация
Компьютерный форум Ru.Board » Компьютеры » Программы » Расширения для Firefox | Mozilla Firefox Extensions

Модерирует : gyra, Maz

 Версия для печати • ПодписатьсяДобавить в закладки
На первую страницук этому сообщениюк последнему сообщению

Открыть новую тему     Написать ответ в эту тему

xrun1



Advanced Member
Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору

Код:
// ==UserScript==
// @name Select text from links
// @namespace      http://operafan.net/forum/index.php?topic=11837.msg205482#msg205482
// @version        0.1
// @description    Выделение текста ссылки
// @include        *
// @grant          none
// @run-at         document-start
// ==/UserScript==
 
// Выделение ссылок
(function olls() {
  function OPLLS() {
    this.init.apply(this, arguments);
  }
  OPLLS.prototype = {
    handleEvent: function (e) {
      switch (e.type) {
      case 'mouseup':
        if (!getSelection() .toString()) break;
//        console.log('mouseup');
        var t = e.target;
        while (t.nodeName != 'A' && t.nodeName != 'HTML') t = t.parentNode;
        if (!t.href) {
//          console.log('uninit');
          this.uninit();
        }
        break;
      case 'click':
        if (!getSelection() .toString()) {
//          console.log('clicked and uninit');
          this.uninit();
          break;
        }
        e.preventDefault();
        e.stopPropagation();
//        console.log('selected and uninit');
        this.uninit();
      }
    },
    init: function (e) {
      var t = e.target;
      if (t.nodeName == 'IMG') return ;
      while (t.nodeName != 'A' && t.nodeName != 'HTML') t = t.parentNode;
      if (!t.href) return ;
      t.draggable = false;
//      console.log('OK');
      document.addEventListener('mouseup', this, true);
      document.addEventListener('click', this, true);
    },
    uninit: function () {
      document.removeEventListener('mouseup', this, true);
      document.removeEventListener('click', this, true);
    }
  }
  document.addEventListener('mousedown', function (e) {
    if (e.button != 0 || e.ctrlKey || e.altKey || e.shiftKey) return ;
    new OPLLS(e);
  }, false);
})();
 

Всего записей: 726 | Зарегистр. 26-12-2009 | Отправлено: 01:08 11-03-2024
Открыть новую тему     Написать ответ в эту тему

На первую страницук этому сообщениюк последнему сообщению

Компьютерный форум Ru.Board » Компьютеры » Программы » Расширения для Firefox | Mozilla Firefox Extensions


Реклама на форуме Ru.Board.

Powered by Ikonboard "v2.1.7b" © 2000 Ikonboard.com
Modified by Ru.B0ard
© Ru.B0ard 2000-2024

BitCoin: 1NGG1chHtUvrtEqjeerQCKDMUi6S6CG4iC

Рейтинг.ru