nebigarci / Tweetdeck RT-FAV Takip

// ==UserScript==
// @name         Tweetdeck RT-FAV Takip
// @namespace   41c86413d9092c3aef3ba677bd3080e5
// @version      1.0.0
// @description  Tweetdeck üzerinden tweetlere favori ve retweet eden kullanıcıları hızlı bir şekilde takip edebilirsiniz.
// @author       Nebi Garcı
// @match        https://tweetdeck.twitter.com/*
// ==/UserScript==
setTimeout(function(){
	$("body > .js-app-loading").after('<div id="takip_nega" style="float: left;position: fixed;width: 50px;background: #000;color: #fff;top: 00px;left: 0px;z-index: 999999999;padding: 5px 0px;cursor: pointer;">Takip et</div><div id="tkp_kod" style="z-index: 999999999999;position: absolute;width: 100%;background: #fff;height: 40px;display: none;"><input id="key" type="text" name="key" value="" placeholder="x-td-oauth-key" style="float: left;display: block;width: 40%;margin: 6px 0px;"></input><input id="secret" type="text" value="" name="secret" placeholder="x-td-oauth-secret" style="float: left;display: block;width: 40%;margin: 6px 0;"></input><input id="tamamdir" style="float: left;padding: 4px 15px;font-size: 15px;margin: 5px;" value="Tamam" type="button"></input></input><input id="iptalet" style="float: left;padding: 4px 15px;font-size: 15px;margin: 5px;" value="İptal" type="button"></input></div>');
		$(".is-condensed .app-header").css("margin-top","25px")
		jQuery.cookie = function(name, value, options) {
	    if (typeof value != 'undefined') {
	        options = options || {};
	        if (value === null) {
	            value = '';
	            options.expires = -1;
	        }
	        var expires = '';
	        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
	            var date;
	            if (typeof options.expires == 'number') {
	                date = new Date();
	                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
	            } else {
	                date = options.expires;
	            }
	            expires = '; expires=' + date.toUTCString();
	        }
	        var path = options.path ? '; path=' + (options.path) : '';
	        var domain = options.domain ? '; domain=' + (options.domain) : '';
	        var secure = options.secure ? '; secure' : '';
	        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
		    } else {
		        var cookieValue = null;
		        if (document.cookie && document.cookie != '') {
		            var cookies = document.cookie.split(';');
		            for (var i = 0; i < cookies.length; i++) {
		                var cookie = jQuery.trim(cookies[i]);
		                if (cookie.substring(0, name.length + 1) == (name + '=')) {
		                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
		                    break;
		                }
		            }
		        }
		        return cookieValue;
		    }
		};
	$("#takip_nega").click(function(){
		var buton = $("#takip_nega").text()
		if(buton == "Durdur"){
			$("#takip_nega").removeClass("rt_bitti");
			$("#takip_nega").removeClass("fav_bitti");
			$("#takip_nega").text("Takip et");
			clearInterval(deck_takip);
			clearInterval(tweet_kontrol);
			clearInterval(rtfav_kontrol);
			$(".column-title-back.txt-ellipsis")[0].click();
		}
		if(buton == "Takip et"){
			$("#tkp_kod").css("display","block")
		}
	})
	$("#key").val($.cookie("nega_key"));
	$("#secret").val($.cookie("nega_secret"));
	$("#iptalet").click(function(){
		$("#tkp_kod").css("display","none")
	})
	$("#tamamdir").click(function(){
		$.cookie("nega_key", $("#key").val(), {expires:7});
		$.cookie("nega_secret", $("#secret").val(), {expires:7});
		var key = $("#key").val();
		var secret = $("#secret").val();
		$("#takip_nega").text("Durdur")
		if(key == "" || secret == ""){
			alert("lütfen doldurulması gereken alanları boş bırakmayın!")
		}
		if(key != "" && secret != ""){
			$("#tkp_kod").css("display","none")
			tweet_kontrol = setInterval(function(){
				var favlar = $(".js-tweet-stat.tweet-stat.txt-small.txt-mute[data-type='favoriters']").length
				if($(".rt_bitti").length == 1 && $(".fav_bitti").length == 0 && favlar == 1){
					$(".column-title-back.txt-ellipsis")[1].click();
					$(".js-tweet-stat.tweet-stat.txt-small.txt-mute[data-type='favoriters']")[0].click()
					$(".js-tweet-stat.tweet-stat.txt-small.txt-mute[data-type='favoriters']")[0].remove()
				}
			},3000)
			rtfav_kontrol = setInterval(function(){
				if($(".fav_bitti").length == 1){
					$(".stream-item.js-stream-item.is-actionable")[0].remove();
					$("#takip_nega").removeClass("fav_bitti");
					$("#takip_nega").removeClass("rt_bitti");
					$("#tamamdir").click();
				}
			},4000)
			var rt_bittimi = $(".rt_bitti").length
			var rtler = $(".js-tweet-stat.tweet-stat.txt-small.txt-mute[data-type='retweeters']").length
			if(rt_bittimi == 0 && rtler == 0){
				$(".pull-left.margin-txs.txt-mute.txt-small.is-vishidden-narrow")[0].click()
			}
			setTimeout(function(){
				if($(".js-tweet-stat.tweet-stat.txt-small.txt-mute[data-type='retweeters']").length == 1){
					$(".js-tweet-stat.tweet-stat.txt-small.txt-mute[data-type='retweeters']")[0].click()
					$(".js-tweet-stat.tweet-stat.txt-small.txt-mute[data-type='retweeters']")[0].remove()
				}
			},1500)
			setTimeout(function(){
					deck_takip = setInterval(function(){
						var rt_veya_fav = $(".is-shifted-2.js-column-state-social-proof").length
						var usr = $(".column-scroller > .stream-item.js-stream-item").length
						var usn = $(".js-stream-item > .item-box > .cf").find(".obj-left").attr("data-user-name");
						var rtler = $(".js-tweet-stat.tweet-stat.txt-small.txt-mute[data-type='retweeters']").length;
						var favlar = $(".js-tweet-stat.tweet-stat.txt-small.txt-mute[data-type='favoriters']").length
						if(rt_veya_fav == 1){
							if(usn != null){
								$.ajax({
									type: "POST",
								  	url: "https://tweetdeck.twitter.com/oauth/proxy/twitter/https%3A%2F%2Fapi.twitter.com%2F1.1%2Ffriendships%2Fcreate.json",
									data :{screen_name: usn, include_entities:1,include_user_entities:1,include_cards:1,send_error_codes:1},
									beforeSend:function(xhr){
										xhr.setRequestHeader("x-td-oauth-key", key);
										xhr.setRequestHeader("x-td-oauth-secret", secret);
										xhr.setRequestHeader("x-td-oauth-service", "twitter");
										xhr.setRequestHeader("x-twitter-client-version", "Twitter-TweetDeck-blackbird-chrome/3.9.296:21 web/");
									},
									statusCode: {
										403: function() {
											$("#takip_nega").text("Takip et")
											$("#takip_nega").removeClass("rt_bitti");
											$("#takip_nega").removeClass("fav_bitti");
											clearInterval(deck_takip);
											clearInterval(tweet_kontrol);
											clearInterval(rtfav_kontrol);
											alert("Şuan anda daha fazla takip yapamazsın!")
										}
									}
								});
							}
						}
						if(usr > 1){
							$(".column-scroller > .stream-item.js-stream-item")[0].remove()
						}
							if(rt_veya_fav == 1 && usn != null && usr == 1 && favlar == 1){
								$("#takip_nega").addClass("rt_bitti");
							}
							if(rt_veya_fav == 1 && usn != null && usr == 1 && favlar == 0){
								clearInterval(deck_takip);
								clearInterval(tweet_kontrol);
								$(".column-title-back.txt-ellipsis")[0].click();
								$("#takip_nega").addClass("fav_bitti");
								$("#takip_nega").text("Takip et");
							}
					},300)
			},1000)
		}
	})	
},20000)