// ==UserScript==
// @name Give Me Bigger
// @description 表格式顯示相簿原圖
// @priority 1
// @version 2011-05-17
// @include http://www.wretch.cc/album/album.php*
// @include http://*.pixnet.net/album/set/*
// @include http://photo.xuite.net/*/*
// ==/UserScript==
GM_registerMenuCommand('Give Me Bigger - Setting columns', settingColumns);
GM_registerMenuCommand('Give Me Bigger - Setting width of images', settingImgWidth);
var siteRule=['www.wretch.cc','pixnet.net','photo.xuite.net'];
var thumbRule=['thumbs\/t','thumb_','_c'];
var thumbRRule=['','','_l'];
var contentRule=['#ad_square','#contentBody','.list_area'];
var linkRule=['td.side a','.thumbImg a','.list_area .photo_info a'];
//Setting columns
function settingColumns() {
var oldCols=GM_getValue('cols')||2; //(Default Value:2)
GM_setValue('cols', prompt('Please enter the columns.', oldCols));
}
//Setting width of images
function settingImgWidth() {
var oldIW=GM_getValue('imgwidth')||240; //(Default Value:240)
GM_setValue('imgwidth', prompt('Please Enter the width(px) of images.', oldIW));
}
//Setting display infomation
function settingInfo() {
window.infoBlock=document.createElement('p');
infoBlock.style.position='absolute';
infoBlock.style.top='10px';
infoBlock.style.left='50px';
infoBlock.style.fontSize='1.8em';
window.curCount=document.createElement('span'); //Current complete images
curCount.textContent=0;
window.toaCount=document.createElement('span'); //Amount of all images
infoBlock.appendChild(curCount);
infoBlock.appendChild(toaCount);
document.getElementsByTagName('body')[0].appendChild(infoBlock);
window.oriTitle=document.title; //Save oringinal title
}
//Counting complete images
function imgReady(){
curCount.textContent=parseInt(curCount.textContent,10)+1;
document.title = curCount.textContent + toaCount.textContent;
}
//依據網址找出規則式編號
function chkIndex(){
for(var i=0;i<siteRule.length;i++)
if(location.href.indexOf(siteRule[i]) != -1) return i
}
function GMB() {
settingInfo();
var ruleIndex=chkIndex(); //規則式編號
var imgWidth=parseInt(GM_getValue('imgwidth')||240,10) //圖片寬度
GM_addStyle('.GMBtd img{max-width:@imgwidthpx}'.replace('@imgwidth',imgWidth));
var pics=document.querySelectorAll('img[src*="' + thumbRule[ruleIndex].replace('\\','') + '"]'); //全部縮圖
var picLinks=document.querySelectorAll(linkRule[ruleIndex]); //圖片超連結
var cols=parseInt(GM_getValue('cols')||3,10); //欄數
var intRows=Math.floor(pics.length / cols); //整數列
var leftPics=pics.length % cols; //剩餘圖片數
var patt=RegExp('(' + thumbRule[ruleIndex] + ')', 'i'); //原圖規則式
var htmlCode=[];
toaCount.textContent=' / ' + pics.length;
//先處理整數列
for(var i=0;i<intRows;i++)
{
htmlCode[htmlCode.length]='<tr>';
for(var j=0;j<cols;j++)
htmlCode[htmlCode.length]='<td class="GMBtd"><a target="_blank" href="' + picLinks[i*cols+j].href + '"><img src="'+ pics[i*cols+j].src.replace(patt,thumbRRule[ruleIndex])+'" /></a></td>';
htmlCode[htmlCode.length]='</tr>';
}
//再處理剩餘圖片
if(leftPics != 0)
{
htmlCode[htmlCode.length]='<tr>';
for(var k=0;k<leftPics;k++)
htmlCode[htmlCode.length]='<td class="GMBtd"><a target="_blank" href="' + picLinks[intRows*cols+k].href + '"><img src="'+ pics[intRows*cols+k].src.replace(patt,thumbRRule[ruleIndex])+'" /></a></td>';
htmlCode[htmlCode.length]='</tr>';
}
var tb=document.createElement('table');
tb.innerHTML=htmlCode.join('');
tb.id='GMB';
var oldContent=document.querySelector(contentRule[ruleIndex]);
oldContent.parentNode.replaceChild(tb,oldContent);
//綁定計算圖片完成數
var myPics=document.querySelectorAll('#GMB img');
for(var i=0;myPics[i];++i)
myPics[i].addEventListener('load',imgReady,false);
delete htmlCode;
delete pics;
delete picLinks;
}
window.addEventListener('DOMContentLoaded',GMB,false);
window.addEventListener('load',function() {document.title=oriTitle},false);
標籤
.net
(
17
)
工作
(
29
)
面試
(
2
)
筆記
(
2
)
筆記倉庫
(
1
)
嘸蝦米
(
2
)
繪圖
(
1
)
Add-on
(
4
)
Android
(
39
)
AngularJS
(
1
)
ASP.NET
(
14
)
AutoHotKey
(
20
)
AutoIt
(
3
)
batch
(
24
)
Blogger Hack
(
3
)
Bookmarklet
(
18
)
C#
(
16
)
Chrome
(
1
)
cmd
(
22
)
CSS
(
6
)
CSS3
(
6
)
D855
(
1
)
DOM
(
17
)
DragOnIt
(
5
)
EmEditor
(
1
)
English
(
1
)
ffmpeg
(
1
)
Firefox
(
25
)
flo
(
2
)
GIMP
(
1
)
gist
(
144
)
Graphviz
(
1
)
hardware
(
1
)
HDD
(
1
)
HTML5
(
4
)
i18n
(
1
)
IIS
(
4
)
ImageMagick
(
5
)
Java
(
1
)
JavaScript
(
92
)
jhead
(
1
)
jQuery
(
6
)
JSBin
(
19
)
jsFiddle
(
4
)
JSON
(
1
)
JustDoubleClick
(
1
)
Kindle
(
1
)
MSSQL
(
26
)
MySQL
(
2
)
Network
(
1
)
node.js
(
12
)
php
(
1
)
PowerShell
(
6
)
ramdisk
(
1
)
Reg
(
3
)
RegExp
(
3
)
rpi3
(
3
)
SJ2000
(
1
)
SQLite
(
3
)
SSD
(
1
)
Stylish
(
1
)
SublimeText
(
2
)
tips
(
6
)
userChrome.js
(
3
)
userscript
(
40
)
VB.net
(
9
)
VBScript
(
2
)
VisualStudio
(
2
)
Vue.js
(
3
)
Win
(
5
)
Win2008
(
1
)
Win7
(
29
)
WinAPI
(
1
)
Winform
(
1
)
WinXP
(
3
)
XML
(
1
)
Give Me Bigger
標籤:
userscript
學網連wretch速度很快,故開發此套件,方便逛相簿,搭配Website: cleaner - WRETCH使用,成效更佳。