Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name ThumbTools v2
- // @namespace thumbtools2
- // @description Thumb collecting tools
- // @include http://*.deviantart.com/*
- // ==/UserScript==
- // VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
- // BE AWARE: THIS CODE IS A MESS! Later I'll rewrite it in object oriented maner, but for now I was in a hurry!
- // If you plan to look into this code, do it at your on risk XD
- // ALSO: Please don't judge my coding based on this... I made this in a hurry within 2 days with no planning!
- if(GM_getValue('disable_thumbtools')){
- window.addEventListener('load', function(event) {
- if(!document.getElementById('ThumbTools')){
- /* Adding the ThumbTools Menu */
- var ThumbToolsMenu=document.createElement('div');
- ThumbToolsMenu.className='oh-ml';
- ThumbToolsMenu.innerHTML="\
- <a href='javascript:void(0);' class='oh-l'>Enable ThumbTools</a>";
- var separatorObject = ThumbToolsMenu;
- var overheadsc = document.getElementById('overhead').getElementsByClassName("oh-gap");
- overheadsc[0].parentNode.insertBefore(ThumbToolsMenu, overheadsc[0]);
- ThumbToolsMenu.addEventListener('click', function (){ GM_setValue('disable_thumbtools', false);window.location.reload(); }, false);
- }
- }, 'false');
- }else{
- var LastThumb;
- var LastActiveThumb;
- var userDeviant="";
- /* Event listener handeling thumb actions */
- function listentToThumbsOver(event) {
- //document.getElementById('thumbtoolsinfo').innerHTML="";
- /* First of all, let's find the Thumbs */
- if(event.target.tagName=='IMG'||(event.target.tagName="SPAN"&&event.target.className=="tt-bookendw")){
- if(event.target.parentNode.href.match(/http:\/\/[^\.]+\.deviantart\.com\/art\/[^\?]*\d+/) && event.target.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.className!="stack"){
- /* Hide the previous buttons container */
- if(LastThumb){ document.getElementById("buttons"+LastThumb).style.display="none"; }
- /* Now let's grep data */
- /* First of all the thumb code */
- grepid=new RegExp(/http:\/\/([^\.\/]+)\.deviantart\.com\/art\/[\w\d\-]+\-(\d+)/);
- deviationId=grepid.exec(event.target.parentNode.href);
- deviantId=deviationId[1];
- deviationId=deviationId[2];
- //document.getElementById('thumbtoolsinfo').innerHTML="(:thumb"+deviationId+":)"
- if(!document.getElementById("buttons"+deviationId)){
- event.target.id="image"+deviationId;
- /* Create buttons containter */
- var buttons=document.createElement('div');
- buttons.id="buttons"+deviationId;
- buttons.innerHTML="<input type='hidden' value='' id='timeout"+deviationId+"'></input>";
- /* Create the buttons in the container */
- var buttmp=document.createElement('a');
- buttmp.innerHTML="<img src='http://i170.photobucket.com/albums/u277/devillmeister/thumbsharetoolv2/add.png' id='selectButton"+deviationId+"'></img>";
- buttmp.title="Add/Remove thumb to/from list";
- buttmp.addEventListener('mousedown',addtolist, false);
- buttons.appendChild(buttmp);
- var buttmp=document.createElement('a');
- buttmp.innerHTML="<img src='http://i170.photobucket.com/albums/u277/devillmeister/thumbsharetoolv2/profile.png'></img>";
- buttmp.title="Visit the profile of "+deviantId;
- buttmp.href="http://"+deviantId+".deviantart.com/";
- buttons.appendChild(buttmp);
- var buttmp=document.createElement('a');
- buttmp.innerHTML="<img src='http://i170.photobucket.com/albums/u277/devillmeister/thumbsharetoolv2/gallery.png'></img>";
- buttmp.title="View the gallery of "+deviantId;
- buttmp.href="http://"+deviantId+".deviantart.com/gallery/";
- buttons.appendChild(buttmp);
- var buttmp=document.createElement('a');
- buttmp.innerHTML="<img src='http://i170.photobucket.com/albums/u277/devillmeister/thumbsharetoolv2/prints.png'></img>";
- buttmp.title="View the prints of "+deviantId;
- buttmp.href="http://"+deviantId+".deviantart.com/prints/";
- buttons.appendChild(buttmp);
- var buttmp=document.createElement('a');
- buttmp.innerHTML="<img src='http://i170.photobucket.com/albums/u277/devillmeister/thumbsharetoolv2/note.png'></img>";
- buttmp.title="Send a note to "+deviantId;
- buttmp.href="http://my.deviantart.com/notes/?deviant="+escape(deviantId)+"&body="+escape(":thumb"+deviationId+":")+"#new-note";
- buttons.appendChild(buttmp);
- if(userDeviant==deviantId){
- var buttmp=document.createElement('a');
- buttmp.innerHTML="<img src='http://i170.photobucket.com/albums/u277/devillmeister/thumbsharetoolv2/editdev.png'></img>";
- buttmp.title="Edit this deviation";
- buttmp.href="http://www.deviantart.com/submit/deviation?deviationId="+deviationId;
- buttons.appendChild(buttmp);
- }
- var buttmp=document.createElement('br');
- buttons.appendChild(buttmp);
- var buttmp=document.createElement('input');
- buttmp.type="text";
- buttmp.value=":thumb"+deviationId+":";
- buttmp.id="inputBox"+deviationId;
- buttmp.setAttribute('style', "background-color:#b4c8b0;border:0px;text-align:center;-moz-border-radius:0.3em;");
- buttmp.addEventListener('mouseover',function(){this.select()},false);
- buttons.appendChild(buttmp);
- /* modify style of buttons container */
- buttons.setAttribute('style', "padding:2px;background-color:#415248;position:absolute;z-index:510;-moz-border-radius:0.5em;");
- buttons.className="thumbToolsButtons"
- /* adding event listeners handling mouse activity of the pop-up */
- buttons.addEventListener('mouseout', listentToButtonsOut, false);
- buttons.addEventListener('mouseover', listentToButtonsOver, false);
- /* Appending the buttons container to the end of the page, and calculating it's absolut position */
- document.getElementById('deviantART-v7').appendChild(buttons);
- }else{
- /* If container already exitst make sure it's visible */
- buttons=document.getElementById("buttons"+deviationId)
- buttons.style.display="block";
- /* And there is no active timeout */
- clearTimeout(document.getElementById("timeout"+deviationId).value);
- }
- /* Positionong */
- targetPos=findPosition(event.target);
- if(GM_getValue('buttonsVPosition')){
- targetPos[1]=targetPos[1]-buttons.offsetHeight-3;
- }else{
- targetPos[1]=targetPos[1]+event.target.offsetHeight+3;
- }
- targetPos[0]=targetPos[0]+(event.target.offsetWidth-buttons.offsetWidth)/2
- buttons.style.left=targetPos[0]+"px";
- buttons.style.top=targetPos[1]+"px";
- updateSelectButton(deviationId);
- LastThumb=deviationId;
- }
- }
- }
- function grepData(targetimage){
- /* Thumb image source */
- thumbImgSrc=targetimage.src;
- /* Deviation page link href */
- deviationPageHref=targetimage.parentNode.href;
- }
- function addtolist(event){
- grepid=new RegExp(/buttons(\d+)/);
- deviationId=grepid.exec(event.target.parentNode.parentNode.id);
- deviationId=deviationId[1];
- collectedList=JSON.parse(GM_getValue('collectedList'));
- found=false;
- for(j in collectedList){
- if(collectedList[j].deviationId==deviationId){
- found=true;
- break;
- }
- }
- if(found){
- collectedList = collectedList.slice(0,j).concat(collectedList.slice(parseInt(j)+1));
- if(event.shiftKey && LastActiveThumb){
- reachedInterval=false;
- var removeList = new Array();
- for(i in imagesInDoc){
- if(imagesInDoc[i].parentNode.href && imagesInDoc[i].parentNode.href.match(/http:\/\/[^\.]+\.deviantart\.com\/art\/[^\?]*\d+/) && !imagesInDoc[i].parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.className=="stack"){
- grepid=new RegExp(/deviantart\.com\/art\/[\w\d\-]+\-(\d+)/);
- deviationId_i=grepid.exec(imagesInDoc[i].parentNode.href);
- deviationId_i=deviationId_i[1];
- if(deviationId_i==deviationId || deviationId_i==LastActiveThumb||reachedInterval){
- if(deviationId_i!=LastActiveThumb){
- removeList[deviationId_i]=true;
- }
- if(reachedInterval && (deviationId_i==deviationId || deviationId_i==LastActiveThumb)){
- break;
- }else{
- reachedInterval=true;
- }
- }
- }
- }
- for(i=collectedList.length-1;i>-1;i--){
- if(removeList[collectedList[i].deviationId]){
- collectedList = collectedList.slice(0,i).concat(collectedList.slice(parseInt(i)+1));
- }
- }
- }
- }else{
- if(event.shiftKey && LastActiveThumb){
- imagesInDoc=document.getElementsByTagName('img');
- reachedInterval=false;
- var addList = new Array();
- for(i in imagesInDoc){
- if(imagesInDoc[i].parentNode.href && imagesInDoc[i].parentNode.href.match(/http:\/\/[^\.]+\.deviantart\.com\/art\/[^\?]*\d+/) && imagesInDoc[i].parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.className!="stack"){
- grepid=new RegExp(/deviantart\.com\/art\/[\w\d\-]+\-(\d+)/);
- deviationId_i=grepid.exec(imagesInDoc[i].parentNode.href);
- deviationId_i=deviationId_i[1];
- imagesInDoc[i].id="image"+deviationId_i;
- if(deviationId_i==deviationId || deviationId_i==LastActiveThumb||reachedInterval){
- if(deviationId_i!=LastActiveThumb){addList.push(getDeviationData(deviationId_i));}
- if(reachedInterval && (deviationId_i==deviationId || deviationId_i==LastActiveThumb)){
- if(deviationId_i==LastActiveThumb){
- addList.reverse();
- newAdditionID=GM_getValue('Thumaddcounter');
- for(i in addList){
- addList[i].additionID=newAdditionID;
- newAdditionID+=1;
- }
- GM_setValue('Thumaddcounter',newAdditionID);
- }
- break;
- }else{
- reachedInterval=true;
- }
- }
- }
- }
- collectedList=collectedList.concat(addList);
- }else{
- collectedList.push(getDeviationData(deviationId));
- }
- }
- LastActiveThumb=deviationId;
- GM_setValue('collectedList',JSON.stringify(collectedList));
- updateListCounter();
- if(event.shiftKey){
- updateAllBorderIndicators();
- }
- updateSelectButton(deviationId);
- }
- function remallonpage(){
- collectedList=JSON.parse(GM_getValue('collectedList'));
- imagesInDoc=document.getElementsByTagName('img');
- var removeList = new Array();
- for(i in imagesInDoc){
- if(imagesInDoc[i].parentNode&&imagesInDoc[i].parentNode.href && imagesInDoc[i].parentNode.href.match(/http:\/\/[^\.]+\.deviantart\.com\/art\/[^\?]*\d+/)&& imagesInDoc[i].parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.className!="stack"){
- grepid=new RegExp(/deviantart\.com\/art\/[\w\d\-]+\-(\d+)/);
- deviationId_i=grepid.exec(imagesInDoc[i].parentNode.href);
- deviationId_i=deviationId_i[1];
- imagesInDoc[i].id="image"+deviationId_i;
- removeList[deviationId_i]=true;
- }
- }
- for(i=collectedList.length-1;i>-1;i--){
- if(removeList[collectedList[i].deviationId]){
- collectedList = collectedList.slice(0,i).concat(collectedList.slice(parseInt(i)+1));
- }
- }
- GM_setValue('collectedList',JSON.stringify(collectedList));
- updateAllBorderIndicators();
- updateListCounter();
- }
- function addallonpage(){
- collectedList=JSON.parse(GM_getValue('collectedList'));
- imagesInDoc=document.getElementsByTagName('IMG');
- for(i in imagesInDoc){
- if(imagesInDoc[i].parentNode && imagesInDoc[i].parentNode.href && imagesInDoc[i].parentNode.href.match(/http:\/\/[^\.]+\.deviantart\.com\/art\/[^\?]*\d+/)&& imagesInDoc[i].parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.className!="stack"){
- grepid=new RegExp(/deviantart\.com\/art\/[\w\d\-]+\-(\d+)/);
- deviationId_i=grepid.exec(imagesInDoc[i].parentNode.href);
- deviationId_i=deviationId_i[1];
- imagesInDoc[i].id="image"+deviationId_i;
- var found=false;
- for(i in collectedList){
- if(collectedList[i].deviationId==deviationId_i){
- found=true;
- break;
- }
- }
- if(!found)collectedList.push(getDeviationData(deviationId_i));
- }
- }
- GM_setValue('collectedList',JSON.stringify(collectedList));
- updateAllBorderIndicators();
- updateListCounter();
- }
- function getDeviationData(deviationId){
- var deviation_data= new Object()
- deviation_data.deviationId=deviationId;
- needToDownload=false;
- deviation_data.largeImageSrc="";
- deviation_data.thumbImageSrc="";
- if(document.getElementById("image"+deviationId).width<=150&&document.getElementById("image"+deviationId).height<=150){
- deviation_data.thumbImageSrc=document.getElementById("image"+deviationId).src;
- }else{
- needToDownload=true;
- }
- if(document.getElementById("image"+deviationId).parentNode.getAttribute('super_img')){
- deviation_data.largeImageSrc=document.getElementById("image"+deviationId).parentNode.getAttribute('super_img');
- }else{
- needToDownload=true;
- }
- deviation_data.thumbTarget=document.getElementById("image"+deviationId).parentNode.href;
- grepid=new RegExp(/^http:\/\/([^\.\/]+)\.deviantart\.com\/art\/[\w\d\-]+\-(\d+)/);
- deviantName=grepid.exec(deviation_data.thumbTarget);
- deviation_data.deviantName=deviantName[1];
- deviation_data.aspectratio=document.getElementById("image"+deviationId).width/document.getElementById("image"+deviationId).height;
- deviation_data.title="";
- deviation_data.date="";
- deviation_data.category="";
- deviation_data.timestamp=0;
- if(document.getElementById("image"+deviationId).parentNode.title){
- //Heart of glass by =knifeofdreams, Apr 9, 2010 in Photography > People & Portraits > Emotive Portraits
- //grepid=new RegExp("^(.*) by [^\w\d]"+deviation_data.deviantName+", (\w\w\w \d+, \d\d\d\d) in (.*)$","i");
- grepid=new RegExp("^(.+) by [^A-Za-z0-9]"+deviation_data.deviantName+"\, ([A-Z][A-Z][A-Z] [0-9]+\, [0-9]+) in.(.*)","i");
- titledata=grepid.exec(document.getElementById("image"+deviationId).parentNode.title);
- if(titledata){
- deviation_data.title=titledata[1];
- deviation_data.date=titledata[2];
- deviation_data.category=titledata[3];
- var d = Date.parse(deviation_data.date);
- deviation_data.timestamp=d;
- }else{
- needToDownload=true;
- }
- }else{
- needToDownload=true;
- }
- deviation_data.additionID=GM_getValue('Thumaddcounter');
- GM_setValue('Thumaddcounter',GM_getValue('Thumaddcounter')+1);
- if(needToDownload){
- GM_xmlhttpRequest({
- method: 'POST',
- data: "preview=preview&journalcss=&subject=&body=%3Athumb"+deviationId+"%3A\
- &supermoodid=24&song=&book=&movie=&game=&food=&drink=&flip=0&skinid=0&\
- skinlabel=Deviant+Green+%28default%29&jheader=&jcss=&jfooter=&skinid=0&skinlabel=Deviant+Green+%28default%29",
- url: 'http://my.deviantart.com/journal/update',
- headers: {
- 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
- 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
- "Content-Type": "application/x-www-form-urlencoded",
- },
- onload: function(responseDetails) {
- greppreview=new RegExp(/<div class="grf-indent">[\s\S]*?<a class="thumb([\s\S]*?)<\/a>/);
- tmp=responseDetails.responseText.match(greppreview);
- if(!tmp)console.log(responseDetails.responseText);
- tmp=tmp[1];
- collectedList=JSON.parse(GM_getValue('collectedList'));
- found=false;
- for(j in collectedList){
- if(collectedList[j].deviationId==deviationId){
- found=true;
- break;
- }
- }
- if(found){
- tmp2=tmp.match(/src="([^"]*)"/);
- collectedList[j].thumbImageSrc=tmp2[1];
- tmp2=tmp.match(/data-super-img="([^"]*)"/);
- if(tmp2)collectedList[j].largeImageSrc=tmp2[1];else collectedList[j].largeImageSrc=collectedList[j].thumbImageSrc;
- tmp2=tmp.match(/title="([^"]*)"/);
- grepid=new RegExp("^(.+) by [^A-Za-z0-9]"+deviation_data.deviantName+"\, ([A-Z][A-Z][A-Z] [0-9]+\, [0-9]+) in(.*)","i");
- titledata=grepid.exec(tmp2[1]);
- if(titledata){
- collectedList[j].title=titledata[1];
- collectedList[j].date=titledata[2];
- collectedList[j].category=titledata[3].replace(/ /gi," ").replace(/^ /,"");
- var d = Date.parse(collectedList[j].date);
- collectedList[j].timestamp=d;
- }
- }
- GM_setValue('collectedList',JSON.stringify(collectedList));
- }
- });
- }
- return deviation_data;
- }
- function updateSelectButton(deviationId){
- collectedList=JSON.parse(GM_getValue('collectedList'));
- found=false;
- for(i in collectedList){
- if(collectedList[i].deviationId==deviationId){
- found=true;
- break;
- }
- }
- if(found){
- document.getElementById('image'+deviationId).style.border='red solid 1px';
- document.getElementById('selectButton'+deviationId).src="http://i170.photobucket.com/albums/u277/devillmeister/thumbsharetoolv2/remove.png";
- }else{
- document.getElementById('image'+deviationId).style.border='none';
- document.getElementById('selectButton'+deviationId).src="http://i170.photobucket.com/albums/u277/devillmeister/thumbsharetoolv2/add.png";
- }
- }
- function updateAllBorderIndicators(){
- collectedList=JSON.parse(GM_getValue('collectedList'));
- var collectedList_Index = new Array();
- for(i in collectedList){
- collectedList_Index[collectedList[i].deviationId]=true;
- }
- imagesInDoc=document.getElementsByTagName('img');
- for(i in imagesInDoc){
- if(imagesInDoc[i].parentNode && imagesInDoc[i].parentNode.href && imagesInDoc[i].parentNode.href.match(/http:\/\/[^\.]+\.deviantart\.com\/art\/[^\?]*\d+/) && imagesInDoc[i].parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.className!="stack"){
- grepid=new RegExp(/deviantart\.com\/art\/[\w\d\-]+\-(\d+)/);
- deviationId=grepid.exec(imagesInDoc[i].parentNode.href);
- deviationId=deviationId[1];
- if(collectedList_Index[deviationId]){
- imagesInDoc[i].style.border='red solid 1px';
- }else{
- imagesInDoc[i].style.border='none';
- }
- }
- }
- }
- function updateListCounter(){
- collectedList=JSON.parse(GM_getValue('collectedList'));
- if(collectedList.length>0){
- document.getElementById('thumbtoolsinfo').innerHTML="("+collectedList.length+")";
- }else{
- document.getElementById('thumbtoolsinfo').innerHTML="";
- }
- }
- function listentToButtonsOver(event){
- /* Find the buttons container */
- targ=event.target;
- while(targ && targ.className!="thumbToolsButtons"){
- targ=targ.parentNode;
- }
- /* Stop the timer */
- if(targ){
- grepid=new RegExp(/buttons(\d+)/);
- deviationId=grepid.exec(targ.id);
- deviationId=deviationId[1];
- clearTimeout(document.getElementById("timeout"+deviationId).value);
- }
- }
- function listentToButtonsOut(event){
- /* Make sure we are exiting */
- reltarg=event.relatedTarget;
- while(reltarg && reltarg.className!="thumbToolsButtons"){
- reltarg=reltarg.parentNode;
- }
- /* Find the buttons container */
- targ=event.target;
- while(targ && targ.className!="thumbToolsButtons"){
- targ=targ.parentNode;
- }
- /* start timer */
- if(! reltarg && targ){
- grepid=new RegExp(/buttons(\d+)/);
- deviationId=grepid.exec(targ.id);
- deviationId=deviationId[1];
- timeout=setTimeout('document.getElementById("buttons'+deviationId+'").style.display="none";',GM_getValue('PopUpTimeOuts'));
- document.getElementById("timeout"+deviationId).value=timeout;
- }
- }
- function listentToThumbsOut(event) {
- if(event.target.tagName=='IMG'){
- if(event.target.parentNode&& event.target.parentNode.href.match(/http:\/\/[^\.]+\.deviantart\.com\/art\/[^\?]*\d+/)&& event.target.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.className!="stack"){
- /* First of all the thumb code */
- grepid=new RegExp(/deviantart\.com\/art\/[\w\d\-]+\-(\d+)/);
- deviationId=grepid.exec(event.target.parentNode.href);
- deviationId=deviationId[1];
- if(document.getElementById("buttons"+deviationId)){
- timeout=setTimeout('document.getElementById("buttons'+deviationId+'").style.display="none";',GM_getValue('PopUpTimeOuts'));
- document.getElementById("timeout"+deviationId).value=timeout;
- }
- }
- }
- }
- function timeOutButton(deviationId){
- document.getElementById("buttons"+deviationId).style.display="none";
- }
- /* Starting up the plug-in when the page has loaded */
- window.addEventListener('load', function(event) {
- if(!document.getElementById('ThumbTools')){
- if(document.getElementById('oh-menu-deviant')){
- grepid=new RegExp(/http:\/\/([^\/\.]+)\.deviantart\.com\//);
- deviantlink=document.getElementById('oh-menu-deviant').getElementsByTagName('a')[0];
- userDeviant=grepid.exec(deviantlink.href);
- userDeviant=userDeviant[1];
- }
- /* Dynamenu is for adding a new menu item, if a new release appeares! Here I update the dynamenu */
- if(!GM_getValue("dynamenu")){ GM_setValue("dynamenu",""); }
- var currentTime = new Date();
- nowStamp = currentTime.getTime();
- if(!GM_getValue("dynamenu_lastupdate_2_0_32")){ GM_setValue("dynamenu_lastupdate_2_0_32",String(nowStamp-1000*60*60*3)); }
- if(parseInt(GM_getValue("dynamenu_lastupdate_2_0_32"))+1000*60*60*3<parseInt(nowStamp) && userDeviant!=""){
- GM_xmlhttpRequest({
- method: 'POST',
- data: "uid="+userDeviant+"&rnd="+Math.floor(Math.random()*1000),
- url: 'http://datools.devillsroom.com/thumbtools/dynamenu_2_0_32.php',
- headers: {
- 'User-agent': navigator.userAgent,
- 'Accept': 'application/atom+xml,application/xml,text/xml',
- "Content-Type": "application/x-www-form-urlencoded",
- },
- onload: function(responseDetails) {
- if(GM_getValue("dynamenu")!=responseDetails.responseText){
- grepalert=new RegExp(/ALERT (.*) ALERT/);
- alertmsg=grepalert.exec(responseDetails.responseText);
- if(alertmsg){
- alert(alertmsg[1]);
- window.location.reload();
- }
- }
- GM_setValue("dynamenu",responseDetails.responseText);
- var currentTime = new Date();
- nowStamp = currentTime.getTime();
- GM_setValue("dynamenu_lastupdate_2_0_32", String(nowStamp));
- }
- });
- }
- if(!GM_getValue('collectedList')){ GM_setValue('collectedList',"[]"); }
- if(!GM_getValue('PopUpTimeOuts')){ GM_setValue('PopUpTimeOuts',500); }
- if(!GM_getValue('Thumaddcounter')){ GM_setValue('Thumaddcounter',1); }
- //var overheadsc = document.getElementById('overhead-sc');
- bugreportbody="Hi!\n\nOperating system and browser: "+navigator.userAgent+"\n\nBug Description:\n\n\n\n\nBye\n:dev"+userDeviant+":";
- /* Adding the ThumbTools Menu */
- var ThumbToolsMenu=document.createElement('div');
- ThumbToolsMenu.className='oh-ml';
- ThumbToolsMenu.innerHTML="\
- <div class='oh-menu'>\
- <a href='javascript:void(0);' class='mi' id='dathumbs_menu'><i class='i1' style='background:no-repeat center url(\"http://i170.photobucket.com/albums/u277/devillmeister/thumbsharetoolv2/dathumbs.png\")'></i><b>dA Thumbs</b></a>\
- <div class='oh-hr'></div>\
- <a href='javascript:void(0);' class='mi' id='clear_menu'><i class='i1' style='background:no-repeat center url(\"http://i170.photobucket.com/albums/u277/devillmeister/thumbsharetoolv2/clear.png\")'></i>Clear list</a>\
- <a href='javascript:void(0);' class='mi' id='addall_menu'><i class='i1' style='background:no-repeat center url(\"http://i170.photobucket.com/albums/u277/devillmeister/thumbsharetoolv2/add.png\")'></i>Add all on this page</a>\
- <a href='javascript:void(0);' class='mi' id='remall_menu'><i class='i1' style='background:no-repeat center url(\"http://i170.photobucket.com/albums/u277/devillmeister/thumbsharetoolv2/remove.png\")'></i>Remove all on this page</a>\
- <div class='oh-hr'></div>\
- <a href='javascript:void(0);' class='mi' id='send_notes' title='This will send the same note to each deviant, whose deviation is in the list.'><i class='i1' style='background:no-repeat center url(\"http://i170.photobucket.com/albums/u277/devillmeister/thumbsharetoolv2/note.png\")'></i>Send note to deviants</a>\
- <div class='oh-hr'></div>\
- <a href='javascript:void(0);' class='mi' id='settings_menu'><i class='i1' style='background:no-repeat center url(\"http://i170.photobucket.com/albums/u277/devillmeister/thumbsharetoolv2/settings.png\")'></i>Settings</a>\
- <a href='http://rdevill.deviantart.com/?givepoints ' class='mi'><i class='i1' style='background:no-repeat center url(\"http://i170.photobucket.com/albums/u277/devillmeister/thumbsharetoolv2/donate.png\")'></i>Donate points to developer</a>\
- <a href='http://rdevill.deviantart.com/art/DeviantArt-Thumbshare-Tool-108494740' class='mi'><i class='i1' style='background:no-repeat center url(\"http://i170.photobucket.com/albums/u277/devillmeister/thumbsharetoolv2/help.png\")'></i>Help</a>\
- <a href='http://my.deviantart.com/notes/?deviant=rdevill&subject=BUG report&body="+escape(bugreportbody)+"#new-note' class='mi'><i class='i1' style='background:no-repeat center url(\"http://i170.photobucket.com/albums/u277/devillmeister/thumbsharetoolv2/bug.png\")'></i>BUG report</a>\
- "+GM_getValue("dynamenu")+"\
- <div class='oh-hr'></div>\
- <a href='javascript:void(0);' class='mi' id='disable_thumbtools'><i class='i1' style='background:no-repeat center url(\"http://i170.photobucket.com/albums/u277/devillmeister/thumbsharetoolv2/switchoff.png\")'></i><b>Disable ThumbTools</b></a>\
- </div>\
- <a href='javascript:void(0);' class='oh-l'>ThumbTools <span id='thumbtoolsinfo'></span><img class='oh-mg' src='http://st.deviantart.net/minish/main/radbelow.png' height='11' width='11'></a>";
- /* Obsolate menu items
- <a href='javascript:void(0);' class='mi'><!--<i class='i1' style='background:no-repeat center url(\"http://i170.photobucket.com/albums/u277/devillmeister/htmlthumb.png\")'>--></i><span style='color:#425349;'>BIG Thumbs (Soon Coming)</span></a>\
- <a href='javascript:void(0);' class='mi'><i class='i1' style='background:no-repeat center url(\"http://i170.photobucket.com/albums/u277/devillmeister/htmltext.png\")'></i>HTML Text</a>\
- <a href='javascript:void(0);' class='mi'><i class='i1' style='background:no-repeat center url(\"http://i170.photobucket.com/albums/u277/devillmeister/htmlthumb.png\")'></i>HTML Thumbs</a>\
- <a href='javascript:void(0);' class='mi'><i class='i1' style='background:no-repeat center url(\"http://i170.photobucket.com/albums/u277/devillmeister/bbtext.png\")'></i>BB Text</a>\
- <a href='javascript:void(0);' class='mi'><i class='i1' style='background:no-repeat center url(\"http://i170.photobucket.com/albums/u277/devillmeister/bbthumb.png\")'></i>BB Thumbs</a>\
- */
- var separatorObject = ThumbToolsMenu;
- var overheadsc = document.getElementById('overhead').getElementsByClassName("oh-gap");
- overheadsc[0].parentNode.insertBefore(ThumbToolsMenu, overheadsc[0]);
- /* Add evet listeners to menu items */
- document.getElementById('dathumbs_menu').addEventListener('click', dathumbs_show, false);
- document.getElementById('clear_menu').addEventListener('click', clear_list, false);
- document.getElementById('addall_menu').addEventListener('click', addallonpage, false);
- document.getElementById('remall_menu').addEventListener('click', remallonpage, false);
- document.getElementById('send_notes').addEventListener('click', sendnotestolist, false);
- document.getElementById('settings_menu').addEventListener('click', settings_open, false);
- document.getElementById('disable_thumbtools').addEventListener('click', function (){ GM_setValue('disable_thumbtools', true);window.location.reload(); }, false);
- updateListCounter();
- updateAllBorderIndicators();
- //document.getElementById('thumbtoolsinfo').innerHTML="("+(parseInt(GM_getValue("dynamenu_lastupdate_2_0_31"))+1000*60*60*8)+" "+parseInt(nowStamp)+")";
- /* *********************************************************************************************************************************************************** */
- /* *********************************************************************************************************************************************************** */
- /* *********************************************************************************************************************************************************** */
- /* *********************************************************************************************************************************************************** */
- /* Handle note query strings*/
- if(!GM_getValue('blockReSend')){
- loc=window.location.href.toString();
- if(loc.match(/^http:\/\/my.deviantart.com\/notes/)){
- var qs = new Querystring()
- recipientFieldId=document.getElementById('friends').getAttribute("onchange").match(/["'](.*)["']\)\.value.*=/)[1];
- //alert(recipientFieldId);
- document.getElementById(recipientFieldId).value=qs.get('deviant',"");
- labels=document.getElementsByTagName('label');
- subjectFieldId="";
- for(l in labels){
- if(labels[l].innerHTML.match(/Subject/)){
- subjectFieldId=labels[l].getAttribute("for");
- break;
- }
- }
- document.getElementById(subjectFieldId).value=qs.get('subject',"");
- document.getElementById("notebody").value=qs.get('body',"");
- if(qs.get('autosend',0)){
- GM_setValue('blockReSend',1);
- elm=document.getElementById("send_note");
- evt = document.createEvent('MouseEvents');
- evt.initMouseEvent(
- 'click',
- true, // Click events bubble
- true, // and they can be cancelled
- document.defaultView, // Use the default view
- 1, // Just a single click
- 0, // Don't bother with co-ordinates
- 0,
- 0,
- 0,
- false, // Don't apply any key modifiers
- false,
- false,
- false,
- 0, // 0 - left, 1 - middle, 2 - right
- null); // Click events don't have any targets other than
- // the recipient of the click
- elm.dispatchEvent(evt);
- }
- }
- }else{
- GM_setValue('blockReSend',0);
- GM_setValue('closeiframe',1);
- var qs = new Querystring()
- if(qs.get('autosend',0)){
- window.location="?";
- }
- }
- }
- }, 'false');
- function sendnotestolist(){
- //sendnote("stereostock, knifeofdreams", "nagyon szeretlek!", "Imadlak meg mindig! \n\nTe vagy a legjobb!");
- collectedList=JSON.parse(GM_getValue('collectedList'));
- var deviantinlist_index=new Array();
- var deviantsInList=new Array();
- for(i in collectedList){
- if(!deviantinlist_index[collectedList[i].deviantName] && collectedList[i].deviantName!=userDeviant){
- deviantinlist_index[collectedList[i].deviantName]=1;
- deviantsInList.push(collectedList[i].deviantName);
- }
- }
- //alert(deviantsInList);
- GM_setValue('deviantsInList',JSON.stringify(deviantsInList));
- ShowHTMLDialog();
- document.getElementById('ThumbToolsHTMLDialog_content').innerHTML="\
- <div style='font-weight:bold;margin-bottom:12px;font-size:20px;'>Send message to deviants featured in current list!</div>\
- <b>Subject:</b><br/>\
- <input type='text' style='width:100%;' id='notesubject' value='Featured'></input>\
- <b>Message:</b><br/>\
- <textarea style='width:100%;height:320px' id='notebody'>Hi!\n\nYou've been featured! --PASTE-LINK-HERE--\n\nHave fun!\n:dev"+userDeviant+":\
- \n\n<sub>Message generated and sent with <a href='http://rdevill.deviantart.com/art/DeviantArt-Thumbshare-Tool-108494740'><b>ThumbTools</b></a></sub></textarea>\
- <b style='color:red'>IMPORTANT DISCLAIMER: </b>Please only use this tool to notify others about getting featured, and only at your own risk! \
- Sending the same note in large quantity to advertise yourself, your art, or any product is considered spamming, and <b>DeviantART will ban spammers! </b><br/><br/>\
- <input type='button' value='Send Notes' id='sendnotesbutton'></input>";
- document.getElementById('sendnotesbutton').addEventListener('click', startSendingNotes, false);
- }
- function startSendingNotes(){
- if(confirm('Are you sure, you wish to send this message to '+JSON.parse(GM_getValue('deviantsInList')).length+' deviants?')){
- GM_setValue('notesubject',document.getElementById('notesubject').value);
- GM_setValue('notebody',document.getElementById('notebody').value);
- document.getElementById('ThumbToolsHTMLDialog_content').innerHTML="\
- <div style='font-weight:bold;margin-bottom:12px;font-size:20px;'>Please wait while the messages are being sent!</div>\
- Please do not browse Deviant art until this is done! It can take up to 20 seconds to send a message!<br/>\
- <b>Sending message #<span id='messagenumber'>0</span> out of "+Math.ceil(JSON.parse(GM_getValue('deviantsInList')).length/15)+"</b>";
- sendNextNote();
- }
- }
- function sendNextNote(){
- deviantsInList=JSON.parse(GM_getValue('deviantsInList'));
- if(deviantsInList.length>0){
- nextround=deviantsInList.slice(0,15);
- deviantsInList=deviantsInList.slice(15);
- GM_setValue('deviantsInList',JSON.stringify(deviantsInList));
- nextround=nextround.join(', ');
- document.getElementById('messagenumber').innerHTML=""+(parseInt(document.getElementById('messagenumber').innerHTML)+1);
- //alert(nextround);
- //setTimeout(sendNextNote,2000);
- sendnote(nextround,GM_getValue('notesubject'),GM_getValue('notebody'))
- }else{
- a=document.getElementById("ThumbToolsHTMLDialog");
- b=document.getElementById("ThumbToolsHTMLDialog_transparentBack");
- a.parentNode.removeChild(a);
- b.parentNode.removeChild(b);
- alert('Your messages are out there!');
- }
- }
- function sendnote(recipient,subject,body){
- GM_setValue('closeiframe',0);
- GM_setValue('blockReSend',0);
- var el = document.createElement("iframe");
- el.setAttribute('id', 'ifrm');
- el.setAttribute('style','position:fixed;top:0px;left:0px;width:0px;height:0px;z-index:600;');
- document.body.appendChild(el);
- el.setAttribute('src', 'http://my.deviantart.com/notes/?deviant='+escape(recipient)+'&subject='+escape(subject)+'&body='+escape(body)+'&autosend=1#new-note');
- //el.setAttribute('src', 'http://my.deviantart.com/notes/#new-note');
- el.addEventListener('load',iframeOnLoad, false);
- }
- function iframeOnLoad(){
- if(GM_getValue('closeiframe')){
- GM_setValue('closeiframe',0);
- document.body.removeChild(document.getElementById('ifrm'));
- sendNextNote();
- }
- }
- function settings_open(){
- ShowHTMLDialog();
- document.getElementById('ThumbToolsHTMLDialog_content').innerHTML="\
- <div style='font-weight:bold;margin-bottom:12px;font-size:30px;'>Settings</div>\
- Where should the thumb pop-up appear?\
- <select id='buttons_position'>\
- <option value='1'>Over the image</option>\
- <option value='0'>Below the image</option>\
- </select>\
- <br/>\
- How long should the thumb pop-up remain visible?\
- <input id='buttons_popup_timout' type='text' value='"+GM_getValue('PopUpTimeOuts')+"'/> milliseconds\
- <br/><br/>\
- Show ThumbTools advert at the end of the thumbs list?\
- <select id='thumbs_advert_dropdown'>\
- <option value='0'>Enable</option>\
- <option value='1'>Disable</option>\
- </select>\
- <br/><br/>\
- <input type='button' id='thumbtools_settings_save' value='save'/>\
- ";
- if(GM_getValue('buttonsVPosition')){
- document.getElementById('buttons_position')[0].selected=true;
- }else{
- document.getElementById('buttons_position')[1].selected=true;
- }
- if(GM_getValue('disable_advert')){
- document.getElementById('thumbs_advert_dropdown')[1].selected=true;
- }else{
- document.getElementById('thumbs_advert_dropdown')[0].selected=true;
- }
- document.getElementById('thumbtools_settings_save').addEventListener('click', save_thumbtools_settings, false);
- }
- function save_thumbtools_settings(){
- if(document.getElementById('buttons_position').value==1){
- GM_setValue('buttonsVPosition',true);
- }else{
- GM_setValue('buttonsVPosition',false);
- }
- pu_timeout=parseInt(document.getElementById('buttons_popup_timout').value);
- GM_setValue('PopUpTimeOuts',pu_timeout)
- if(document.getElementById('thumbs_advert_dropdown').value==1){
- if(!GM_getValue('disable_advert',false) && confirm("The small advert at the end of the Thumbs list let's other people know about this script, so that they can enjoy it like you do! Are you sure you want to remove it?")){
- GM_setValue('disable_advert',true);
- }
- }else{
- GM_setValue('disable_advert',false);
- }
- document.getElementById("ThumbToolsHTMLDialog").style.display="none";document.getElementById("ThumbToolsHTMLDialog_transparentBack").style.display="none";
- }
- function dathumbs_show(){
- ShowHTMLDialog();
- document.getElementById('ThumbToolsHTMLDialog_content').innerHTML="\
- <div id='ThumbToolsHTMLDialog_topmenu'></div>\
- <div id='ThumbToolsHTMLDialog_subContainer'>\
- <textarea id='ThumbToolsOutput' style='width:100%;height:470px;margin-top:10px;background-color:#e0ee7df;border:none;'>"+generateOutput()+"</textarea>\
- <div id='ThumbToolsOutputPreview' style='width:100%;height:470px;overflow:auto;text-align:center;display:none;'></div>\
- </div>";
- document.getElementById('ThumbToolsOutput').select();
- var sortSelect=document.createElement('select');
- sortSelect.innerHTML="\
- <option value=''>Sort by:</option>\
- <option value='additionID'>Adding order</option>\
- <option value='aspectratio'>Aspect ratio</option>\
- <option value='category'>Category</option>\
- <option value='deviantName'>Deviant</option>\
- <option value='timestamp'>Submit date</option>\
- <option value='reverse'>Reverse order</option>\
- ";
- sortSelect.id="ThumbTools_SortSelect";
- //buttonRawdata.addEventListener('', rawdata_show, false);
- document.getElementById('ThumbToolsHTMLDialog_topmenu').appendChild(sortSelect);
- sortSelect.addEventListener('click', sortArray, false);
- var buttonJournalPreview=document.createElement('a');
- buttonJournalPreview.innerHTML="Preview";
- buttonJournalPreview.id="buttonJournalPreview";
- buttonJournalPreview.href="javascript:void(0);";
- buttonJournalPreview.style.marginLeft='8px';
- buttonJournalPreview.addEventListener('click', journalPreview, false);
- document.getElementById('ThumbToolsHTMLDialog_topmenu').appendChild(buttonJournalPreview);
- if(userDeviant=='rdevill'){
- var buttonRawdata=document.createElement('a');
- buttonRawdata.innerHTML="Raw Data";
- buttonRawdata.style.marginLeft='8px';
- buttonRawdata.href="javascript:void(0);";
- buttonRawdata.addEventListener('click', rawdata_show, false);
- document.getElementById('ThumbToolsHTMLDialog_topmenu').appendChild(buttonRawdata);
- }
- }
- function journalPreview(){
- if(document.getElementById('buttonJournalPreview').innerHTML=="Preview"){
- document.getElementById('ThumbToolsOutputPreview').style.display="block";
- document.getElementById('ThumbToolsOutputPreview').innerHTML="<h2>Please wait!</h2>";
- document.getElementById('ThumbToolsOutput').style.display="none";
- document.getElementById('buttonJournalPreview').innerHTML="Edit";
- GM_xmlhttpRequest({
- method: 'POST',
- data: "preview=preview&journalcss=&subject=&body="+escape(document.getElementById('ThumbToolsOutput').value)+"\
- &supermoodid=24&song=&book=&movie=&game=&food=&drink=&flip=0&skinid=0&\
- skinlabel=Deviant+Green+%28default%29&jheader=&jcss=&jfooter=&skinid=0&skinlabel=Deviant+Green+%28default%29",
- url: 'http://my.deviantart.com/journal/update',
- headers: {
- 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
- 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
- "Content-Type": "application/x-www-form-urlencoded",
- },
- onload: function(responseDetails) {
- greppreview=new RegExp(/<div class="grf-indent"><div class="text"><keeper for="Smoothie\.thumbs"><\/keeper><smoothie q="journal:0 by:my" qx="0" label="Journal: Devious Journal Entry" offset="0"><\/smoothie>(.*)<br\/><br\/><\/div> <div class="c ppb alink bottom">/);
- tmp=responseDetails.responseText.match(greppreview);
- document.getElementById('ThumbToolsOutputPreview').innerHTML=tmp[1];
- updateAllBorderIndicators();
- }
- });
- }else{
- document.getElementById('ThumbToolsOutputPreview').style.display="none";
- document.getElementById('ThumbToolsOutput').style.display="block";
- document.getElementById('ThumbToolsOutput').value=generateOutput();
- document.getElementById('buttonJournalPreview').innerHTML="Preview";
- updateAllBorderIndicators();
- }
- }
- function generateOutput(){
- collectedList=JSON.parse(GM_getValue('collectedList'));
- retVal="";
- for(i in collectedList){
- retVal+=":thumb"+collectedList[i].deviationId+": ";
- }
- if(!GM_getValue('disable_advert')){ retVal+="\n<br/><sub>Generated with <a href='http://rdevill.deviantart.com/art/DeviantArt-Thumbshare-Tool-108494740'><b>the ThumbshareTool</b></a></sub>";}
- return retVal;
- }
- function sortArray(){
- if(document.getElementById('ThumbTools_SortSelect').value){
- //method=document.getElementById('ThumbTools_SortSelect').value;
- collectedList=JSON.parse(GM_getValue('collectedList'));
- if(document.getElementById('ThumbTools_SortSelect').value=='reverse'){
- collectedList.reverse();
- }else{
- collectedList.sort(objectSort);
- }
- GM_setValue('collectedList',JSON.stringify(collectedList));
- generateOutput();
- document.getElementById('ThumbTools_SortSelect')[0].selected=true;
- document.getElementById('ThumbToolsOutput').value=generateOutput();
- }
- }
- function objectSort(a, b){
- method=document.getElementById('ThumbTools_SortSelect').value;
- if(method=='aspectratio' || method=='timestamp'||method=='additionID'){
- return parseFloat(a[method])-parseFloat(b[method]);
- }else{
- var A = a[method].toLowerCase();
- var B = b[method].toLowerCase();
- if (A < B){
- return -1;
- }else if (A > B){
- return 1;
- }else{
- return 0;
- }
- }
- }
- function rawdata_show(){
- document.getElementById('ThumbToolsOutputPreview').style.display="none";
- document.getElementById('ThumbToolsOutput').style.display="block";
- document.getElementById('ThumbToolsOutput').value=generateOutput();
- document.getElementById('buttonJournalPreview').innerHTML="Preview";
- document.getElementById('ThumbToolsOutput').value=GM_getValue('collectedList');
- }
- function ShowHTMLDialog(){
- if(document.getElementById('ThumbToolsHTMLDialog')){
- document.getElementById('ThumbToolsHTMLDialog').style.display='block';
- document.getElementById('ThumbToolsHTMLDialog_transparentBack').style.display='block';
- }else{
- var ThumbToolsHTMLDialog=document.createElement('div');
- ThumbToolsHTMLDialog.setAttribute('style', "background-color:black;opacity:0.7;border:0px;width:100%;height:100%;z-index:503;position:fixed;top:0;left:0;");
- ThumbToolsHTMLDialog.id="ThumbToolsHTMLDialog_transparentBack";
- document.getElementById('deviantART-v7').appendChild(ThumbToolsHTMLDialog);
- var ThumbToolsHTMLDialog=document.createElement('div');
- ThumbToolsHTMLDialog.setAttribute('style', "border:0px;width:100%;height:100%;z-index:506;position:fixed;top:0;left:0;");
- ThumbToolsHTMLDialog.innerHTML="\
- <div style='position:absolute;top:50%;left:50%;margin:0px;padding:0px;'>\
- <div style='position:relative;margin:0px;padding:10px;top:-250px;left:-350px;width:700px;height:500px;background-color:#b4c8b0;border:0px;-moz-border-radius:10px;'>\
- <a href='javascript:void(0);' style='float:right;' onclick='a=document.getElementById(\"ThumbToolsHTMLDialog\");b=document.getElementById(\"ThumbToolsHTMLDialog_transparentBack\");a.parentNode.removeChild(a);b.parentNode.removeChild(b);'>Close</a>\
- <div id='ThumbToolsHTMLDialog_content' style='width:100%;height:100%;'></div>\
- </div>\
- </div>";
- ThumbToolsHTMLDialog.id="ThumbToolsHTMLDialog";
- document.getElementById('deviantART-v7').appendChild(ThumbToolsHTMLDialog);
- }
- }
- function clear_list(){
- GM_setValue('collectedList',"[]");
- updateListCounter();
- updateAllBorderIndicators();
- }
- /* Find absolute position of an element */
- function findPosition( oElement ) {
- if( typeof( oElement.offsetParent ) != 'undefined' ) {
- for( var posX = 0, posY = 0; oElement; oElement = oElement.offsetParent ) {
- posX += oElement.offsetLeft;
- posY += oElement.offsetTop;
- }
- return [ posX, posY ];
- } else {
- return [ oElement.x, oElement.y ];
- }
- }
- /* JSON encode and decode implementation */
- var JSON = JSON || {};
- // implement JSON.stringify serialization
- JSON.stringify = JSON.stringify || function (obj) {
- var t = typeof (obj);
- if (t != "object" || obj === null) {
- // simple data type
- if (t == "string") obj = '"'+obj+'"';
- return String(obj);
- }
- else {
- // recurse array or object
- var n, v, json = [], arr = (obj && obj.constructor == Array);
- for (n in obj) {
- v = obj[n]; t = typeof(v);
- if (t == "string") v = '"'+v+'"';
- else if (t == "object" && v !== null) v = JSON.stringify(v);
- json.push((arr ? "" : '"' + n + '":') + String(v));
- }
- return (arr ? "[" : "{") + String(json) + (arr ? "]" : "}");
- }
- };
- // implement JSON.parse de-serialization
- JSON.parse = JSON.parse || function (str) {
- if (str === "") str = '""';
- eval("var p=" + str + ";");
- return p;
- };
- /* Adding event listeners */
- document.addEventListener('mouseover', listentToThumbsOver, false);
- document.addEventListener('mouseout', listentToThumbsOut, false);
- }
- /* Query string parser */
- function Querystring(qs) { // optionally pass a querystring to parse
- this.params = {};
- if (qs == null) qs = location.search.substring(1, location.search.length);
- if (qs.length == 0) return;
- // Turn <plus> back to <space>
- // See: http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.13.4.1
- qs = qs.replace(/\+/g, ' ');
- var args = qs.split('&'); // parse out name/value pairs separated via &
- // split out each name=value pair
- for (var i = 0; i < args.length; i++) {
- var pair = args[i].split('=');
- var name = decodeURIComponent(pair[0]);
- var value = (pair.length==2)
- ? decodeURIComponent(pair[1])
- : name;
- this.params[name] = value;
- }
- }
- Querystring.prototype.get = function(key, default_) {
- var value = this.params[key];
- return (value != null) ? value : default_;
- }
- Querystring.prototype.contains = function(key) {
- var value = this.params[key];
- return (value != null);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement