Skip to content

Instantly share code, notes, and snippets.

@eaglefsd
Last active January 26, 2016 07:53
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save eaglefsd/94e5bb55dd5131b7f32e to your computer and use it in GitHub Desktop.
Save eaglefsd/94e5bb55dd5131b7f32e to your computer and use it in GitHub Desktop.
LSS Fahrzeugexport
// ==UserScript==
// @name LSS Fahrzeugexport
// @namespace Leitstellenspiel
// @include http://www.leitstellenspiel.de/
// @include http://www.leitstellenspiel.de/#
// @version 1
// @grant none
// @require https://code.jquery.com/jquery-2.1.4.min.js
// @author Eagle
// ==/UserScript==
var $ = jQuery.noConflict();
if (window.location.pathname == "/") {
$('#news_li').before('<li id="exportCars"><a href="#">Fahrzeuge exportieren</a></li>');
$('#exportCars').bind('click', function() {
var data = [];
$('#building_list').find('.building_list_li').each(function(index, element) {
var stationId = $(element).find('.building_list_caption').find('.building_marker_image').attr('building_id'),
stationName = $(element).find('.building_list_caption').find('.map_position_mover').html(),
stationLat = $(element).find('.building_list_caption').find('.map_position_mover').attr('data-latitude'),
stationLng = $(element).find('.building_list_caption').find('.map_position_mover').attr('data-longitude'),
cars = [];
$('#vehicle_building_'+ stationId).find('li').each(function(index, element) {
var carId = $(element).attr('vehicle_id'),
carName = $(element).find('a').html(),
carType = $(element).find('a').attr('vehicle_type_id');
var tempCarData = {
'carId' : carId,
'carName' : carName,
'carType' : carType
};
cars.push(tempCarData);
});
var tempStationData = {
'stationId' : stationId,
'stationName' : stationName,
'stationLat' : stationLat,
'stationLng' : stationLng,
'cars': cars
};
data.push(tempStationData);
});
console.log(data);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment