Greasy Fork

ColoredMercury

Adds site's colors to the mobile skin of FANDOM

目前为 2017-06-29 提交的版本。查看 最新版本

// ==UserScript==
// @name         ColoredMercury
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Adds site's colors to the mobile skin of FANDOM
// @author       Unai Mengual
// @match        http://*.wikia.com/*
// @grant        none
// @require      https://code.jquery.com/jquery-2.1.4.min.js
// ==/UserScript==

(function($) {
    'use strict';
    if (!$('body').hasClass('mobile-wiki')) {
        return;
    }
    $.ajax({
        url: '/__load/-/only=scripts&skin=oasis/startup',
        dataType: 'text',
        type: 'GET',
        async: true
    }).done(function (startup) {
        var color = startup.replace(/[\s\S]*color-buttons":"(#[A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})[\s\S]*/, '$1');
    $('.wiki-page-header:not(.has-hero-image), .portable-infobox  .pi-secondary-background')
        .css('background', color);
   $('.edit-section .icon').not('.wiki-page-header__wrapper .edit-section .icon')
        .css('fill', color + '!important'); 
    });
}(jQuery));