forked from SO-Close-Vote-Reviewers/UserScripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SECloseVoteRequestGenerator-bookmarklet.min.js
1 lines (1 loc) · 1.93 KB
/
SECloseVoteRequestGenerator-bookmarklet.min.js
1
javascript:void(function(){function t(){try{history.replaceState({},'',a)}catch(t){}}var e,o={t:'Too Broad',u:'Unclear',p:'Primarily Opinion Based',o:'Opinion Based',d:'Duplicate',m:'No MCVE',r:'Typo or Cannot Reproduce',g:'General Computing',s:'Super User',f:'Server Fault',l:'Request for Off-Site Resource',get:function(t){var e=t.split(' ');return e.forEach(function(t,r){e[r]=o.hasOwnProperty(t)&&'get'!==t?o[t]:t}),e.join(' ')}},r=window,n=r.location,a=n.href,s=$(r),i=s.scrollTop(),l=StackExchange.notify,c=($('.special-status .question-status H2 B').filter(function(){return/hold|closed|marked/i.test($(this).text())}).length?'reopen':'cv')+'-pls',u='https://'+n.hostname,p=window.prompt('Request reason:','');if(p){p=o.get(p);var h,g='['+$('#question-header h1 a').text().replace(/(\[|\])/g,'\\$1').replace(/^\s+|\s+$/gm,'')+']('+u+$('#question .short-link').attr('href')+')',d=$('.post-signature.owner:not([align=\'right\'],#popup-close-question .post-signature) .user-details').text().trim().match(/[^\n]+/)[0].trim(),f=$('#question a.post-tag').first().text(),m=$('#question .owner:not(#popup-close-question .owner)'),v=$('a',m);v.length&&(d='['+d+']('+u+v.attr('href')+')');var y=$('.relativetime',m);y.length&&(h=y.attr('title'));var w='[tag:'+c+'] [tag:'+f+'] '+p+' '+g+' - '+d+(h?' - '+h:''),x='<textarea class=\'cvrg-result\' style=\'width:95%;display:block;margin:10px auto;\'>'+w+'</textarea>',T=$(x).appendTo(document.body),q='The text for your '+c;try{if(T[0].select(),!(e=document.execCommand('copy')))throw 1;var C='been copied to the clipboard.',O=q+' has '+C;l.show(O,483912),setTimeout(l.close,3e3,483912)}catch(t){var S=q+' is:',b=x,k='It has '+(e?'':'NOT ')+C;try{l.show(S+b+k+' You can press Ctrl-C now to copy it.',483912)}catch(t){alert(S+'\n\n'+w+'\n\n'+k)}}T.remove(),s.scrollTop(i),loopCount=0,setTimeout(function e(){loopCount++;var o=$('.cvrg-result');o.length?(o[0].select(),t()):loopCount<100?setTimeout(e,200):t()},200)}else t()}())