Last active
February 17, 2021 16:47
-
-
Save akinov/95cf1c427ce26198a5bfc9c6b70ec109 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name messenger ninja | |
// @namespace https://gist.github.com/akinov/95cf1c427ce26198a5bfc9c6b70ec109 | |
// @version 0.1 | |
// @description ninja! | |
// @author akinov | |
// @grant none | |
// @match https://www.messenger.com/* | |
/* load jQuery */ | |
// @require https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
const nekoSrc = 'https://pbs.twimg.com/profile_images/424484505915621376/EOwsjaMZ_400x400.png', | |
nekoName = '猫田 猫男'; | |
const $toggeBtn = $('<div>🎭</div>').css({ | |
position: 'fixed', | |
right: '10px', | |
bottom: '10px', | |
'z-index': '1000' | |
}).on('click', toggleNinja); | |
$('body').append($toggeBtn); | |
function toggleNinja() { | |
$('._1t2u ._4ld- > img, ._1t2u ._1jt6 img, .uiScrollableAreaContent ._55lt img').each(function() { | |
const $this = $(this); | |
if (!$this.attr('origin-src')) { | |
$this.attr('origin-src', $this.attr('src')); | |
} | |
toggleImg($this); | |
}); | |
$('._3oh- a, .uiScrollableAreaContent ._1ht6').each(function() { | |
const $this = $(this); | |
if (!$this.attr('origin-text')) { | |
$this.attr('origin-text', $this.text()); | |
} | |
toggleText($this); | |
}); | |
} | |
function toggleImg($this) { | |
if ($this.attr('origin-src') == $this.attr('src')) { | |
$this.attr('src', nekoSrc); | |
} else { | |
$this.attr('src', $this.attr('origin-src')); | |
} | |
} | |
function toggleText($this) { | |
if ($this.attr('origin-text') == $this.text()) { | |
$this.text(nekoName); | |
} else { | |
$this.text($this.attr('origin-text')); | |
} | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What exactly does this script do?