您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Previews banners for the reddit.com/r/EVEX banner contest
- // ==UserScript==
- // @name Evex Banner Contest Viewer
- // @namespace faubiguy
- // @version 0.1
- // @description Previews banners for the reddit.com/r/EVEX banner contest
- // @author faubiguy
- // @match https://www.reddit.com/r/EVEX/comments/3uztta/*
- // @grant none
- // ==/UserScript==
- /* jshint -W097 */
- 'use strict';
- if (document.body.classList.contains('comment-permalink-page')) {
- console.log('Switching banner image');
- var commentbody = document.getElementsByClassName('comment')[0].getElementsByClassName('usertext-body')[0];
- var imagelinks = Array.prototype.slice.call(commentbody.getElementsByTagName('a')).filter(function(url){return /\.(jpg|jpeg|png|gif)($|\?)/.exec(url.href);});
- console.log(Array.prototype.slice.call(commentbody.getElementsByTagName('a')).map(function(url){return url.href}));
- if (imagelinks.length === 0) {
- console.log('No images found');
- return;
- }
- console.log('Found an image to use: ' + imagelinks[0].href);
- var newstyle = document.createElement('style');
- newstyle.innerHTML = '#header{background-image:url("'+ imagelinks[0].href +'")!important;}';
- document.head.appendChild(newstyle);
- console.log('Appended style');
- }