您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Replace white pixels of all images with transparent. Requires Canvas support.
当前为
- // ==UserScript==
- // @name Delete white background of images
- // @description Replace white pixels of all images with transparent. Requires Canvas support.
- // @include http://devdb.ru/*
- // @grant none
- // @version 0.0.1.20140630035011
- // @namespace https://greasyfork.org/scripts/68
- // ==/UserScript==
- // History
- // 2013-10-23 : Created first version
- var imgs = document.getElementsByTagName('img');
- for (var i = 0;i<imgs.length;) {
- var node = imgs[i], newNode = document.createElement("canvas");
- node.parentNode.replaceChild(newNode, node);
- newNode.id = node.id;
- newNode.class = node.class;
- var width = node.width || node.clientWidth;
- var height = node.height || node.clientHeight;
- newNode.setAttribute('width', width);
- newNode.setAttribute('height', height);
- var canvas = newNode.getContext("2d");
- canvas.drawImage(node, 0, 0);
- imageData = canvas.getImageData(0,0,width,height);
- index = 0;
- for (y = 0; y < height; y++) {
- for (x = 0; x < width; x++) {
- if (imageData.data[index] > 247 &&
- imageData.data[index+1] > 247 &&
- imageData.data[index+2] > 247)
- imageData.data[index+3] = 0;
- index += 4;
- }
- }
- canvas.putImageData(imageData, 0, 0);
- }