Skip to content

Instantly share code, notes, and snippets.

@umnik1
Last active March 27, 2023 19:17
Show Gist options
  • Save umnik1/0a04da9573e5862f041e52a632cdde0f to your computer and use it in GitHub Desktop.
Save umnik1/0a04da9573e5862f041e52a632cdde0f to your computer and use it in GitHub Desktop.
DTFNewDislikeSystem
// ==UserScript==
// @name DTFNewDislikeSystem
// @namespace http://tampermonkey.net/
// @version 0.3
// @icon https://img.freepik.com/premium-vector/betty-boop-cowboys_690789-538.jpg
// @homepageURL https://dtf.ru/u/52199
// @description Новая система дизлайка
// @author Maksim Chingin
// @match https://dtf.ru/*
// @run-at document-start
// @grant GM.xmlHttpRequest
// @require http://code.jquery.com/jquery-3.4.1.min.js
// @require https://cdn.jsdelivr.net/npm/axios@v1.0.0-alpha.1/dist/axios.min.js
// @require https://cdn.jsdelivr.net/npm/axios-userscript-adapter@0.2.0-alpha.2
// ==/UserScript==
axios.defaults.adapter = axiosGmxhrAdapter;
function GM_addStyle(css) {
const style = document.getElementById("GM_addStyleBy8626") || (function() {
const style = document.createElement('style');
style.type = 'text/css';
style.id = "GM_addStyleBy8626";
document.head.appendChild(style);
return style;
})();
const sheet = style.sheet;
sheet.insertRule(css, (sheet.rules || sheet.cssRules || []).length);
}
(function() {
'use strict';
GM_addStyle(".like-button--action-dislike{float:left;margin-right: 15px;}");
GM_addStyle(".like-button--action-dislike .like-button__lottie{display:none;}");
GM_addStyle(".content-footer__item--right{display: flex;}");
GM_addStyle(".avatars{display:flex;width:66px;justify-content:space-between;align-items:center;margin-left:20px}");
GM_addStyle(".avatars__item{margin-left:-0.25rem;}");
GM_addStyle(".avatars__image{background-color:#d1d5db;rgb(89 89 89) 0px 0px 0px 0.05rem;color:#fff;font-size:.75rem;border-radius:50%;align-items:center;display:flex;justify-content:center;height:25px;width:25px;background-position: center !important;background-size: contain !important;}");
})();
var poop = '<svg xmlns="http://www.w3.org/2000/svg" version="1.0" width="18" height="20" viewBox="0 0 564.000000 464.000000" preserveAspectRatio="xMidYMid meet"><g transform="translate(0.000000,464.000000) scale(0.100000,-0.100000)" fill="#595959" stroke="none"><path d="M1690 4608 c-26 -14 -51 -35 -59 -52 -17 -36 -25 -98 -17 -130 7 -28 62 -96 78 -96 21 0 156 -133 193 -190 21 -33 42 -60 46 -60 9 0 63 -140 80 -205 6 -27 16 -56 22 -62 5 -7 7 -19 4 -27 -3 -7 0 -19 6 -25 7 -7 7 -14 1 -20 -5 -5 -106 -11 -224 -13 -202 -4 -220 -6 -300 -32 -142 -47 -214 -91 -326 -200 -86 -83 -110 -113 -147 -185 -43 -86 -60 -128 -58 -145 1 -4 -3 -13 -8 -20 -14 -16 -31 -129 -31 -201 0 -72 17 -185 31 -201 5 -7 9 -16 8 -20 -1 -5 3 -22 9 -37 15 -35 15 -37 1 -37 -22 0 -134 -54 -189 -91 -87 -58 -211 -186 -255 -264 -22 -38 -40 -72 -41 -75 0 -3 -9 -23 -18 -44 -61 -136 -61 -406 0 -542 9 -21 18 -41 19 -44 0 -3 8 -19 18 -36 l16 -32 -49 -20 c-27 -11 -76 -40 -110 -64 -34 -23 -73 -49 -86 -56 -58 -32 -175 -191 -219 -298 -15 -38 -35 -85 -44 -104 -23 -51 -23 -349 0 -400 9 -19 29 -65 44 -102 15 -37 39 -86 54 -110 40 -62 130 -168 149 -175 10 -4 35 -21 57 -39 55 -45 206 -119 281 -138 56 -14 283 -16 2196 -16 2087 0 2135 0 2204 20 81 22 210 87 271 136 23 19 46 34 51 34 13 0 101 102 145 167 18 27 46 81 61 119 16 38 36 85 44 104 32 72 24 430 -9 430 -5 0 -9 6 -9 14 0 8 -20 54 -45 102 -45 91 -149 225 -196 253 -14 9 -60 39 -102 67 -41 28 -87 54 -101 58 -29 7 -34 27 -12 45 18 15 62 152 76 233 56 346 -130 685 -458 835 -40 18 -80 33 -89 33 -13 0 -13 3 -3 15 7 8 9 15 5 15 -4 0 -3 6 3 13 40 48 55 301 26 430 -48 208 -221 424 -415 518 -126 61 -210 81 -371 86 l-148 5 0 46 c0 53 -19 172 -30 187 -4 6 -15 35 -25 65 -22 70 -84 190 -102 197 -7 3 -13 11 -13 19 0 8 -4 14 -10 14 -5 0 -10 6 -10 13 -1 16 -41 60 -115 123 -63 54 -112 86 -205 132 -30 15 -57 29 -60 32 -11 11 -110 41 -183 55 -64 12 -187 15 -671 15 l-592 0 -44 -22z m1253 -394 c90 -23 169 -67 239 -133 111 -104 163 -217 178 -383 10 -120 39 -188 106 -247 64 -56 120 -72 289 -80 139 -7 147 -9 218 -44 96 -47 167 -119 215 -216 36 -73 37 -77 37 -190 0 -106 -2 -121 -27 -175 -16 -32 -44 -81 -65 -108 -84 -116 -32 -246 105 -262 163 -20 239 -52 325 -137 67 -68 113 -157 130 -254 22 -131 -28 -280 -131 -384 -75 -77 -84 -94 -84 -149 0 -90 50 -145 142 -157 61 -8 176 -42 227 -67 61 -30 148 -126 186 -205 30 -64 32 -74 32 -183 0 -109 -2 -119 -32 -183 -36 -76 -116 -166 -181 -204 -23 -14 -70 -34 -103 -44 -59 -18 -127 -19 -1929 -19 -1802 0 -1870 1 -1929 19 -33 10 -80 30 -103 44 -65 38 -145 128 -181 204 -30 64 -32 74 -32 184 0 113 1 117 37 190 61 124 163 210 263 224 28 4 61 13 75 21 14 7 51 16 83 19 90 10 147 70 147 155 0 54 -10 71 -86 152 -35 38 -72 85 -83 105 -148 292 38 629 366 663 137 14 190 64 181 171 -4 43 -13 66 -46 113 -52 74 -82 153 -89 236 -13 153 73 324 205 409 89 57 120 63 342 71 236 9 274 18 349 86 55 50 90 120 98 199 11 101 -50 323 -131 480 -22 44 -42 83 -44 88 -2 4 141 7 318 7 260 0 334 -3 383 -16z"/></g></svg>';
// Проверяем, когда удобнее вставлять
$( document ).ready(function() {
setInterval(function() {
// Посты
$( ".content-footer" ).each(function( index ) {
if (!$(this).attr( "like-moved")) {
if ($(this).find('.content-footer__item .like-button--action-like').length > 0) {
$(this).find('.content-footer__item .like-button--action-like').appendTo($(this).find('.content-footer__item--right'));
$(this).attr( "like-moved", true);
$(this).find('.content-footer__item').eq(0).css('display', 'none');
$(this).find('.content-footer__item .like-button--action-dislike .like-button__icon').not("").html(poop);
$(this).find('.content-footer__item .like-button--action-dislike.like-button--active').html('<img src="https://dtfpass.ru/1dtf/poop_on.png" style="width: 19px;">');
// Отображаем кол-во дизлайков и аватарки
let id = $(this).parent().attr("data-content-id");
if (!id) {
var parse = $('.entry_data').attr("data-article-info");
parse = JSON.parse(parse);
id = parse.id;
}
if ( $(this).find('.content-footer__item .like-button--action-dislike .like-button__count').length == 0) {
axios.get("https://dtfpass.ru/dislike.php?id="+ id).then((res) => {
console.log(id, res.data);
if (res.data > 0) {
$(this).find('.content-footer__item .like-button--action-dislike').append('<span class="like-button__count">' + res.data + '</span>');
}
});
}
}
}
});
$( "button.like-button.like-button--default.like-button--action-dislike.like-button--active" ).click(function() {
$(this).html(poop);
});
$( "button.like-button.like-button--default.like-button--action-dislike").not(".like-button--active").click(function() {
$(this).html('<img src="https://dtfpass.ru/1dtf/poop_on.png" style="width: 19px;">');
$(this).find('img').animate({width: '25px'});
$(this).find('img').animate({width: '19px'});
});
// Комменты
$( ".comment" ).each(function( index ) {
if (!$(this).attr( "like-moved")) {
if ($(this).find('.comment__content .like-button--action-like').length > 0) {
$(this).find('.comment__content .like-button--action-like').insertAfter($(this).find('.like-button--action-dislike'));
$(this).attr( "like-moved", true);
$(this).find('.comment__content .like-button--action-dislike .like-button__icon').not("").html(poop);
$(this).find('.comment__content .like-button--action-dislike.like-button--active').html('<img src="https://dtfpass.ru/1dtf/poop_on.png" style="width: 19px;">');
}
}
});
$( "button.like-button.like-button--small.like-button--action-dislike.like-button--active" ).click(function() {
$(this).html(poop);
});
$( "button.like-button.like-button--small.like-button--action-dislike").not(".like-button--active").click(function() {
$(this).html('<img src="https://dtfpass.ru/1dtf/poop_on.png" style="width: 19px;">');
$(this).find('img').animate({width: '25px'});
$(this).find('img').animate({width: '19px'});
});
}, 1000);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment