SlimRunner

desmos-rmb-color-bubble

Jul 28th, 2020 (edited)
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (function() {
  2.     //'use strict';
  3.    
  4.     let showContextMenu = true;
  5.    
  6.     document.addEventListener("contextmenu", (e) => {
  7.         if (!showContextMenu) {
  8.             showContextMenu = true;
  9.             e.preventDefault();
  10.         }
  11.     }, capture = false);
  12.    
  13.     window.addEventListener('mousedown', (e) => {
  14.         if (
  15.             e.button === 2 &&
  16.             typeof e.target.classList === 'object' &&
  17.             typeof e.target.className === 'string' &&
  18.             e.target.classList.contains('dcg-hovered') &&
  19.             (e.target.classList.contains('dcg-layered-icon') ||
  20.             e.target.classList.contains('dcg-circular-icon'))
  21.         ) {
  22.             const ICON_DICTIONARY = `boxplot cross distribution dotplot-cross dotplot-default dotplot-open histogram move move-horizontal move-vertical open parametric-dashed parametric-dotted parametric-solid point points polygon-filled polygon-solid`;
  23.            
  24.             // isolate icon name using regex
  25.             let targetName = e.target.className.match(/(?<=dcg-icon-)[a-z\-]+/im);
  26.            
  27.             if (
  28.                 ICON_DICTIONARY.search(targetName) !== -1 ||
  29.                 e.target.className.search('dcg-do-not-blur') !== -1
  30.             ) {
  31.                 showContextMenu = false;
  32.                 Desmos.$(e.target.parentElement.parentElement).trigger('dcg-longhold');
  33.             }
  34.            
  35.         }
  36.     });
  37.    
  38. }());
Advertisement
Add Comment
Please, Sign In to add comment