JVC contenu

Lire directement les tweets

  1. // ==UserScript==
  2. // @name JVC contenu
  3. // @namespace Jvc contenu
  4. // @version 1.0.5
  5. // @description Lire directement les tweets
  6. // @author Personne
  7. // @require http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
  8. // @match http://www.jeuxvideo.com/forums/*
  9. // @match http://m.jeuxvideo.com/forums/*
  10. // @match http://jvforum.fr/*
  11. // @connect publish.twitter.com
  12. // @connect opengraph.io
  13. // @grant GM_xmlhttpRequest
  14. // @noframes
  15. // ==/UserScript==
  16.  
  17.  
  18. (function() {
  19.  
  20. get_contenu(true);
  21.  
  22. $("body").append('<div id="ytb-player" style="display:none;opacity:0.95;background:black;position:fixed;top:100px;right:40px;width:320px;height:180px;"><div id="contenu-ytb"></div><div id="ytb-close" style="position: absolute; top: -32px; right: 0px;"><img style="width:32px;cursor:pointer;" src="https://cdn0.iconfinder.com/data/icons/very-basic-android-l-lollipop-icon-pack/24/close-128.png"></div></div>');
  23.  
  24. $("#ytb-close").click(function(){
  25. $("#contenu-ytb").html('');
  26. $("#ytb-player").css('display','none');
  27. });
  28.  
  29. function mydebug(data){
  30. console.log('[JVC-contenu]');
  31. console.log(data);
  32. }
  33.  
  34.  
  35.  
  36. function get_params(param) {
  37. var vars = {};
  38. window.location.href.replace( location.hash, '' ).replace(
  39. /[?&]+([^=&]+)=?([^&]*)?/gi, // regexp
  40. function( m, key, value ) { // callback
  41. vars[key] = value !== undefined ? value : '';
  42. }
  43. );
  44.  
  45. if ( param ) {
  46. return vars[param] ? vars[param] : null;
  47. }
  48. return vars;
  49. }
  50.  
  51.  
  52. function get_contenu(interval){
  53. var getLocation = function(href) {
  54. var l = document.createElement("a");
  55. l.href = href;
  56. return l;
  57. };
  58. $('.txt-msg a.xXx,.message__content-text a').each(function(){
  59.  
  60. var regex = new RegExp("^https?://(mobile.)?twitter\.com/[A-Za-z0-9_]{1,15}/status(es)?/([0-9]+)");
  61. var insta = new RegExp("^https?://(www\.)?instagram\.com/p/([A-Za-z0-9_-]+)");
  62. var face = new RegExp("^https:\/\/www\.facebook\.com\/([^\/?].+\/)?video(s|\.php)[\/?].*");
  63. var face2 = new RegExp("^https:\/\/www\.facebook\.com\/(photo(\.php|s)|permalink\.php|media|questions|notes|[^\/]+\/(activity|posts))[\/?].*");
  64. var youtube = new RegExp('(?:youtube\.com\/(?:[^\/]+\/.+\/|(?:v|e(?:mbed)?)\/|.*[?&]v=)|youtu\.be\/)([^"&?\/ ]{11})');
  65.  
  66. // console.log("[JVC-Contenu]"+$(this).parent().attr('class'));
  67.  
  68. var url = ($(this).attr('href'));
  69.  
  70. if($(this).attr('data-contenu') == '1' ){
  71. return true;
  72. }
  73.  
  74. $(this).attr('data-contenu','1');
  75.  
  76. var id;
  77.  
  78. var obj = $(this);
  79.  
  80. if(youtube.test(url)){
  81.  
  82. match = youtube.exec(url);
  83. id = match[1];
  84.  
  85. html = "<div style='position:relative; ' >";
  86. html += "<a data-ytb-id='"+id+"' data-ytb='"+url+"' class='contenu-ytb-player' data-contenu='1' style='height: 50px; left: 18%; top: 30%; position: absolute; z-index: 40; opacity: 0.7;' target='blank_' href='"+url+"'><img style='height: 50px;' src='https://cdn4.iconfinder.com/data/icons/iconsimple-logotypes/512/youtube-128.png'></a>";
  87. html += "<a data-ytb-id='"+id+"' data-ytb='"+url+"' class='contenu-ytb-player' data-contenu='1' target='blank_' href='"+url+"'><img style='border-radius: 5px;max-width:250px;max-height:250px;' src='http://img.youtube.com/vi/"+id+"/mqdefault.jpg'></a></div>";
  88. obj.html(html);
  89.  
  90. $('.contenu-ytb-player').click(function(){
  91. var lien = $(this).data('ytb');
  92.  
  93. var reg_t = new RegExp("[&?]t=([0-9a-zA-Z]+)");
  94. match = reg_t.exec(lien);
  95.  
  96. var t = "";
  97.  
  98. if(match){
  99. t = "&t="+match[1];
  100. }
  101.  
  102. var l = get_params(lien);
  103. var my_id = $(this).data('ytb-id');
  104.  
  105. l = '<iframe width="320" height="180px" src="https://www.youtube.com/embed/'+my_id+'?autoplay=1'+t+'" frameborder="0" allowfullscreen></iframe>';
  106.  
  107. $('#contenu-ytb').html(l);
  108. $('#ytb-player').css('display','block');
  109. return false;
  110. });
  111.  
  112. return true;
  113.  
  114. }
  115.  
  116.  
  117. if(regex.test(url)){
  118. GM_xmlhttpRequest ( {
  119. method: "GET",
  120. url: "https://publish.twitter.com/oembed?url="+url,
  121. headers: {"Content-Type": "application/json"},
  122. onload: function (response) {
  123. if(response.status == 200){
  124. rep = jQuery.parseJSON(response.responseText);
  125. obj.after(rep.html);
  126. }
  127.  
  128. },
  129. onerror: function () {
  130. }
  131. } );
  132.  
  133. return true;
  134. }
  135.  
  136. if(insta.test(url)){
  137. match = insta.exec(url);
  138. id = match[1];
  139. if(match.length == 3){
  140. id = match[2];
  141. }
  142. html = "<div ><a data-contenu='1' target='blank_' href='"+match[0]+"'><img style='max-width:250px;max-height:250px;' src='https://instagram.com/p/"+id+"/media/?size=m'></a></div>";
  143. obj.html(html);
  144.  
  145. return true;
  146. }
  147.  
  148. if(face.test(url) || face2.test(url) ){
  149. match = face.exec(url);
  150.  
  151. if(face2.test(url)){
  152. match = face2.exec(url);
  153. }
  154. code = "<script> function resizeIframe(obj) { obj.style.height = obj.contentWindow.document.body.scrollHeight + 'px'; } </script>";
  155. obj.after(code);
  156. html = '<iframe src="https://www.facebook.com/plugins/post.php?href='+match[0]+'&width=350&show_text=true" width="350" style="width: 350px;border:none;overflow:hidden" scrolling="no" frameborder="0" onload="resizeIframe(this)" allowTransparency="true"></iframe>';
  157. obj.after(html);
  158. return true;
  159. }
  160.  
  161.  
  162.  
  163.  
  164. var host = getLocation(url);
  165.  
  166. host = host.hostname.toLowerCase();
  167. // var liste =["timesofisrael.com", "france24.com","i24news.tv", "presstv.ir", "prestv.com", "jeuxvideo.com", "m.jeuxvideo.com","fr.sputniknews.com","entreprendre.fr", "lorientlejour.com","francais.rt.com", "gameblog.fr","gamekult.com", "fr.wikipedia.org","en.wikipedia.org", "thesun.co.uk", "jeanmarcmorandini.com", "franceinter.fr", "lemonde.fr", "mobile.lemonde.fr", "mediapart.fr", "blogs.mediapart.fr", "lefigaro.fr","bfmbusiness.bfmtv.com","bfmtv.com", "marianne.net", "numerama.com", "buzzfeed.com", "tv5.org","01net.fr","20minutes.fr","challenges.fr","dna.fr","europe1.fr","france2.fr","france3.fr","france5.fr","latribune.fr","leparisien.fr","lepoint.fr","lepost.fr","Lequipe.fr","lesechos.fr","letelegramme.fr","lexpress.fr","liberation.fr","nouvelobs.com","parismatch.com","radiofrance.fr","rfi.fr","rue89.com","sudouest.fr","telerama.fr","TF1.fr","agoravox.fr","capital.fr","ladepeche.fr","lanouvellerepublique.fr","laprovence.com","lavoixdunord.fr","ledauphine.com","lejdd.fr","leprogres.fr","lesinrocks.com","m6.fr","marianne2.fr","mediapart.fr","nicematin.com","ouest-france.fr","owni.fr","rmc.fr","rtl.fr","slate.fr","maville.com","midilibre.com","metrofrance.com"];
  168.  
  169. var liste = ["google.com", "google.fr", "google.be", "google.ch", "goo.gl", "vid.me", "issoutv.com", "webm.land", "noelshack.com", "image.noelshack.com", "i.imgur.com", "vimeo.com", "hapshack.com", "puu.sh", "dailymotion.com"];
  170.  
  171. host = host.replace('www.','');
  172.  
  173. if((liste.indexOf(host) == -1)){
  174.  
  175. var urlEncoded = encodeURIComponent(url);
  176. var apiKey = "A MODIFIER";
  177. var requestUrl = 'http://opengraph.io/api/1.0/site/' + urlEncoded ;
  178.  
  179. if(apiKey){
  180. requestUrl = 'https://opengraph.io/api/1.0/site/' + urlEncoded + '?app_id=' + apiKey;
  181. }
  182.  
  183. GM_xmlhttpRequest ( {
  184. method: "GET",
  185. url: requestUrl,
  186. headers: {"Content-Type": "application/json"},
  187. onload: function (response) {
  188. if(response.status == 200){
  189. json = jQuery.parseJSON(response.responseText);
  190.  
  191. if (typeof json.hybridGraph.title !== 'undefined') {
  192. html = '<a data-contenu="1" href="'+url+'" target="_blank" style="text-decoration:none;color:black">';
  193. html += '<div style="margin-top:5px;margin-bottom:5px;padding:5px;border:1px solid #dedede;background: #f9f9f9;">';
  194. console.log(json);
  195. if (typeof json.hybridGraph.image !== 'undefined') {
  196. html += '<div class="ope-img" style="margin-right:10px;float: left;height:90px;width:170px; background:url(\''+json.hybridGraph.image+'\') no-repeat ; background-size: cover;background-position: center;">';
  197. html += '</div>';
  198. }
  199.  
  200. html += '<div class="contenu" style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis;height:90px;">';
  201. html += '<div class="title" title="'+json.hybridGraph.title +'" style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis;font-weight:bold;margin-bottom:10px;">'+json.hybridGraph.title+'</div>';
  202. html += '<div class="description" title="'+json.hybridGraph.description +'" style="height: 50px; overflow: hidden;font-size: 11.5px;white-space: normal; ">'+json.hybridGraph.description+'</div>';
  203. html += '<div style="font-size: 8px; float: right; bottom: 5px; color: gray;">'+host+'</div>';
  204. html += '</div>';
  205. html += '</div></a>';
  206.  
  207. obj.after(html);
  208. obj.hide();
  209. }
  210.  
  211. }
  212.  
  213. },
  214. onerror: function () {
  215. }
  216. } );
  217.  
  218. }
  219.  
  220.  
  221. });
  222.  
  223.  
  224. if(interval === true){
  225. setInterval(function(){ get_contenu(false); }, 500);
  226. }
  227. }
  228. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址