BC - Recent Activity Links - Open in new tab

Allows users to open Recent Activity links in a new tab

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

You will need to install an extension such as Tampermonkey to install this script.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

You will need to install an extension such as Tampermonkey to install this script.

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name        BC - Recent Activity Links - Open in new tab
// @author      Brad Mitchell
// @homepage    https://github.com/bairdley
// @version     0.1
// @namespace   https://forum.bigcommerce.com
// @description Allows users to open Recent Activity links in a new tab
// @match       https://forum.bigcommerce.com/*
// @grant       none
// @require     https://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js
// ==/UserScript==
(function () {
  var OS,
  urlExt = '/s/question/',
  dataID,
  newTabCount = 0,
  keyCodes,
  keyed = false,
  currentKey;
  (function () {
    if (navigator.appVersion.indexOf('Win') != - 1) {
      OS = 'win';
      keyCodes = {
        ctrl: 238
      };
    } else {
      OS = 'mac';
      keyCodes = {
        ctrl: 17,
        cmdL: 91,
        cmdR: 93,
        cmdFF: 224
      };
    }
  }());
  $(document).keydown(function (e) {
    for (var i in keyCodes) {
      if (e.which === keyCodes[i]) {
        currentKey = keyCodes[i];
        keyed = true;
      }
    }
  });
  $(document).keyup(function (e) {
    if (e.which === currentKey) {
      keyed = false;
    }
  });
  $('.compactFeedElement').live('mouseover', function () {
    $(this).mousedown(function (e) {
      var el = $(this).find('a').andSelf();
      if ($(this).attr('data-id')) {
        dataID = $(this).attr('data-id');
        if (e.which !== 1 && keyed === false) {
          clicks.right(el);
        } else if (OS === 'win') {
          if (keyed === true && currentKey === keyCodes.ctrl) {
            clicks.win.ctrlClick(el);
          }
        } else if (OS === 'mac') {
          if (keyed === true && currentKey === (keyCodes.cmdFF || keyCodes.cmdR || keyCodes.cmdL)) {
            clicks.mac.cmdClick(el);
          } else if (keyed === true && currentKey === keyCodes.ctrl) {
            setHref.url(el);
          }
        }
      }
    }).mouseleave(function () {
      setHref.void ($(this).find('a').andSelf());
    });
  });
  function newTab() {
    window.open(urlExt + dataID);
    var int = setInterval(function () {
      if (newTabCount > 0) {
        newTabCount = 0;
        window.clearInterval(int);
      }
    }, 500);
  }
  var setHref = {
    url: function (el) {
      $(el).attr('href', urlExt + dataID);
    },
    void : function (el) {
      $(el).attr('href', 'javascript:void(0)');
      keyed = false;
    }
  };
  var clicks = {
    mac: {
      cmdClick: function (el) {
        while (newTabCount < 1) {
          newTab();
          newTabCount += 1;
        }
      },
      ctrlClick: function (el) {
      }
    },
    win: {
      ctrlClick: function (el) {
      }
    },
    right: function (el) {
      setHref.url(el);
    }
  };
}) ();