Skip to content

Possible to move or copy existing element in DOM into a different location #20

Closed Answered by uBlock-user
peace2000 asked this question in Q&A
Discussion options

You must be logged in to vote

The point is to be able to place element X before element Y

/// insert-child-before.js
// is.fi##+js(insert-child-before, section.text-positive.bg-header-main, .nav-bar__link-bar)
 (() => {
		const selector = '{{1}}';
		if ( selector === '' || selector === '{{1}}' ) { return; }
	        const element = '{{2}}';
		if ( element === '' || element === '{{2}}' ) { return; }
		const behavior = '{{3}}';
		let timer = undefined;
		const insertelem = () => {
			try {
				const elems = document.querySelectorAll(selector);
				const nodes = document.querySelectorAll(element);
				for (let i = 0; i < elems.length; i++) {
				    elems[i].before(nodes[i]);
				}	
			} catch { }
	   	};
		const mutat…

Replies: 4 comments 16 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
7 replies
@uBlock-user
Comment options

@peace2000
Comment options

@uBlock-user
Comment options

@peace2000
Comment options

@uBlock-user
Comment options

Comment options

You must be logged in to vote
7 replies
@peace2000
Comment options

@uBlock-user
Comment options

@uBlock-user
Comment options

@peace2000
Comment options

@uBlock-user
Comment options

Comment options

You must be logged in to vote
2 replies
@peace2000
Comment options

@uBlock-user
Comment options

Answer selected by peace2000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants