Showing
1 changed file
with
36 additions
and
0 deletions
检查重复.js
0 → 100644
| 1 | +// ==UserScript== | |
| 2 | +// @name 检查重复 | |
| 3 | +// @namespace http://tampermonkey.net/ | |
| 4 | +// @version 0.1 | |
| 5 | +// @description try to take over the world! | |
| 6 | +// @author You | |
| 7 | +// @match http://dpcms8.sysu.edu.cn/gp-dev/manage/menu/main | |
| 8 | +// @grant none | |
| 9 | +// ==/UserScript== | |
| 10 | + | |
| 11 | +(function($) { | |
| 12 | + var getRandomColor = function() { | |
| 13 | + return '#' + (function(color) { | |
| 14 | + return (color += '0123456789abcdef' [Math.floor(Math.random() * 16)]) && (color.length == 6) ? color : arguments.callee(color); | |
| 15 | + })(''); | |
| 16 | + } | |
| 17 | + | |
| 18 | + $('a.menu-item__link').each(function(parentIndex, e) { | |
| 19 | + var color = getRandomColor(); | |
| 20 | + var parent = $(this); | |
| 21 | + $('a.menu-item__link').each(function(index, e) { | |
| 22 | + if (parentIndex == index) { | |
| 23 | + return true; | |
| 24 | + } | |
| 25 | + if (parent.attr('href') == '/gp-dev/') { | |
| 26 | + return false; | |
| 27 | + } | |
| 28 | + | |
| 29 | + if ($(this).attr('href') == parent.attr('href')) { | |
| 30 | + | |
| 31 | + $(this).css('background', color); | |
| 32 | + parent.css('background', color); | |
| 33 | + } | |
| 34 | + }); | |
| 35 | + }); | |
| 36 | +})(jQuery); | ... | ... |
Please
register
or
login
to post a comment