Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions Extension/Content.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

const AUTHOR_HANDLE_LENGTH_CUTOFF = 100;

const randLength = 10;

const sirHighlightStyle = String.raw`
{
border-width: 2px;
Expand Down Expand Up @@ -95,6 +97,7 @@ const loc_templateUpdatePrompt = String.raw`
{caption} - Picture caption
{selection} - The text you have selected (trimmed to 128 symbols)
{tags} - Tags string
{rand} - random string
`;

function pick(element) {
Expand Down Expand Up @@ -161,6 +164,7 @@ function getNameBy(template) {
template = template.replace(/\{caption\}/g, getPictureName());
template = template.replace(/\{selection\}/g, selectionText);
template = template.replace(/\{tags\}/g, getTags());
template = template.replace(/\{rand\}/g, getRand(randLength));

template = template.replace(/\s{2,}/g, ' ').trim();

Expand All @@ -172,6 +176,17 @@ function getLinksArr() {
return array || [];
};

function getRand(randLength) {
const chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
let randString = "";

for (let i = 0; i < randLength; i++) {
randString += chars.charAt(Math.floor(Math.random() * chars.length));
}

return randString;
};
Comment thread
coderabbitai[bot] marked this conversation as resolved.

// ! Drag-able elderMagicField
var dragging = false;
var currentX, currentY, initialX, initialY;
Expand Down