Skip to content

Instantly share code, notes, and snippets.

@DanielSundberg
Last active August 29, 2015 14:04
Show Gist options
  • Save DanielSundberg/8f0502d7c9eb8dfdc64a to your computer and use it in GitHub Desktop.
Save DanielSundberg/8f0502d7c9eb8dfdc64a to your computer and use it in GitHub Desktop.
Greasemonkey Script to rewrite gerrit download URL to a valid PowerShell command
// ==UserScript==
// @name Rewrite Gerrit download link
// @include http://*/gerrit/#/*
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
// @require https://gist.github.com/raw/2625891/waitForKeyElements.js
// @version 1
// @grant GM_addStyle
// ==/UserScript==
// This script will take the url you get from
// the Gerrit download field and replace
// the unix command/line separator ('&&') with
// a ';' which is accepted as line break in
// PowerShell
//
// This works with some Gerrit version previous
// to 2.9 on Windows/Firefox. When we upgrades
// to 2.9 I couldn't make the GreasMonkey script
// work.
function rewriteDownloadLink (jNode) {
var element = document.getElementsByClassName('downloadLinkCopyLabel')
if (element.length == 0) {
console.log("Could not get download link object")
} else {
element[0].textContent = element[0].textContent.replace('&&', ';')
}
}
waitForKeyElements (".downloadLinkCopyLabel", rewriteDownloadLink);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment