Advertisement
Guest User

terstock

a guest
May 29th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name        Download terstock
  3. // @description Adds live example button, with styling.
  4. // @include     https://www.shutterstock.com/image-vector/*
  5. // @include     https://www.shutterstock.com/image-photo/*
  6. // @grant       GM_addStyle
  7. // ==/UserScript==
  8.  
  9. /*--- Create a button in a container div.  It will be styled and
  10.     positioned with CSS.
  11. */
  12. var zNode       = document.createElement ('div');
  13. zNode.innerHTML = '<button id="myButton" type="button">' + 'Download with terstock</button>'
  14.                 ;
  15. zNode.setAttribute ('id', 'myContainer');
  16. document.body.appendChild (zNode);
  17.  
  18. //--- Activate the newly added button.
  19. document.getElementById ("myButton").addEventListener (
  20.     "click", ButtonClickAction, false
  21. );
  22.  
  23. function ButtonClickAction (zEvent) {
  24.     /*--- For our dummy action, we'll just add a line of text to the top
  25.         of the screen.
  26.     */
  27.     var zNode       = document.createElement ('p');
  28.     var url = window.location.href;
  29.     url = url.replace("shut",'');
  30.     window.location.href = url;
  31.     document.getElementById ("myContainer").appendChild (zNode);
  32. }
  33.  
  34. //--- Style our newly added elements using CSS.
  35. GM_addStyle ( multilineStr ( function () {/*!
  36.     #myContainer {
  37.         position:               fixed;
  38.         top:                    20%;
  39.         left:                   0%;
  40.         font-size:              13px;
  41.         background:             white;
  42.         border:                 0px outset black;
  43.         margin:                 5px;
  44.         opacity:                0.9;
  45.         z-index:                10000;
  46.         padding:                5px 5px;
  47.     }
  48.     #myButton {
  49.         cursor:                 pointer;
  50.     }
  51.     #myContainer p {
  52.         color:                  red;
  53.         background:             white;
  54.     }
  55. */} ) );
  56.  
  57. function multilineStr (dummyFunc) {
  58.     var str = dummyFunc.toString ();
  59.     str     = str.replace (/^[^\/]+\/\*!?/, '') // Strip function () { /*!
  60.             .replace (/\s*\*\/\s*\}\s*$/, '')   // Strip */ }
  61.             .replace (/\/\/.+$/gm, '') // Double-slash comments wreck CSS. Strip them.
  62.             ;
  63.     return str;
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement