User:1Veertje/mubi.js
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Press Ctrl-F5.
var id = null;
var json =JSON.parse( document.getElementById('__NEXT_DATA__').text);
if (json['page'] == "/cast/[castSlug]"){
id = json['props']["initialProps"]["pageProps"]["castMember"]['id'];
}
else if(json['page'] == "/films/[filmSlug]"){
id = json['props']["initialProps"]["pageProps"]["initFilm"]['id'];
}
//Copy to clipboard
//Stefan Maric stefanmaric
//https://gist.github.com/stefanmaric/2abf96c740191cda3bc7a8b0fc905a7d
if (id != null){
var node = document.createElement('textarea')
node.textContent = id
document.body.appendChild(node)
// var selection = document.getSelection().removeAllRanges()
node.select()
node.setSelectionRange(0, 99999);
document.execCommand('copy')
// selection.removeAllRanges()
document.body.removeChild(node)
}