remove func

movietv.to - you can see full movies without passing to premium / remove func

当前为 2016-02-20 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // ==UserScript==
  3. // @name remove func
  4. // @namespace https://example.com
  5. // @description movietv.to - you can see full movies without passing to premium / remove func
  6. // @author xxx from reek's aak
  7. // @version 1.8
  8. // @license Creative Commons BY-NC-SA
  9. // @encoding utf-8
  10. // @homepage example.com
  11. // @include http*://*
  12. // @grant unsafeWindow
  13. // @grant GM_addStyle
  14. // @grant GM_getValue
  15. // @grant GM_setValue
  16. // @grant GM_xmlhttpRequest
  17. // @grant GM_registerMenuCommand
  18. // @grant GM_deleteValue
  19. // @grant GM_listValues
  20. // @grant GM_getResourceText
  21. // @grant GM_getResourceURL
  22. // @grant GM_log
  23. // @grant GM_openInTab
  24. // @grant GM_setClipboard
  25. // @grant GM_info
  26. // @grant GM_getMetadata
  27. // @run-at document-start
  28. // ==/UserScript==
  29.  
  30. mtv = {
  31. debug : {
  32. log: true,
  33. dump : false,
  34. inserted : false
  35. },
  36. initialize : function () {
  37.  
  38. // Debug
  39. if (mtv.debug.dump) {
  40. mtv.log('mtv');
  41. mtv.log(mtv);
  42. mtv.log('Local Storage');
  43. mtv.log(localStorage);
  44. //localStorage.clear();
  45. mtv.log('GM Storage');
  46. mtv.log(mtv.listValues());
  47.  
  48. mtv.log('GM API Supported');
  49. mtv.log(mtv.apiSupported());
  50. }
  51.  
  52. // Stop if user not use Script Manager or not support GM Api
  53. if (mtv.apiRequires()) {
  54. // Add Command in Greasemonkey Menu
  55. mtv.addCommands();
  56.  
  57. // Detect and Kill
  58. mtv.kill();
  59. }
  60. },
  61. uw : unsafeWindow || window,
  62. isTopWindow : !(window.top != window.self),
  63. ready : function (fn) {
  64. window.addEventListener('load', fn);
  65. },
  66. contains : function (string, search) {
  67. return string.indexOf(search) != -1;
  68. },
  69. log : function (msg, type) {
  70. if (mtv.debug.log) {
  71. if (typeof console === 'undefined') {
  72. console = unsafeWindow.console;
  73. }
  74. console[type || 'info']('movietv: ' + msg);
  75. }
  76. },
  77. apiRequires : function () {
  78. if (typeof GM_xmlhttpRequest != 'undefined' &&
  79. typeof GM_setValue != 'undefined' &&
  80. typeof GM_getValue != 'undefined' &&
  81. typeof GM_addStyle != 'undefined' &&
  82. typeof GM_registerMenuCommand != 'undefined') {
  83. return true;
  84. } else {
  85. return false;
  86. }
  87. },
  88. apiSupported : function () {
  89. if (mtv.isTopWindow) {
  90. // GM API
  91. // Doc: http://tinyurl.com/yeefnj5
  92. return {
  93. GM_xmlhttpRequest : typeof GM_xmlhttpRequest != 'undefined',
  94. GM_setValue : typeof GM_setValue != 'undefined',
  95. GM_getValue : typeof GM_getValue != 'undefined',
  96. GM_addStyle : typeof GM_addStyle != 'undefined',
  97. GM_registerMenuCommand : typeof GM_registerMenuCommand != 'undefined',
  98. GM_info : typeof GM_info != 'undefined',
  99. GM_getMetadata : typeof GM_getMetadata != 'undefined',
  100. GM_deleteValue : typeof GM_deleteValue != 'undefined',
  101. GM_listValues : typeof GM_listValues != 'undefined',
  102. GM_getResourceText : typeof GM_getResourceText != 'undefined',
  103. GM_getResourceURL : typeof GM_getResourceURL != 'undefined',
  104. GM_log : typeof GM_log != 'undefined',
  105. GM_openInTab : typeof GM_openInTab != 'undefined',
  106. GM_setClipboard : typeof GM_setClipboard != 'undefined'
  107. }
  108. }
  109. },
  110. listValues : function () {
  111. var list = GM_listValues();
  112. var obj = {};
  113. for (var i in list) {
  114. obj[list[i]] = GM_getValue(list[i]);
  115. }
  116. return obj;
  117. },
  118. getBrowser : function () {
  119. var ua = navigator.userAgent;
  120. if (mtv.contains(ua, 'Firefox')) {
  121. return "Firefox";
  122. } else if (mtv.contains(ua, 'MSIE')) {
  123. return "IE";
  124. } else if (mtv.contains(ua, 'Opera')) {
  125. return "Opera";
  126. } else if (mtv.contains(ua, 'Chrome')) {
  127. return "Chrome";
  128. } else if (mtv.contains(ua, 'Safari')) {
  129. return "Safari";
  130. } else if (mtv.contains(ua, 'Konqueror')) {
  131. return "Konqueror";
  132. } else if (mtv.contains(ua, 'PaleMoon')) {
  133. return "PaleMoon"; // fork firefox
  134. } else if (mtv.contains(ua, 'Cyberfox')) {
  135. return "Cyberfox"; // fork firefox
  136. } else if (mtv.contains(ua, 'SeaMonkey')) {
  137. return "SeaMonkey"; // fork firefox
  138. } else if (mtv.contains(ua, 'Iceweasel')) {
  139. return "Iceweasel"; // fork firefox
  140. } else {
  141. return ua;
  142. }
  143. },
  144. getScriptManager : function () {
  145. if (mtv.apiRequires()) {
  146. if (typeof GM_info == 'object') {
  147. // Greasemonkey (Firefox)
  148. if (typeof GM_info.uuid != 'undefined') {
  149. return 'Greasemonkey';
  150. } // Tampermonkey (Chrome/Opera)
  151. else if (typeof GM_info.scriptHandler != 'undefined') {
  152. return 'Tampermonkey';
  153. }
  154. } else {
  155. // Scriptish (Firefox)
  156. if (typeof GM_getMetadata == 'function') {
  157. return 'Scriptish';
  158. } // NinjaKit (Safari/Chrome)
  159. else if (typeof GM_getResourceText == 'undefined' &&
  160. typeof GM_getResourceURL == 'undefined' &&
  161. typeof GM_openInTab == 'undefined' &&
  162. typeof GM_setClipboard == 'undefined') {
  163. return 'NinjaKit';
  164. } // GreaseGoogle (Chrome)
  165. else if (mtv.getBrowser() == 'Chrome' &&
  166. typeof GM_setClipboard == 'undefined') {
  167. return 'GreaseGoogle';
  168. }
  169. }
  170. } else {
  171. mtv.log('No Script Manager detected');
  172. return false;
  173. }
  174. },
  175. generateID : function () {
  176. return 'mtv-' + Math.random().toString(36).substring(4);
  177. },
  178. generateUUID : function () {
  179. // Universally Unique IDentifier
  180. var d = new Date().getTime();
  181. var uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
  182. var r = (d + Math.random() * 16) % 16 | 0;
  183. d = Math.floor(d / 16);
  184. return (c == 'x' ? r : (r & 0x7 | 0x8)).toString(16);
  185. });
  186. return uuid;
  187. },
  188. addCommands : function () {
  189. },
  190. notification : function (message, delay) {
  191. if (mtv.isTopWindow) {
  192.  
  193. // animation
  194. mtv.addStyle('@-webkit-keyframes mtv-fadeInDown{0%{opacity:0;-webkit-transform:translateY(-20px)}100%{opacity:1;-webkit-transform:translateY(0)}}@keyframes mtv-fadeInDown{0%{opacity:0;transform:translateY(-20px)}100%{opacity:1;transform:translateY(0)}}');
  195.  
  196. // box
  197. mtv.addStyle('#mtv-notice {-webkit-animation:mtv-fadeInDown .5s ease; animation:mtv-fadeInDown .5s ease; padding:0px; color:#000; background-color:#fff; display:block; width:100%; position:fixed; z-index:999999; left: 0; top: 0; text-align: left; vertical-align:middle; margin:0; font-size:14px; font-family:arial; border-bottom:5px solid #DF3A32; line-height:1.2; font-variant:small-caps;}'.replace(/;/g, ' !important;'));
  198.  
  199. // navbar
  200. mtv.addStyle('#mtv-notice-navbar {background-color:#DF3A32; padding:0px 20px 0px 62px; background-image:url("' + mtv.iconURL + '"); background-repeat:no-repeat; background-position:20px 3px; background-size:32px;}'.replace(/;/g, ' !important;'));
  201.  
  202. // link
  203. mtv.addStyle('.mtv-navbar-link {padding:0px 5px; line-height:35px; color:#fff; display:inline-block; text-decoration:none; transform:skew(345deg, 0deg); background-color:#DF3A32; border-bottom:3px solid #DF3A32;}'.replace(/;/g, ' !important;'));
  204.  
  205. // link:hover
  206. mtv.addStyle('.mtv-navbar-link:hover {color:#fff; background-color:#000; border-bottom:3px solid #fff; text-decoration:none;}'.replace(/;/g, ' !important;'));
  207.  
  208. // close
  209. mtv.addStyle('#mtv-notice-close {color:#fff; float: right; margin:0px 5px; padding:10px 10px 8px 10px; text-decoration: none;}'.replace(/;/g, ' !important;'));
  210.  
  211. // brand
  212. mtv.addStyle('#mtv-notice .brand {padding-right:20px; color:#fff; font-size:14px;}'.replace(/;/g, ' !important;'));
  213.  
  214. // content
  215. mtv.addStyle('#mtv-notice-content {padding:5px 20px; min-height:72px;}'.replace(/;/g, ' !important;'));
  216. mtv.addStyle('#mtv-notice-content a {color:#DF3A32; text-decoration:none;}'.replace(/;/g, ' !important;'));
  217. mtv.addStyle('#mtv-notice-content a:hover {text-decoration:underline;}'.replace(/;/g, ' !important;'));
  218.  
  219. // remove
  220. mtv.removeElement('#mtv-notice');
  221.  
  222. // close (manually)
  223. document.querySelector('#mtv-notice-close').onclick = function () {
  224. mtv.removeElement('#mtv-notice');
  225. }
  226.  
  227. // close (automatically)
  228. setTimeout(function () {
  229. mtv.removeElement('#mtv-notice');
  230. }, delay);
  231.  
  232. }
  233. },
  234. setStorage : function () {
  235. if (localStorage) {
  236. // Le navigateur supporte le localStorage
  237. } else {
  238. //throw 'localStorage non supporté';
  239. }
  240. },
  241. getStorage : function () {
  242. if (localStorage) {
  243. // Le navigateur supporte le localStorage
  244. } else {
  245. //throw 'localStorage non supporté';
  246. }
  247. },
  248. kill : function () {
  249.  
  250. // Detect & Kill
  251. for (var i in mtv.rules) {
  252.  
  253. // Current
  254. var current = mtv.rules[i];
  255.  
  256. // RegExp host
  257. var reHost = new RegExp(current.host.join('|'), 'i');
  258. // If domains is
  259. if (reHost.test(location.host)) {
  260. // On all statements
  261. if (current.onAlways) {
  262. current.onAlways(); // loading
  263. window.addEventListener('DOMContentLoaded', current.onAlways); // interactive
  264. window.addEventListener('load', current.onAlways); // complete
  265. }
  266. // Add Js / Css / Cookie
  267. if (current.onStart) {
  268. current.onStart();
  269. }
  270. // When Before Script Executed
  271. if (current.onBeforeScript) {
  272. if ('onbeforescriptexecute' in document) { // Mozilla Firefox
  273. window.addEventListener('beforescriptexecute', current.onBeforeScript);
  274. }
  275. } // When After Script Executed
  276. if (current.onAfterScript) {
  277. if ('onafterscriptexecute' in document) { // Mozilla Firefox
  278. window.addEventListener('afterscriptexecute', current.onAfterScript);
  279. }
  280. }
  281. // When Window Load
  282. if (current.onEnd) {
  283. window.addEventListener('load', current.onEnd);
  284. }
  285. // When DOM Load
  286. if (current.onLoad) {
  287. window.addEventListener('DOMContentLoaded', current.onLoad);
  288. }
  289. // When DOM AttrModified
  290. if (current.onAttrModified) {
  291. window.addEventListener('DOMAttrModified', current.onAttrModified, false);
  292. }
  293. // When DOM SubtreeModified
  294. if (current.onSubtreeModified) {
  295. window.addEventListener('DOMSubtreeModified', current.onSubtreeModified, false);
  296. }
  297. // When DOM Elements are Inserted in Document
  298. if (current.onInsert) {
  299.  
  300. // Mutation Observer
  301. // Doc: http://tinyurl.com/mxxzee4
  302. // Support: http://tinyurl.com/nepn7vy
  303. if (typeof window.MutationObserver != 'undefined' ||
  304. typeof WebKitMutationObserver != 'undefined') {
  305.  
  306. // Mutation Observer
  307. var MutationObserver = window.MutationObserver || WebKitMutationObserver;
  308.  
  309. // Create an observer instance
  310. var obs = new MutationObserver(function (mutations) {
  311. // We can safely use `forEach` because we already use mutation
  312. // observers that are more recent than `forEach`. (source: MDN)
  313. mutations.forEach(function (mutation) {
  314. // we want only added nodes
  315. if (mutation.addedNodes.length) {
  316. //mtv.log(addedNodes);
  317. Array.prototype.forEach.call(mutation.addedNodes, function (addedNode) {
  318. //mtv.log(addedNode);
  319. current.onInsert(addedNode);
  320. });
  321. }
  322. });
  323. });
  324. // Observer
  325. obs.observe(document, {
  326. childList : true,
  327. subtree : true
  328. });
  329. }
  330. // Mutation Events (Alternative Solution)
  331. // Doc: http://tinyurl.com/op95rfy
  332. else {
  333. window.addEventListener("DOMNodeInserted", function (e) {
  334. current.onInsert(e.target);
  335. }, false);
  336. }
  337. }
  338. // When DOM Elements are Removed in Document
  339. if (current.onRemove) {
  340.  
  341. // Mutation Observer
  342. // Doc: http://tinyurl.com/mxxzee4
  343. // Support: http://tinyurl.com/nepn7vy
  344. if (typeof window.MutationObserver != 'undefined' ||
  345. typeof WebKitMutationObserver != 'undefined') {
  346.  
  347. // Mutation Observer
  348. var MutationObserver = window.MutationObserver || WebKitMutationObserver;
  349.  
  350. // Create an observer instance
  351. var obs = new MutationObserver(function (mutations) {
  352. // We can safely use `forEach` because we already use mutation
  353. // observers that are more recent than `forEach`. (source: MDN)
  354. mutations.forEach(function (mutation) {
  355. // we want only removed nodes
  356. if (mutation.removedNodes.length) {
  357. //mtv.log(mutation.removedNodes);
  358. Array.prototype.forEach.call(mutation.removedNodes, function (removedNode) {
  359. //mtv.log(removedNode);
  360. current.onRemove(removedNode);
  361. });
  362. }
  363. });
  364. });
  365. // Observer
  366. obs.observe(document, {
  367. childList : true,
  368. subtree : true
  369. });
  370. }
  371. // Mutation Events (Alternative Solution)
  372. // Doc: http://tinyurl.com/op95rfy
  373. else {
  374. window.addEventListener("DOMNodeRemoved", function (e) {
  375. current.onRemove(e.target);
  376. }, false);
  377. }
  378. }
  379. }
  380. }
  381. },
  382. confirmLeave : function () {
  383. window.onbeforeunload = function () {
  384. return '';
  385. };
  386. },
  387. stopScript : function (e) {
  388. e.preventDefault();
  389. e.stopPropagation();
  390. },
  391. innerScript : function (e) {
  392. return e.target.innerHTML;
  393. },
  394. addScript : function (code) {
  395. // Note: Scriptish no support
  396. if (document.head) {
  397. if (/\.js$/.test(code)) { // External
  398. document.head.appendChild(document.createElement('script')).src = code;
  399. } else { // Inline
  400. document.head.appendChild(document.createElement('script')).innerHTML = code.toString().replace(/^function.*{|}$/g, '');
  401. }
  402. }
  403. },
  404. addElement : function (str) { // ex: div.ads or span#ads
  405. if (mtv.contains(str, '.')) {
  406. var str = str.replace('.', ':className:');
  407. } else if (mtv.contains(str, '#')) {
  408. var str = str.replace('#', ':id:');
  409. }
  410. var arr = str.split(':');
  411. mtv.addScript('function() { document.documentElement.appendChild(document.createElement("' + arr[0] + '")).' + arr[1] + ' = "' + arr[2] + '"; document.querySelector("' + arr[0] + '").innerHTML = "<br>"; }');
  412. },
  413. removeElement : function (o) {
  414. if (o instanceof HTMLElement) {
  415. return o.parentNode.removeChild(o);
  416. } else if (typeof o === "string") {
  417. var elem = document.querySelectorAll(o);
  418. for (var i = 0; i < elem.length; i++) {
  419. elem[i].parentNode.removeChild(elem[i]);
  420. }
  421. } else {
  422. return false;
  423. }
  424. },
  425. getElement : function (selector) {
  426. var elem = document.querySelector(selector) || false;
  427. if (elem) {
  428. return elem;
  429. } else {
  430. return false;
  431. }
  432. },
  433. setElement : function (selector, props) {
  434. var elem = mtv.getElement(selector);
  435. if (elem) {
  436. for (p in props) {
  437. elem.setAttribute(p, props[p]);
  438. }
  439. } else {
  440. return false;
  441. }
  442. },
  443. addStyle : function (css) {
  444. GM_addStyle(css);
  445. },
  446. getStyle : function (elem, prop) {
  447. if (elem.currentStyle)
  448. return elem.currentStyle[prop];
  449. else if (window.getComputedStyle)
  450. return document.defaultView.getComputedStyle(elem, null).getPropertyValue(prop);
  451. },
  452. getCookie : function (name) {
  453. var oRegex = new RegExp("(?:; )?" + name + "=([^;]*);?");
  454. if (oRegex.test(document.cookie)) {
  455. return decodeURIComponent(RegExp["$1"]);
  456. } else {
  457. return null;
  458. }
  459. },
  460. setCookie : function (name, value, time) {
  461. var time = (time) ? time : 365 * 24 * 60 * 60 * 1000; // 1 year
  462. var expires = new Date();
  463. expires.setTime(new Date().getTime() + time);
  464. document.cookie = name + "=" + encodeURIComponent(value) + ";expires=" + expires.toGMTString() + ";path=/";
  465. },
  466. decodeURI : function (str) {
  467. return decodeURIComponent(str);
  468. },
  469. encodeURI : function (str) {
  470. return encodeURIComponent(str);
  471. },
  472. encodeHTML : function (str) {
  473. return String(str).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
  474. },
  475. decodeHTML : function (str) {
  476. return String(str).replace(/&amp;/g, '&').replace(/&lt;/g, '<').replace(/&gt;/g, '>').replace(/&quot;/g, '"');
  477. },
  478. allowfullscreen : function (elem, boolen) {
  479. var boolen = (boolen) ? boolen : true;
  480. if (typeof elem == 'string') {
  481. var elem = document.querySelector(elem);
  482. }
  483.  
  484. var parent = elem.parentNode;
  485. var clone = elem.cloneNode(true);
  486. var params = clone.querySelector('param[name="allowfullscreen"]') || false;
  487.  
  488. if (params) {
  489. params.value = boolen;
  490. }
  491. if (typeof clone.allowfullscreen != 'undefined') {
  492. clone.allowfullscreen = boolen;
  493. }
  494.  
  495. // Replace
  496. parent.replaceChild(clone, elem);
  497. },
  498. player : { // http://tinyurl.com/pb6fthj
  499. in : {
  500. node : null,
  501. html : null,
  502. tag : null,
  503. parent : null
  504. },
  505. out : {
  506. node : null,
  507. html : null,
  508. tag : null,
  509. parent : null
  510. },
  511. nameplayer : 'custom',
  512. swfvars : null,
  513. options : {
  514. method : 'replace',
  515. output : 'embed'
  516. },
  517. flashvars : {
  518. str : null,
  519. obj : {}
  520. },
  521. attributes : {
  522. wmode : 'opaque',
  523. quality : 'high',
  524. bgcolor : '#000000',
  525. type : 'application/x-shockwave-flash',
  526. pluginspage : 'http://www.adobe.com/go/getflash',
  527. allowscriptaccess : 'always', // never / always
  528. allowfullscreen : true
  529. },
  530. get : function (element) {
  531.  
  532. if (element instanceof HTMLElement) {
  533. this.in.node = element;
  534. } else if (typeof element == 'string') {
  535. if (/^[#\.]/.test(element)) {
  536. this.in.node = document.querySelector(element);
  537. } else {
  538. this.in.node = document.getElementById(element);
  539. }
  540. } else {
  541. throw 'Not object or embed player or invalid selector';
  542. }
  543.  
  544. this.in.html = this.getHtml(this.in.node);
  545. this.in.parent = this.in.node.parentNode;
  546. this.in.tag = this.in.node.tagName;
  547.  
  548. this.attributes.id = this.attributes.name = mtv.generateID();
  549. this.attributes.height = this.in.node.height || this.in.node.clientHeight || '100%';
  550. this.attributes.width = this.in.node.width || this.in.node.clientWidth || '100%';
  551.  
  552. if (/^(object|embed)$/i.test(this.in.tag)) {
  553.  
  554. //
  555. this.attributes.src = this.in.node.src || this.in.node.data || false;
  556. this.flashvars.str = this.in.node.flashvars || this.in.node.querySelector('param[name="flashvars"]') && this.in.node.querySelector('param[name="flashvars"]').value || false;
  557. var swfvars = !this.flashvars.str && this.in.node.data && this.in.node.data.split('?', 2) || false;
  558.  
  559. //
  560. if (swfvars) {
  561. this.attributes.src = swfvars[0];
  562. this.flashvars.str = swfvars[1];
  563. }
  564.  
  565. this.splitVars();
  566. this.joinVars();
  567. }
  568. //mtv.log(this);
  569. },
  570. custom : function (element, attributes, flashvars, options) {
  571.  
  572. //
  573. this.get(element);
  574.  
  575. //
  576. if (typeof attributes == 'object') {
  577. this.mergeObj(this.attributes, attributes);
  578. }
  579.  
  580. //
  581. if (typeof flashvars == 'object') {
  582. if (flashvars.set) {
  583. this.setVars(flashvars.set);
  584. }
  585. if (flashvars.remove) {
  586. this.removeVars(flashvars.remove);
  587. }
  588. }
  589.  
  590. //
  591. if (typeof options == 'object') {
  592. if (options.method) {
  593. this.options.method = options.method;
  594. }
  595. if (options.output) {
  596. this.options.output = options.output;
  597. }
  598. }
  599.  
  600. this.insert();
  601. //mtv.log(this);
  602. },
  603. log : function (a) {
  604. var a = (a) ? a : '';
  605. mtv.log('mtv.player ' + a + ' --> ', this);
  606. },
  607. addDownloadBtn : function () {
  608. var btn = document.createElement("p");
  609. btn.innerHTML = '<strong>Video: </strong> <a href="' + this.attributes.src + '" download>Download</a>';
  610. this.out.node.parentNode.insertBefore(btn, this.out.node);
  611. },
  612. mergeObj : function (obj1, obj2) {
  613. for (var prop in obj2) {
  614. obj1[prop] = obj2[prop];
  615. }
  616. },
  617. setVars : function (flashvars) {
  618. if (typeof flashvars == 'string') {
  619. this.flashvars.str = flashvars;
  620. this.splitVars();
  621. this.joinVars();
  622. } else if (typeof flashvars == 'object') {
  623. this.mergeObj(this.flashvars.obj, flashvars);
  624. this.joinVars();
  625. this.splitVars();
  626. }
  627. },
  628. removeVars : function (str) {
  629. var obj = this.flashvars.obj;
  630. var splits = str.split(',');
  631. for (var i = 0; i < splits.length; i++) {
  632. var k = splits[i];
  633. if (k in obj)
  634. delete obj[k];
  635. }
  636. this.flashvars.obj = obj;
  637. this.joinVars();
  638. },
  639. splitVars : function () {
  640. var str = mtv.decodeHTML(this.flashvars.str);
  641. var arr = str.split('&');
  642. var obj = {};
  643. for (var i = 0; i < arr.length; i++) {
  644. var k = arr[i];
  645. if (k != '' && k.split('=')) {
  646. var s = k.split('=');
  647. obj[s[0]] = mtv.decodeURI(s[1]);
  648. }
  649. }
  650. this.flashvars.obj = obj;
  651. },
  652. joinVars : function () {
  653. var obj = this.flashvars.obj;
  654. var arr = [];
  655. for (k in obj) {
  656. arr.push(k + '=' + mtv.encodeURI(obj[k])); // encodeURIComponent
  657. }
  658. this.flashvars.str = arr.join('&'); // &amp;
  659. },
  660. insert : function () {
  661.  
  662. //
  663. this.swfvars = [this.attributes.src, this.flashvars.str].join('?');
  664.  
  665. //
  666. switch (this.options.output) {
  667. case 'iframe':
  668. this.out.node = document.createElement('iframe');
  669. this.out.node.setAttribute('src', this.swfvars);
  670. this.out.node.setAttribute('width', this.attributes.width);
  671. this.out.node.setAttribute('height', this.attributes.height);
  672. this.out.node.setAttribute('frameborder', 0);
  673. this.out.node.setAttribute('scrolling', 'no');
  674. break;
  675. case 'tab':
  676. this.log();
  677. return GM_openInTab(this.swfvars);
  678. break;
  679. case 'html5':
  680. this.out.node = document.createElement('video');
  681. this.out.node.innerHTML = '<strong>Video not playing ? <a href="' + this.attributes.src + '" download>Download file</a> instead.</strong>';
  682. for (k in this.attributes) {
  683. if (k == 'autoplay') { // fix bug duplicate playing on firefox
  684. this.out.node.onloadstart = function () {
  685. this.play();
  686. }
  687. } else {
  688. this.out.node.setAttribute(k, this.attributes[k]);
  689. }
  690. }
  691. this.out.node.onerror = function () { // switch to plugin player
  692. mtv.player.plugin(this, {file:mtv.player.attributes.src});
  693. };
  694. break;
  695. default:
  696. this.out.node = document.createElement('embed');
  697. for (k in this.attributes) {
  698. this.out.node.setAttribute(k, this.attributes[k]);
  699. }
  700. if (this.flashvars.str) {
  701. this.out.node.setAttribute('flashvars', this.flashvars.str);
  702. }
  703. }
  704.  
  705. //
  706. this.out.html = this.getHtml(this.out.node);
  707. this.out.tag = this.out.node.tagName;
  708.  
  709. //
  710. if (this.options.output == 'inner') {
  711. this.in.node.innerHTML = this.out.html;
  712. } else { // replace
  713. this.in.parent.replaceChild(this.out.node, this.in.node);
  714. }
  715. //this.addDownloadBtn();
  716. this.log('done');
  717. },
  718. getHtml : function (node) {
  719. var tmp = document.createElement('div');
  720. tmp.appendChild(node.cloneNode(true))
  721. return tmp.innerHTML;
  722. },
  723. getMime : function (file) {
  724. var mime = file.match(/\.(flv|mp4|webm|ogv|ogg|mp3|mpeg|mpg|mkv|avi|mov)$/);
  725. if (mime && mime.length == 2) {
  726. return 'video/' + mime[1];
  727. } else {
  728. return 'video/mp4';
  729. }
  730. },
  731. plugin : function (id, setup) {
  732. // Web Player (plugin)
  733. // VLC : http://tinyurl.com/omlzp39
  734. // WMP :
  735. // QT :
  736.  
  737. this.get(id);
  738. this.nameplayer = 'plugin';
  739. this.attributes.autoplay = setup.autostart || setup.autoplay || false;
  740. this.attributes.src = setup.file || setup.src;
  741. this.attributes.height = setup.height || this.in.node.clientHeight || "100%";
  742. this.attributes.width = setup.width || this.in.node.clientWidth || "100%";
  743.  
  744. // Plugins
  745. var plugins = [];
  746. if (navigator.plugins && (navigator.plugins.length > 0)) {
  747. for (var i = 0; i < navigator.plugins.length; i++) {
  748. plugins.push(navigator.plugins[i].name);
  749. }
  750. var plugins = plugins.join('|');
  751. if (mtv.contains(plugins, 'Windows Media Player')) {
  752. this.attributes.type = "application/x-mplayer2";
  753. this.attributes.pluginspage = 'http://www.microsoft.com/Windows/MediaPlayer/';
  754. } else if (mtv.contains(plugins, 'VLC Web Plugin')) {
  755. this.attributes.type = "application/x-vlc-plugin";
  756. this.attributes.pluginspage = "http://www.videolan.org";
  757. } else if (mtv.contains(plugins, 'QuickTime Plug-in')) {
  758. this.attributes.type = "video/quicktime";
  759. this.attributes.pluginspage = "http://www.apple.com/quicktime/download/";
  760. } else {
  761. mtv.notification('You need install VLC Web Plugin ! <a href="http://www.videolan.org/vlc/" target="_blank">Install</a>', 30000);
  762. return false;
  763. }
  764. }
  765. this.options.output = 'embed';
  766. this.insert();
  767. },
  768. html5 : function (id, setup) {
  769.  
  770. // Video Tag (html5)
  771. /* Note:
  772. https://html5rocks.com/en/tutorials/video/basics/
  773. http://www.w3schools.com/tags/tag_video.asp
  774.  
  775. // Test video
  776. https://www.joomlacontenteditor.net/images/big_buck_bunny.flv
  777. http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4
  778. http://clips.vorwaerts-gmbh.de/big_buck_bunny.webm
  779. http://clips.vorwaerts-gmbh.de/big_buck_bunny.ogv
  780. */
  781.  
  782. this.get(id);
  783. //this.attributes = {};
  784. this.attributes.id = this.attributes.name = mtv.generateID();
  785. this.attributes.height = setup.height || this.in.node.clientHeight || "100%";
  786. this.attributes.width = setup.width || this.in.node.clientWidth || "100%";
  787. this.attributes.src = setup.file || setup.src;
  788. this.attributes.type = this.getMime(this.attributes.src);
  789. this.attributes.controls = 'controls';
  790. //this.attributes.preload = 'none';
  791. if (setup.autostart || setup.autoplay) {
  792. this.attributes.autoplay = 'autoplay';
  793. }
  794. this.options.output = 'html5';
  795. this.insert();
  796. }
  797. },
  798. rules : {
  799. // --------------------------------------------------------------------------------------------
  800. // Specific
  801. // --------------------------------------------------------------------------------------------
  802. movie_domains : {
  803. host : ['movietv.to'],
  804. onAlways : function () {
  805. mtv.uw.myFunction = function () {};
  806. // for (i in mtv.uw) { mtv.uw[i] = function () {}; }
  807. }
  808. },
  809. gum_domains : {
  810. host : ['gum-gum-streaming.com','dpstream.net','jeu.info','jemontremesseins.com'],
  811. onAlways : function () {
  812. for (i in mtv.uw) { mtv.uw[i] = function () {}; }
  813. }
  814. },
  815.  
  816. }
  817. };
  818.  
  819. mtv.initialize();