ScrapIT

By Justin eittreim Last update Aug 10, 2008 — Installed 625 times. Daily Installs: 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0

There are 2 previous versions of this script.

// ScrapIT user script
// version 0.2
// 2008-08-10
// Copyright (c) 2008, Justin Eittreim
// Released under the GPL license
// http://www.gnu.org/copyleft/gpl.html
//
// --------------------------------------------------------------------
//
// This is a Greasemonkey user script.
//
// To install, you need Greasemonkey: http://www.greasespot.net/
// Then restart Firefox and revisit this script.
// Under Tools, there will be a new menu item to "Install User Script".
// Accept the default configuration and install.
//
// To uninstall, go to Tools/Greasemonkey/Manage User Scripts,
// select "ScrapIT", and click Uninstall.
//
// --------------------------------------------------------------------
//
// ==UserScript==
// @name           ScrapIT
// @namespace      Kyogo.deviantart.com
// @description    Provides an easy way to scrap a deviation.
// @include        http://www.deviantart.com/submit/deviation?deviationId=*
// @include        http://*.deviantart.com/art/*
// ==/UserScript==

//Main.
with(unsafeWindow) {

//Both buttons.
var t_button = document.createElement('a');
var t_button2 = document.createElement('a');

//Store the source code of the current page to a variable.
var sourcecode = document.body.innerHTML;

//look to see if this deviation was submitted by our user...
if (sourcecode.match(/<a href="#" onclick="Deviation._delete((.*));return false">Delete Deviation<\/a>/)) {
	var i_T = document.getElementById("deviation-links");
	var i_S = i_T.getElementsByTagName("i");
	if( i_S[4] ) {
		var i_O = i_S[4];
	} else if( i_S[5] ) {
		var i_O = i_S[5];
	} else if( i_S[6] ) {
		var i_O = i_S[6];
	} else if( i_S[7] ) {
		var i_O = i_S[7];
	} else if( i_S[8] ) {
		var i_O = i_S[8];
	} else if( i_S[9] ) {
		var i_O = i_S[9];
	} else if( i_S[10] ) {
		var i_O = i_S[10];
	} else {
		var i_O = i_S[3];
	}
	var _l_ = sourcecode.split("http://www.deviantart.com/submit/deviation?deviationId=");
	var _l2_ = _l_[1].split("\"");
	var id_ = _l2_[0];

	//icon
	var t_spacer2 = document.createElement('i');
	
	//icon
	var t_spacer3 = document.createElement('i');

	//icons class
	t_spacer2.setAttribute("class","i9");

	//again
	t_spacer3.setAttribute("class","i13");

	//Capture clicks.
	if (t_button2.captureEvents) t_button2.captureEvents(Event.CLICK);

	//Set the mouse pointer on hover.
	t_button2.style.cursor = 'pointer';

	//Scrap buttons text.
	t_button2.innerHTML = 'Scrap Deviation';

	//And its ID.
	t_button2.setAttribute("id","scrap_deviation_button");

	//Insert a icon after the tag.
	i_O.parentNode.insertBefore(t_spacer2,i_O.nextSibling);

	//And the button after the icon.
	t_spacer2.parentNode.insertBefore(t_button2,t_spacer2.nextSibling);
	
	//Replace the icon taken away.
	t_button2.parentNode.insertBefore(t_spacer3,t_button2.nextSibling);
	
} else {

	var cookie_catch = getCookie('scrapit');
	if ( cookie_catch != null && cookie_catch != "" ) {
		
		//delete it.
		document.cookie="scrapit=true;expires=Fri, 07 Aug 2000 13:33:37 GMT;domain=.deviantart.com;path=/;host=.deviantart.com";
		
		//The tag that tells you what catergory it's in.
		var t_link = document.getElementById('categoryTitleDisplay');

		//What we set the value to.
		var t_val = document.getElementById('catDesc');

		//And the ID, otherwise the value is useless.
		var t_id = document.getElementById('categoryId');
		
		//the form
		var form3 = document.getElementById('form3');
		
		//And tell the user that it's been scrapped!
		t_link.innerHTML = '<font color="#a6bd44" style="italic"><b>Scrapped!</b></font>';
	
		//Set category.value to 'No Category' a.k.a (Scraps)
		t_val.value = "No Category";
		
		//Then category.ID to 1123, Scraps.
		t_id.value = "1123";
		
		//OK!
		SPDeviation.nextScreen('deviation', 'save');
		
	} else {
		
		//The tag that tells you what catergory it's in.
		var t_link = document.getElementById('categoryTitleDisplay');

		//What we set the value to.
		var t_val = document.getElementById('catDesc');

		//And the ID, otherwise the value is useless.
		var t_id = document.getElementById('categoryId');

		//Need a spacer between them!
		var t_spacer = document.createElement('span');

		//What the spacer looks like.
		t_spacer.appendChild(document.createTextNode(' | '));

		//Spacers ID.
		t_spacer.setAttribute("id","extendspacer");

		//Capture clicks.
		if (t_button.captureEvents) t_button.captureEvents(Event.CLICK);

		//Set the mouse pointer on hover.
		t_button.style.cursor = 'pointer';

		//Scrap buttons text.
		t_button.innerHTML = '<font color="#DD472F" style="bold"><b>Scrap</b></font>';

		//And its ID.
		t_button.setAttribute("id","scrap_deviation_button");

		//Insert a spacer after the tag.
		t_link.parentNode.insertBefore(t_spacer,t_link.nextSibling);

		//And the button after the spacer.
		t_spacer.parentNode.insertBefore(t_button,t_spacer.nextSibling);
	}
}

//Then when the user clicks the button...
t_button.onclick = function(e) {

	//Set category.value to 'No Category' a.k.a (Scraps)
	t_val.value = "No Category";
	
	//Then category.ID to 1123, Scraps.
	t_id.value = "1123";
	
	//And tell the user that it's been scrapped!
	t_link.innerHTML = '<font color="#a6bd44" style="italic"><b>Scrapped!</b></font>';
	
	//rid of the links
	t_spacer.style.display = "none";
	t_button.style.display = "none";
	
}

//Or the other button
t_button2.onclick = function(e) {
	document.cookie="scrapit=true;expires=Fri, 07 Aug 2011 13:33:37 GMT;domain=.deviantart.com;path=/;host=.deviantart.com";
	location.href = "http://www.deviantart.com/submit/deviation?deviationId="+id_;
}

//getCookie function
function getCookie(c_name) {
if (document.cookie.length>0) {
	c_start=document.cookie.indexOf(c_name + "=");
	if (c_start!=-1) {
		c_start=c_start + c_name.length+1;
		c_end=document.cookie.indexOf(";",c_start);
		if (c_end==-1) c_end=document.cookie.length;
			return unescape(document.cookie.substring(c_start,c_end));
	}
}
return "";
}

//end main
}