User:999real/JS

Show text with copy button like on this page

<syntaxhighlight lang="js" style="display: inline-block;" copy>

toggle scrolling down constantly in VisualFileChange view. It works as a toggle, it will scroll until you run/click the script again

javascript:(function() {
    if (window.scrollInterval) {
        clearInterval(window.scrollInterval);
        window.scrollInterval = null;
        return;
    }
		const scrollButton = document.querySelector("body > div.ui-dialog.ui-widget.ui-widget-content.ui-corner-all.ui-draggable.ui-resizable.ui-dialog-buttons > div.md-nav-button-container > div:nth-child(2) > a");
		const moreButton = document.getElementById('mdQueryMoreBtn');
    window.scrollInterval = setInterval(function() {
        scrollButton.click();
        moreButton.click();
    }, 1000);
})();
javascript:(function() {navigator.clipboard.writeText("https://www.tineye.com/search?url="+escape(document.getElementById("file").getElementsByTagName("img")[0].src))})();
javascript:(function() {window.open("https://www.tineye.com/search?url="+escape(document.getElementById("file").getElementsByTagName("img")[0].src))})();
javascript:(function() { navigator.clipboard.writeText(Array.from(document.getElementsByClassName('mw-file-description')).map(link => (link.getElementsByTagName("img")[0].src)).join('\n')) })();
javascript:(function() {const imgs = document.getElementsByClassName('mw-file-description'); for(let i=0; i < imgs.length; i++) window.open("https://www.tineye.com/search?url="+escape(imgs[i].getElementsByTagName("img")[0].src))})();
javascript:(function() {window.open("https://lens.google.com/uploadbyurl?url=" + encodeURIComponent(document.getElementById("file").getElementsByTagName("img")[0].src) + "&safe=off")})();
javascript:(function() {navigator.clipboard.writeText("https://lens.google.com/uploadbyurl?url=" + encodeURIComponent(document.getElementById("file").getElementsByTagName("img")[0].src) + "&safe=off")})();
 javascript:(function() {window.open("https://www.google.com/searchbyimage?sbisrc=4chanx&image_url=" + encodeURIComponent(document.getElementById("file").getElementsByTagName("img")[0].src) + "&safe=off")})();
 javascript:(function() {navigator.clipboard.writeText("https://www.google.com/searchbyimage?sbisrc=4chanx&image_url=" + encodeURIComponent(document.getElementById("file").getElementsByTagName("img")[0].src) + "&safe=off")})();


prompt to enter keyword and then select/deselect all images containing it in Cat a lot or VisualfileChange view

javascript:(function() {
    const searchString = prompt("Enter keyword");
    let elements = document.getElementsByClassName('gallerytext');
    if(elements.length === 0) elements = document.getElementsByClassName('cat_a_lot_label')  ;
    for (var i = 0; i < elements.length; i++) {
        const e = elements[i];
        if (e.textContent.includes(searchString)) {
            e.click();
            const checkBoxVFC = e.querySelector('input');
            if(checkBoxVFC) checkBoxVFC.checked ^= 1;
        }
    }
})();

Copy From_YouTube

javascript:(function() {     navigator.clipboard.writeText('{{From YouTube|' + window.location.href.split('?v=')[1].substring(0, 11)+ '|"' + document.querySelector('yt-formatted-string.ytd-watch-metadata:nth-child(1)').title + '"|t='+document.getElementsByClassName('ytp-time-current')[0].textContent.replace(':','m')+'s}}'); })();

Copy YouTube license template

javascript:(function() {const sdads = document.querySelector('ytd-channel-name.ytd-video-owner-renderer > div:nth-child(1) > div:nth-child(1) > yt-formatted-string:nth-child(1) > a:nth-child(1)'); navigator.clipboard.writeText('{{YouTube CC-BY|[' + sdads.href + ' ' + sdads.textContent + ']}}{{YouTubeReview}}');})();

Copy channel name with link

javascript:(function() {const sdads = document.querySelector('ytd-channel-name.ytd-video-owner-renderer > div:nth-child(1) > div:nth-child(1) > yt-formatted-string:nth-child(1) > a:nth-child(1)'); navigator.clipboard.writeText('[' + sdads.href + ' ' + sdads.textContent + ']');})();
javascript:(function() { navigator.clipboard.writeText(Array.from(document.querySelectorAll('.TablePager_col_img_name a:nth-child(1)')).map(link => link.href).join('\n')) })();
(function() {
	const toCopy = [];
	const titles = document.getElementsByClassName('jFileTitle');
	const dimensions = document.getElementsByClassName('jFileSize');
	
	const minimumWidth = 1000;
	const minimumHeight = 1000; 
	
	for (let i = 0; i < titles.length; i++) {
		const url = titles[i].href;
		if (url.endsWith('.mpg') || url.endsWith('.mpeg') || url.endsWith('.ogv') || url.endsWith('.webm')) {
			const ds = dimensions[i].textContent.replace(/^.*KiB/, '').replace('px', '');
			const width = ds.replace(/^.* x /, '');
			const height = ds.replace(/^ x .*/, '');
			if((minimumHeight > parseInt(height.replaceAll(' ', ''))) || (minimumWidth > parseInt(width.replaceAll(' ', '')))) toCopy.push(url);
		}
	}
	if (toCopy.length === 0) {
		alert('No videos with width below ' + minimumWidth + ' or height below ' + minimumHeight + ' found on this page');
	} else {
		navigator.clipboard.writeText(toCopy.join('\n')).then(() => {
			alert('Copied ' + toCopy.length + ' items');
		}).catch(err => {
			console.error('Failed to copy: ', err);
		});
	}
})();

Get the languages names from wikidata

(function() {
    let ds=[];
const sd=document.querySelectorAll('[data-wb-sitelinks-group="wikipedia"] .wikibase-sitelinkview-link');
   for(let i = 0;i<sd.length;i++){
       ds.push('|'+sd[i].getElementsByTagName('a')[0].hreflang + '='+sd[i].textContent);
   }
console.log(ds.join('\n'));
})();

Here is how I do it for archive.org collections 1st I scroll the whole collection then run this script in browser console this is to stop archive.org removing the pages when you scroll because it does that to save memory then scroll all the way back up

const scroller = document.querySelector('app-root').shadowRoot.querySelector('collection-page').shadowRoot.querySelector('collection-browser').shadowRoot.querySelector('infinite-scroller').shadowRoot;
const observer = new MutationObserver((mutations) => {
    // Now re-adding the pages when archive.org removes them so we can download all at the same time
    for (const mutation of mutations) {
        if (mutation.type === 'childList') {
            for (const node of mutation.removedNodes) {
                mutation.target.appendChild(node);
            }
        }
    }
});
observer.observe(scroller, { childList: true, subtree: true });

Next this is to copy the URLS and files names

let files = [];
for(const d of document.querySelector('app-root').shadowRoot.querySelector('collection-page').shadowRoot.querySelector('collection-browser').shadowRoot.querySelector('infinite-scroller').shadowRoot.querySelectorAll('tile-dispatcher')){
	const elem = d.shadowRoot.getElementById('container').getElementsByTagName('a')[0];
	const url = elem.href;
	const title = elem.ariaLabel.replace(': ', '-_').replaceAll(' ', '_') ;
	if(!title.includes('Index')) files.push(url.replace('details', 'download') + '/' + url.split('/').pop() + '.pdf' + ' ' + title + '.pdf');
}
console.log(files.join('\n'));

Violentmonkey userscripts

Import transfermarkt match to wikidata copy paste the Q elemnt from wikidata once and it will save it

// ==UserScript==
// @name		 Transfermarkt to Wikidata QuickStatements
// @namespace	Violentmonkey Scripts
// @version	  1.0
// @description  Import Transfermarkt match data to Wikidata
// @match		https://www.transfermarkt.com/spielbericht/index/spielbericht/*
// @match		https://www.transfermarkt.de/spielbericht/index/spielbericht/*
// @match		https://www.transfermarkt.*/spielbericht/index/spielbericht/*
// @grant		GM_setValue
// @grant		GM_getValue
// @license      CC0
// @author	  -
// ==/UserScript==

(function() {
	'use strict';

	const button = document.createElement('button');
	button.textContent = 'Import to Wikidata';
	button.style.cssText = 'position:fixed;bottom:20px;left:20px;z-index:9999;padding:10px 20px;background:#0645ad;color:white;border:none;border-radius:5px;cursor:pointer;font-size:14px;';
	document.body.appendChild(button);

	button.addEventListener('click', async () => {
    await processMatch();
	});

	async function processMatch() {
		const matchData = extractMatchData();
		const qStatements = await buildQuickStatements(matchData);
		showResultDialog(qStatements);
	}

	function extractMatchData() {
		const url = window.location.href;
		const matchId = url.match(/spielbericht\/(\d+)/)[1];

		const teamElements = document.querySelectorAll('.sb-team');
		const homeTeam = teamElements[0]?.querySelector('.sb-vereinslink')?.textContent.trim();
		const awayTeam = teamElements[1]?.querySelector('.sb-vereinslink')?.textContent.trim();

		const resultText = document.querySelector('.sb-endstand')?.textContent.trim();
		const scoreMatch = resultText?.match(/(\d+):(\d+)/);
		const homeScore = scoreMatch ? parseInt(scoreMatch[1]) : null;
		const awayScore = scoreMatch ? parseInt(scoreMatch[2]) : null;

		let winner = null;
		if (homeScore !== null && awayScore !== null) {
			if (homeScore > awayScore) winner = 'home';
			else if (awayScore > homeScore) winner = 'away';
		}

    const dateTextParentEl = document.getElementsByClassName('sb-datum')[0];
    const dataAs=dateTextParentEl.getElementsByTagName('a');
    const dateEl = dataAs[(dataAs.length>1 ? 1:0)];
    const dateText = dateEl.innerText;
	  const dateMatch = dateText?.match(/(\d{2})\/(\d{2})\/(\d{2})/);
		const pointInTime = dateMatch ? `+20${dateMatch[3]}-${dateMatch[2]}-${dateMatch[1]}T00:00:00Z/11` : null;

		let formattedDate = '';
		if (dateMatch) {
			const months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
			const day = parseInt(dateMatch[1]);
			const month = months[parseInt(dateMatch[2]) - 1];
			const year = `20${dateMatch[3]}`;
			formattedDate = `${day} ${month} ${year}`;
		}

		const stadium = document.querySelector('.sb-zusatzinfos a')?.textContent.trim();

		const competitionLink = document.querySelector('.direct-headline__link');
		const competition = competitionLink?.textContent.trim();

		const countryImg = document.querySelector('.icons-profil img');
		const countryAlt = countryImg?.alt;

		const isCountryMatch = homeTeam?.includes('national') || awayTeam?.includes('national') ||
							 competitionLink?.href?.includes('wettbewerb/WM') ||
							 competitionLink?.href?.includes('wettbewerb/EM');

		const matchLabel = `${homeTeam} vs ${awayTeam}, ${formattedDate}`;

		return {
			matchId,
			homeTeam,
			awayTeam,
			winner,
			pointInTime,
			stadium,
			competition,
			countryAlt,
			isCountryMatch,
			matchLabel
		};
	}

	async function buildQuickStatements(data) {
		const statements = ['CREATE'];

		//statements.push(`LAST\tScommonswiki\tCategory:"${data.matchLabel.replace(/"/g, '\\"')}"`);
		statements.push(`LAST\tLen\t"${data.matchLabel.replace(/"/g, '\\"')}"`);

		const instanceOf = data.isCountryMatch ?'Q12166442':'Q109623729';
		statements.push(`LAST\tP31\t${instanceOf}`);

		const sport = await getQItem('sport', 'Q2736 (association football)');
		if (sport && sport !== 'SKIP') {
			statements.push(`LAST\tP641\t${sport}`);
		}

		const country = await getQItem('country_' + data.countryAlt, `Country for ${data.countryAlt}`);
		if (country && country !== 'SKIP') {
			statements.push(`LAST\tP17\t${country}`);
		}

		if (data.pointInTime) {
			statements.push(`LAST\tP585\t${data.pointInTime}`);
		}

		const stadiumQ = await getQItem('stadium_' + data.stadium, `Stadium: ${data.stadium}`);
		if (stadiumQ && stadiumQ !== 'SKIP') {
			statements.push(`LAST\tP276\t${stadiumQ}`);
		}

		const homeTeamQ = await getQItem('team_' + data.homeTeam, `Home team: ${data.homeTeam}`);
		if (homeTeamQ && homeTeamQ !== 'SKIP') {
			statements.push(`LAST\tP1923\t${homeTeamQ}`);
		}

		const awayTeamQ = await getQItem('team_' + data.awayTeam, `Away team: ${data.awayTeam}`);
		if (awayTeamQ && awayTeamQ !== 'SKIP') {
			statements.push(`LAST\tP1923\t${awayTeamQ}`);
		}

		if (data.winner) {
			const winnerQ = data.winner === 'home' ? homeTeamQ : awayTeamQ;
			if (winnerQ && winnerQ !== 'SKIP') {
				statements.push(`LAST\tP1346\t${winnerQ}`);
			}
		}

		statements.push(`LAST\tP7455\t"${data.matchId}"`);

		const tournamentQ = await getQItem('tournament_' + data.competition, `Tournament: ${data.competition}`, true);
		if (tournamentQ && tournamentQ !== 'SKIP') {
			statements.push(`LAST\tP361\t${tournamentQ}`);
		}

		return statements.join('\n');
	}

	async function getQItem(key, description, allowSkip = false) {
		const stored = GM_getValue(key);
		if (stored) return stored;

		return new Promise((resolve) => {
			const overlay = document.createElement('div');
			overlay.style.cssText = 'position:fixed;top:0;left:0;right:0;bottom:0;background:rgba(0,0,0,0.5);z-index:10000;';

			const dialog = document.createElement('div');
			dialog.style.cssText = 'position:fixed;top:50%;left:50%;transform:translate(-50%,-50%);background:white;padding:30px;border-radius:8px;z-index:10001;min-width:400px;box-shadow:0 4px 6px rgba(0,0,0,0.3);';

			const title = document.createElement('h3');
			title.textContent = 'Enter Q-item';
			title.style.marginTop = '0';

			const desc = document.createElement('p');
			desc.textContent = description;
			desc.style.margin = '10px 0';

			const input = document.createElement('input');
			input.type = 'text';
			input.placeholder = 'Q12345';
			input.style.cssText = 'width:100%;padding:8px;margin:10px 0;border:1px solid #ccc;border-radius:4px;font-size:14px;';

			const hint = document.createElement('p');
			hint.style.cssText = 'font-size:12px;color:#666;margin:5px 0;';
			hint.textContent = allowSkip ?
				'Leave empty to skip forever, or type "skip" to skip once' :
				'Type "skip" to skip this value once';

			const btnContainer = document.createElement('div');
			btnContainer.style.cssText = 'margin-top:20px;display:flex;gap:10px;';

			const submitBtn = document.createElement('button');
			submitBtn.textContent = 'Submit';
			submitBtn.style.cssText = 'flex:1;padding:10px;background:#0645ad;color:white;border:none;border-radius:4px;cursor:pointer;font-size:14px;';

			const cancelBtn = document.createElement('button');
			cancelBtn.textContent = 'Cancel';
			cancelBtn.style.cssText = 'flex:1;padding:10px;background:#666;color:white;border:none;border-radius:4px;cursor:pointer;font-size:14px;';

			const cleanup = () => {
				overlay.remove();
				dialog.remove();
			};

			submitBtn.onclick = () => {
				const value = input.value.trim();

				if (value.toLowerCase() === 'skip') {
					cleanup();
					resolve('SKIP');
					return;
				}

				if (value === '' && allowSkip) {
					GM_setValue(key, 'SKIP');
					cleanup();
					resolve('SKIP');
					return;
				}

				if (value.match(/^Q\d+$/)) {
					GM_setValue(key, value);
					cleanup();
					resolve(value);
					return;
				}

				if (value === '') {
					cleanup();
					resolve(null);
					return;
				}

				input.style.borderColor = 'red';
				hint.textContent = 'Invalid Q-item format! Must be like Q12345';
				hint.style.color = 'red';
			};

			cancelBtn.onclick = () => {
				cleanup();
				resolve(null);
			};

			input.onkeypress = (e) => {
				if (e.key === 'Enter') submitBtn.click();
			};

			btnContainer.appendChild(submitBtn);
			btnContainer.appendChild(cancelBtn);

			dialog.appendChild(title);
			dialog.appendChild(desc);
			dialog.appendChild(input);
			dialog.appendChild(hint);
			dialog.appendChild(btnContainer);

			document.body.appendChild(overlay);
			document.body.appendChild(dialog);
			input.focus();
		});
	}

	function showResultDialog(statements) {
		const dialog = document.createElement('div');
		dialog.style.cssText = 'position:fixed;top:50%;left:50%;transform:translate(-50%,-50%);background:white;padding:20px;border:2px solid #0645ad;border-radius:8px;z-index:10000;max-width:600px;box-shadow:0 4px 6px rgba(0,0,0,0.1);';

		const title = document.createElement('h3');
		title.textContent = 'QuickStatements Output';
		title.style.marginTop = '0';

		const textarea = document.createElement('textarea');
		textarea.value = statements;
		textarea.style.cssText = 'width:100%;height:300px;font-family:monospace;margin:10px 0;';
		textarea.readOnly = true;

		const copyBtn = document.createElement('button');
		copyBtn.textContent = 'Copy to Clipboard';
		copyBtn.style.cssText = 'padding:8px 16px;background:#0645ad;color:white;border:none;border-radius:4px;cursor:pointer;margin-right:10px;';
		copyBtn.onclick = () => {
			textarea.select();
			document.execCommand('copy');
			copyBtn.textContent = 'Copied!';
			setTimeout(() => copyBtn.textContent = 'Copy to Clipboard', 2000);
		};

		const closeBtn = document.createElement('button');
		closeBtn.textContent = 'Close';
		closeBtn.style.cssText = 'padding:8px 16px;background:#666;color:white;border:none;border-radius:4px;cursor:pointer;';
		closeBtn.onclick = () => dialog.remove();

		dialog.appendChild(title);
		dialog.appendChild(textarea);
		dialog.appendChild(copyBtn);
		dialog.appendChild(closeBtn);
		document.body.appendChild(dialog);
	}
})();

Import photos from Mehr with URL2Commons

>User:999real/Mehr

Import photos from khamenei.ir with URL2Commons

>User:999real/khamenei.ir

Import photos from avash.ir with URL2Commons

>User:999real/Avash

Import photos from Tasnim with URL2Commons

>User:999real/Tasnim

Import photos from esfahanzibaonline.ir with URL2Commons

>User:999real/esfahanzibaonline.ir