0

I have a simple userscript that i am using to restyle a popup with tampermonkey in google chrome. Everything works fine in the tampermonkey extension however i need to install and maintain the script across multiple users browsers as such i am trying to host the file on our server and import and update by the url import and updates in tampermonkey if this is possible?

When i try to import by url i get 'invalid userscrip sry' popup and when i try to update the script on the server no updates are made even though i get an 'operation successful' popup.

I am new to using tampermonkey and userscripts and I cant seem to find where I am going wrong?

Here is my code:

// ==UserScript==
// @name         zendesk-popup-style-changes
// @version      0.1
// @description  Zendesk popup style changes for Essential E-Commerce LTD
// @author       Aaron Sly
// @match        https://essential-commerce.zendesk.com/*
// @grant        none
// @downloadURL  https://www.theheatingboutique.co.uk/zendesk-popup-style-changes.user.js
// ==/UserScript==

(function() {
'use strict';

function addGlobalStyle(css) {
var head, style;
head = document.getElementsByTagName('head')[0];
if (!head) { return; }
style = document.createElement('style');
style.type = 'text/css';
style.innerHTML = css;
head.appendChild(style);
}

addGlobalStyle('div.jGrowl div.jGrowl-notification{ width: 400px; font-size:15px;background-color: #D6FFDF; animation: pulse 2s linear infinite, nudge 2s linear infinite;  }');
addGlobalStyle('div.jGrowl div.jGrowl-notification.ui-state-alert a {border-bottom: 2px solid #FFA914;} ');
addGlobalStyle('div.jGrowl div.jGrowl-notification .jGrowl-close {opacity:1;}');
addGlobalStyle('@keyframes pulse { 0%, 100% { background-color: #FFC6C2; } 50% { background-color: #FFECEB; } }');
addGlobalStyle('@keyframes nudge { 0%, 50%, 60%, 100% { transform: translate(0, 0); } 25% { transform: translate(-1%, 0); } 55% {transform: translate(0.5%,0) } } ');

})();
Aaron
  • 1
  • 1
  • What url were you trying to import? It should be a direct link to the file, not an HTML page. – wOxxOm Jan 19 '17 at 12:11
  • Its the same link as in the @downloadURL above (https://www.theheatingboutique.co.uk/zendesk-popup-style-changes.user.js) it seems to find the file but says its not a valid userscript – Aaron Jan 19 '17 at 12:17
  • 1
    It doesn't have the [metadata block](https://wiki.greasespot.net/Metadata_Block). – wOxxOm Jan 19 '17 at 12:53
  • wOxxOm is right; `downloadURL` must have a valid *Metadata Block*. See, also, [How @downloadURL & @updateURL work](http://stackoverflow.com/questions/38023717/why-is-usage-of-the-downloadurl-updateurl-keys-called-unusual-and-how-do-they). – Brock Adams Jan 19 '17 at 19:58
  • I've had a look and turns out that the js file was getting minified by cloudflare and stripping the meta block out. Thanks for the help all is working perfectly now! – Aaron Jan 20 '17 at 12:05

0 Answers0