Skip to content

Instantly share code, notes, and snippets.

@Aikufurr Aikufurr/esix-Assistant.js
Last active Oct 24, 2019

Embed
What would you like to do?
Adds useful option for tags on esix, see comments
// ==UserScript==
// @name esix Assistant
// @namespace http://tampermonkey.net/
// @version 0.2
// @description Adds useful option for tags on esix
// @author Aikufurr
// @match https://e621.net/*
// @match https://e926.net/*
// @grant none
// ==/UserScript==
(function () {
'use strict';
//start
var copy = `
function fallbackCopyTextToClipboard(text) {
var textArea = document.createElement("textarea");
textArea.value = text;
document.body.appendChild(textArea);
textArea.focus();
textArea.select();
try {
var successful = document.execCommand('copy');
var msg = successful ? 'successful' : 'unsuccessful';
console.log('Fallback: Copying text command was ' + msg);
} catch (err) {
console.error('Fallback: Oops, unable to copy', err);
}
document.body.removeChild(textArea);
}
function copyTextToClipboard(text) {
if (!navigator.clipboard) {
fallbackCopyTextToClipboard(text);
return;
}
navigator.clipboard.writeText(text).then(function () {
console.log('Async: Copying to clipboard was successful!');
alert("Copied to Clipboard")
}, function (err) {
console.error('Async: Could not copy text: ', err);
});
}
function e6main(text) {
if (document.querySelector('input[name="E6WTD"]:checked').value == "clipboard") {
copyTextToClipboard(text);
}
if (document.querySelector('input[name="E6WTD"]:checked').value == "search") {
document.getElementById('tags').value = document.getElementById('tags').value + " " + text
}
if (document.querySelector('input[name="E6WTD"]:checked').value == "new") {
window.location = "/post/index/1/" + text;
}
}
`;
var script = document.createElement("script");
script.setAttribute('type', 'text/javascript');
script.innerHTML = copy;
document.head.appendChild(script);
document.querySelector('.sidebar').children[0].innerHTML = document.querySelector('.sidebar').children[0].innerHTML + `<br>
<div id="whatToDo" style="background-color:#214b89;">
<input type="radio" name="E6WTD" id="CTclipboard" value="clipboard">
<label for="CTclipboard">Copy to clipboard</label><br>
<input type="radio" name="E6WTD" id="ATsearch" value="search" checked>
<label for="ATsearch">Add to search</label><br>
<input type="radio" name="E6WTD" id="ATnew" value="new">
<label for="ATnew">Search for this tag</label>
</div>
<br>`;
var ul = document.getElementById("tag-sidebar");
var items = ul.getElementsByTagName("li");
for (var i = 0; i < items.length; ++i) {
try {
items[i].childNodes[items[i].childNodes.length - 3].outerHTML = unescape(`<a onclick='e6main("${items[i].childNodes[items[i].childNodes.length - 3].text.replace(/ /g, "_")}")' href="/post/search?tags=${items[i].childNodes[items[i].childNodes.length - 3].text.replace(/ /g, "_")}">${items[i].childNodes[items[i].childNodes.length - 3].text}</a></span>`)
} catch (e) {}
}
jQuery("li").click(function (e) {
if (this.classList[0].includes("tag")) {
e.preventDefault();
}
});
jQuery('#tags').after('<input type="submit" value="Submit">');
jQuery('a:contains("Resize image")').remove();
jQuery('#image').css({
'max-width': '100%',
'width': 'auto',
'height': 'auto',
'max-height': '90vh'
});
//end
})();
@Aikufurr

This comment has been minimized.

Copy link
Owner Author

Aikufurr commented Oct 24, 2019

This Tampermonkey script adds some useful tools and changes to e6 and e9.

Features:

  • Tag options such as copying tag to clipboard (includes _ if it has a space), Adding the clicked tag to the search bar (adds a space for seperation and a _ if the tag itself has a space), and the default searching for tags.
    screenshot of tag options

  • Image scaling so the image height doesn't go below the view-port, useful for larger images

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.