Skip to content

Instantly share code, notes, and snippets.

@andersevenrud
Last active August 29, 2015 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andersevenrud/b49950126c344261ce17 to your computer and use it in GitHub Desktop.
Save andersevenrud/b49950126c344261ce17 to your computer and use it in GitHub Desktop.
Better Battlelog Favourite Server Browser
// ==UserScript==
// @name Better Battlelog Favourite Server Browser
// @namespace http://andersevenrud.github.io/
// @version 0.3
// @description Makes browsing your favouires a bit nicer
// @match http://battlelog.battlefield.com/*
// @downloadURL https://gist.github.com/andersevenrud/b49950126c344261ce17
// @updateURL https://gist.github.com/andersevenrud/b49950126c344261ce17
// @author andersevenrud
// ==/UserScript==
/*
=== INSTALLATION ===
1: Install Greasemonkey (Firefox) or Tampermonkey (Chrome) browser extension.
2: Click the "RAW" button on this gist and it should install automatically
3: Refresh battlelog and it should now work automatically when you browse your favorites
If it does not install automatically:
1: Go to battlelog, click the browser extension icon and choose to add a new file or script
2: Copy/Paste this file
3: Refresh battlelog and it should now work automatically when you browse your favorites
=== SCREENSHOTS ===
Better Mode sorting: http://i.imgur.com/JGpKBUW.png
Better Map sorting: http://i.imgur.com/03faLCE.png
=== ALSO TAKE A LOOK AT ===
* Better Battlelog Loadout
https://gist.github.com/andersevenrud/d9f3ae140a587106f21d
* Bring Battlelog Hooahs back!
https://gist.github.com/andersevenrud/c4cf8ec40ed25c2ef2cf
* Battlelog Server Browser Blacklist
https://gist.github.com/andersevenrud/e275e0b600578bcf6e26
=== LINKS ===
Reddit thread: http://www.reddit.com/r/battlefield_4/comments/2uf86n/better_battlelog_favourite_listing_more_info_in/
*/
(function() {
function createListHeaders(sortBy) {
$("table.servers-list tbody tr.custom-header").remove();
if ( sortBy === "mode" || sortBy === "map" ) {
setTimeout(function() {
var lastIter;
$("table.servers-list tbody tr").each(function(idx, el) {
var newIter = $(el).find("span." + sortBy).html();
if ( idx === 0 || newIter !== lastIter ) {
var row = $("<tr class=\"custom-header\"><td colspan=\"6\">" + newIter + "</td></tr>");
row.find("td").css({
"background-color": "rgba(0, 0, 0, 0.35)",
"font-size": "14px",
"font-weight": "bold",
});
$(el).before(row);
}
lastIter = newIter;
});
}, 100);
}
}
function initFavourites() {
$(".server-info a").on("click", function(ev) {
createListHeaders($(this).attr("data-sort"));
});
$(".server-info a.sort-asc, .server-info a.sort-desc").each(function(idx, el) {
createListHeaders($(el).attr("data-sort"));
});
}
if ( window.location.href.match(/favourites\/pc\/?$/) ) {
initFavourites();
}
$(document).ajaxComplete(function(ev, resp, req) {
if ( req.url === "/bf4/servers/favourites/pc/" ) {
initFavourites();
}
});
//init();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment