Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Download terstock
- // @description Adds live example button, with styling.
- // @include https://www.shutterstock.com/image-vector/*
- // @include https://www.shutterstock.com/image-photo/*
- // @grant GM_addStyle
- // ==/UserScript==
- /*--- Create a button in a container div. It will be styled and
- positioned with CSS.
- */
- var zNode = document.createElement ('div');
- zNode.innerHTML = '<button id="myButton" type="button">' + 'Download with terstock</button>'
- ;
- zNode.setAttribute ('id', 'myContainer');
- document.body.appendChild (zNode);
- //--- Activate the newly added button.
- document.getElementById ("myButton").addEventListener (
- "click", ButtonClickAction, false
- );
- function ButtonClickAction (zEvent) {
- /*--- For our dummy action, we'll just add a line of text to the top
- of the screen.
- */
- var zNode = document.createElement ('p');
- var url = window.location.href;
- url = url.replace("shut",'');
- window.location.href = url;
- document.getElementById ("myContainer").appendChild (zNode);
- }
- //--- Style our newly added elements using CSS.
- GM_addStyle ( multilineStr ( function () {/*!
- #myContainer {
- position: fixed;
- top: 20%;
- left: 0%;
- font-size: 13px;
- background: white;
- border: 0px outset black;
- margin: 5px;
- opacity: 0.9;
- z-index: 10000;
- padding: 5px 5px;
- }
- #myButton {
- cursor: pointer;
- }
- #myContainer p {
- color: red;
- background: white;
- }
- */} ) );
- function multilineStr (dummyFunc) {
- var str = dummyFunc.toString ();
- str = str.replace (/^[^\/]+\/\*!?/, '') // Strip function () { /*!
- .replace (/\s*\*\/\s*\}\s*$/, '') // Strip */ }
- .replace (/\/\/.+$/gm, '') // Double-slash comments wreck CSS. Strip them.
- ;
- return str;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement