Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Copy IMDB Title and ID to clipboard
- javascript:(function(){
- let titleElement = document.querySelector( '.title_wrapper > h1:nth-child(1)' );
- let imdbID = /\/tt(\d+)\//.exec( document.URL );
- if ( titleElement && imdbID ) {
- let newTitle = ( titleElement.innerText + " (tt" + imdbID[1] + ")" )
- .replace(/:/g, ' - ')
- .replace(/\s+/g, ' ')
- .replace(/^\s+/g, '')
- .replace(/\s+$/g, '');
- console.log( 'IMDB Bookmarklet - Suggested title: ' + newTitle );
- navigator.clipboard.writeText( newTitle ).then(
- status => console.log( 'IMDB Bookmarklet - Copied: ' + status ),
- status => console.log( 'IMDB Bookmarklet - Not copied: ' + status )
- ).catch( e => console.log( 'IMDB Bookmarklet - Could not copy: ' + e ) );
- } else {
- console.log( 'IMDB Bookmarklet - Something went wrong.' );
- console.log( 'Title Element:');
- console.log( titleElement );
- console.log( 'IMDB ID:');
- console.log( imdbID );
- }
- })()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement