// ==UserScript== // @name WPorg-Dev // @namespace wordpress // @description A userscript to help developers access certain WordPress.org plugin information and pages a lot easier. // @include https://wordpress.org/plugins/* // @include https://*.wordpress.org/plugins/* // @version 2.0 // @copyright 2017 Armando Lüscher // @author Armando Lüscher // @oujs:author noplanman // @grant GM_addStyle // @require https://code.jquery.com/jquery-1.11.3.min.js // @homepageURL https://github.com/noplanman/WPorg-Dev-Userscript // @supportURL https://github.com/noplanman/WPorg-Dev-Userscript/issues // @downloadURL none // ==/UserScript== // The base URL of the WordPress plugins pages. var wpBaseURL = location.protocol + '//' + location.host; var pluginsBaseURL = wpBaseURL + '/plugins/'; var wodu = {}; /** * Extract the plugin slug from a URL. * @param {string} url URL to extract the plugin slug from. * @return {string} The extracted plugin slug. */ wodu.getSlug = function (url) { var p = url.indexOf(pluginsBaseURL); if (p >= 0) { return url.substring(p + pluginsBaseURL.length).split('/')[0]; } return ''; }; /** * Generate the failed message and the retry button. * * @param {jQuery} $el The error message panel gets appended to this jQuery object. * @param {Function} cb Callback function when clicking the "Retry" button. * @return {jQuery} The jQuery object containing the message and button. */ wodu.getFailedRetryButton = function ($el, cb) { $el.removeClass('wodu-loaded'); return $('
Failed.
') .append($('
Retry
').click(cb)) .appendTo($el); }; /** * Generate a dropdown menu with all the downloadable versions. * * When the selection changes, the selected version download begins. * * @param {jQuery} $devPage The page containing the links. * @return {jQuery} Dropdown menu with all the links. */ wodu.getDLLinkDropdown = function ($devPage) { var $select = $('