Lochnair / Get item IDs - Steam Workshop Collection

// ==UserScript==
// @name        Get item IDs - Steam Workshop Collection
// @namespace   https://lochnair.net
// @include     http://steamcommunity.com/sharedfiles/filedetails/?id=*
// @version     1
// @require     http://code.jquery.com/jquery-1.11.3.min.js
// @grant       none
// ==/UserScript==
var url = "http://steamcommunity.com/sharedfiles/filedetails/?id=";

if ($(".collectionNotifications").length > 0) {
  $("div.workshopItemControlCtn:nth-child(4)").append('\
    <span id="GetItemIDs" class="general_btn share tooltip" data-tooltip-content="Get item IDs">\
     <span>Get item IDs</span>\
    </span>\
  ');

  $("#GetItemIDs span").click(function() {
    var result = "";
    $(".collectionItemDetails > a").each(function(index, element) {
      result += element.href.substring(url.length) + "\n";
    });
    window.prompt(result);
  });
}