movietv

movietv_time

当前为 2015-11-28 提交的版本,查看 最新版本

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