|
| 1 | +// ==UserScript== |
| 2 | +// @name 反图片防盗链 |
| 3 | +// @name:en Anti-anti-pic-stealing-link |
| 4 | +// @namespace hoothin |
| 5 | +// @version 0.2 |
| 6 | +// @description 破解图片防盗链 |
| 7 | +// @description:en crack Anti-pic-stealing-link to show real picture |
| 8 | +// @author hoothin |
| 9 | +// @include http*://*/* |
| 10 | +// @grant unsafeWindow |
| 11 | +// @grant GM_registerMenuCommand |
| 12 | +// @grant GM_getValue |
| 13 | +// @grant GM_setValue |
| 14 | +// ==/UserScript== |
| 15 | + |
| 16 | +(function() { |
| 17 | + 'use strict'; |
| 18 | + const sites={ |
| 19 | + "qq.com": "photo\.store\.qq\.com", |
| 20 | + "baidu.com": "a\.hiphotos\.baidu\.com\/image", |
| 21 | + }; |
| 22 | + var customRule=GM_getValue("aaslr"); |
| 23 | + function refererChanger(item){ |
| 24 | + var frameid = 'frameimg' + Math.random(); |
| 25 | + unsafeWindow.img = '<img id="aapslImg" src="'+item.src+'?'+Math.random()+'"/><script>window.onload=function(){parent.document.getElementById("'+frameid+'").height=document.getElementById("aapslImg").height+"px";}</script>'; |
| 26 | + var iframe=document.createElement("iframe"); |
| 27 | + iframe.id=frameid; |
| 28 | + iframe.src="javascript:parent.img;"; |
| 29 | + iframe.frameBorder="0"; |
| 30 | + iframe.scrolling="no"; |
| 31 | + iframe.width="100%"; |
| 32 | + item.parentNode.replaceChild(iframe,item); |
| 33 | + } |
| 34 | + GM_registerMenuCommand("Anti-anti-pic-stealing-link rule", function(){ |
| 35 | + var input=prompt("Set up Anti-anti-pic-stealing-link rule:",customRule?customRule:""); |
| 36 | + if(input){ |
| 37 | + customRule=input; |
| 38 | + GM_setValue("aaslr",customRule); |
| 39 | + } |
| 40 | + }); |
| 41 | + [].forEach.call(document.querySelectorAll("img"),function(item){ |
| 42 | + for (var i in sites) { |
| 43 | + var sitePatt=new RegExp(sites[i],"i"); |
| 44 | + if(sitePatt.test(item.src)){ |
| 45 | + if(!(new RegExp(i,"i")).test(location.href)){ |
| 46 | + refererChanger(item); |
| 47 | + } |
| 48 | + break; |
| 49 | + } |
| 50 | + } |
| 51 | + if(customRule && (new RegExp(customRule,"i")).test(item.src)){ |
| 52 | + refererChanger(item); |
| 53 | + } |
| 54 | + }); |
| 55 | +})(); |
0 commit comments