🏠 返回首頁 

Greasy Fork is available in English.

Watch Transition

отслеживает событие transition и выводит его в консоль

  1. // ==UserScript==
  2. // @name Watch Transition
  3. // @namespace almaceleste
  4. // @version 0.2.0
  5. // @description watches for a transition event and prints it to the console
  6. // @description:ru отслеживает событие transition и выводит его в консоль
  7. // @author (ɔ) Paola Captanovska
  8. // @license AGPL-3.0-or-later; http://www.gnu.org/licenses/agpl
  9. // @icon https://cdn1.iconfinder.com/data/icons/jumpicon-basic-ui-line-1/32/-_Eye-Show-View-Watch-See-16.png
  10. // @icon64 https://cdn1.iconfinder.com/data/icons/jumpicon-basic-ui-line-1/32/-_Eye-Show-View-Watch-See-64.png
  11. // @homepageURL https://greasyfork.org/en/users/174037-almaceleste
  12. // @homepageURL https://openuserjs.org/users/almaceleste
  13. // @homepageURL https://github.com/almaceleste/userscripts
  14. // @supportURL https://github.com/almaceleste/userscripts/issues
  15. // @require https://code.jquery.com/jquery-3.3.1.js
  16. // @require https://openuserjs.org/src/libs/sizzle/GM_config.js
  17. // @grant GM_getValue
  18. // @grant GM_setValue
  19. // @grant GM_registerMenuCommand
  20. // @grant GM_openInTab
  21. // @match http*://*/*
  22. // ==/UserScript==
  23. // ==OpenUserJS==
  24. // @author almaceleste
  25. // ==/OpenUserJS==
  26. const windowcss = `
  27. #wtCfg {
  28. background-color: lightblue;
  29. }
  30. #wtCfg .reset_holder {
  31. float: left;
  32. position: relative;
  33. bottom: -1em;
  34. }
  35. #wtCfg .saveclose_buttons {
  36. margin: .7em;
  37. }
  38. #wtCfg_field_url {
  39. background: none !important;
  40. border: none;
  41. cursor: pointer;
  42. padding: 0 !important;
  43. text-decoration: underline;
  44. }
  45. #wtCfg_field_url:hover,
  46. #wtCfg_resetLink:hover {
  47. filter: drop-shadow(0 0 1px dodgerblue);
  48. }
  49. `;
  50. const iframecss = `
  51. height: 34.5em;
  52. width: 25em;
  53. border: 1px solid;
  54. border-radius: 3px;
  55. position: fixed;
  56. z-index: 9999;
  57. `;
  58. GM_registerMenuCommand('Watch Transition Settings', opencfg);
  59. function opencfg(){
  60. GM_config.open();
  61. wtCfg.style = iframecss;
  62. }
  63. GM_config.init({
  64. id: 'wtCfg',
  65. title: `Watch Transition ${GM_info.script.version}`,
  66. fields: {
  67. run: {
  68. section: ['', 'Watch events'],
  69. label: 'transitionrun (created, not started)',
  70. labelPos: 'right',
  71. title: 'fired when a CSS transition is created, when it is added to a set of running transitions, though not necessarily started',
  72. type: 'checkbox',
  73. default: false,
  74. },
  75. start: {
  76. label: 'transitionstart (started)',
  77. labelPos: 'right',
  78. title: 'fired when a CSS transition has started transitioning',
  79. type: 'checkbox',
  80. default: false,
  81. },
  82. cancel: {
  83. label: 'transitioncancel (canceled)',
  84. labelPos: 'right',
  85. title: 'fired when a CSS transition has been cancelled',
  86. type: 'checkbox',
  87. default: false,
  88. },
  89. end: {
  90. label: 'transitionend (finished)',
  91. labelPos: 'right',
  92. title: 'fired when a CSS transition has finished playing (most useful)',
  93. type: 'checkbox',
  94. default: true,
  95. },
  96. property: {
  97. label: 'print event property',
  98. labelPos: 'left',
  99. type: 'select',
  100. title: 'print one preferred event property before the whole event',
  101. options: [
  102. 'none',
  103. 'bubbles',
  104. 'cancelBubble',
  105. 'cancelable',
  106. 'composed',
  107. 'currentTarget',
  108. 'defaultPrevented',
  109. 'elapsedTime',
  110. 'eventPhase',
  111. 'isTrusted',
  112. 'path',
  113. 'propertyName',
  114. 'pseudoElement',
  115. 'returnValue',
  116. 'srcElement',
  117. 'target',
  118. 'timestamp',
  119. 'type'
  120. ],
  121. default: 'target',
  122. },
  123. italic: {
  124. section: ['', 'Style Settings'],
  125. label: 'italic font',
  126. labelPos: 'right',
  127. type: 'checkbox',
  128. default: false,
  129. },
  130. bold: {
  131. label: 'bold font',
  132. labelPos: 'right',
  133. type: 'checkbox',
  134. default: false,
  135. },
  136. method: {
  137. label: 'console method',
  138. labelPos: 'left',
  139. type: 'select',
  140. options: [
  141. 'debug',
  142. 'dir',
  143. 'dirxml',
  144. 'error',
  145. 'info',
  146. 'log',
  147. 'warn'
  148. ],
  149. default: 'log',
  150. },
  151. runcolor: {
  152. label: 'transitionrun color',
  153. labelPos: 'left',
  154. type: 'select',
  155. options: [
  156. 'unset',
  157. 'black',
  158. 'blue',
  159. 'green',
  160. 'aqua',
  161. 'red',
  162. 'purple',
  163. 'yellow',
  164. 'white',
  165. 'gray',
  166. 'lightskyblue',
  167. 'lightgreen',
  168. 'orangered',
  169. 'pink',
  170. 'gold',
  171. 'whitesmoke',
  172. 'lightgray',
  173. 'dimgray'
  174. ],
  175. default: 'unset',
  176. },
  177. runbackground: {
  178. label: 'transitionrun background',
  179. labelPos: 'left',
  180. type: 'select',
  181. options: [
  182. 'unset',
  183. 'black',
  184. 'blue',
  185. 'green',
  186. 'aqua',
  187. 'red',
  188. 'purple',
  189. 'yellow',
  190. 'white',
  191. 'gray',
  192. 'lightskyblue',
  193. 'lightgreen',
  194. 'orangered',
  195. 'pink',
  196. 'gold',
  197. 'whitesmoke',
  198. 'lightgray',
  199. 'dimgray'
  200. ],
  201. default: 'unset',
  202. },
  203. startcolor: {
  204. label: 'transitionstart color',
  205. labelPos: 'left',
  206. type: 'select',
  207. options: [
  208. 'unset',
  209. 'black',
  210. 'blue',
  211. 'green',
  212. 'aqua',
  213. 'red',
  214. 'purple',
  215. 'yellow',
  216. 'white',
  217. 'gray',
  218. 'lightskyblue',
  219. 'lightgreen',
  220. 'orangered',
  221. 'pink',
  222. 'gold',
  223. 'whitesmoke',
  224. 'lightgray',
  225. 'dimgray'
  226. ],
  227. default: 'unset',
  228. },
  229. startbackground: {
  230. label: 'transitionstart background',
  231. labelPos: 'left',
  232. type: 'select',
  233. options: [
  234. 'unset',
  235. 'black',
  236. 'blue',
  237. 'green',
  238. 'aqua',
  239. 'red',
  240. 'purple',
  241. 'yellow',
  242. 'white',
  243. 'gray',
  244. 'lightskyblue',
  245. 'lightgreen',
  246. 'orangered',
  247. 'pink',
  248. 'gold',
  249. 'whitesmoke',
  250. 'lightgray',
  251. 'dimgray'
  252. ],
  253. default: 'unset',
  254. },
  255. cancelcolor: {
  256. label: 'transitioncancel color',
  257. labelPos: 'left',
  258. type: 'select',
  259. options: [
  260. 'unset',
  261. 'black',
  262. 'blue',
  263. 'green',
  264. 'aqua',
  265. 'red',
  266. 'purple',
  267. 'yellow',
  268. 'white',
  269. 'gray',
  270. 'lightskyblue',
  271. 'lightgreen',
  272. 'orangered',
  273. 'pink',
  274. 'gold',
  275. 'whitesmoke',
  276. 'lightgray',
  277. 'dimgray'
  278. ],
  279. default: 'unset',
  280. },
  281. cancelbackground: {
  282. label: 'transitioncancel background',
  283. labelPos: 'left',
  284. type: 'select',
  285. options: [
  286. 'unset',
  287. 'black',
  288. 'blue',
  289. 'green',
  290. 'aqua',
  291. 'red',
  292. 'purple',
  293. 'yellow',
  294. 'white',
  295. 'gray',
  296. 'lightskyblue',
  297. 'lightgreen',
  298. 'orangered',
  299. 'pink',
  300. 'gold',
  301. 'whitesmoke',
  302. 'lightgray',
  303. 'dimgray'
  304. ],
  305. default: 'unset',
  306. },
  307. endcolor: {
  308. label: 'transitionend color',
  309. labelPos: 'left',
  310. type: 'select',
  311. options: [
  312. 'unset',
  313. 'black',
  314. 'blue',
  315. 'green',
  316. 'aqua',
  317. 'red',
  318. 'purple',
  319. 'yellow',
  320. 'white',
  321. 'gray',
  322. 'lightskyblue',
  323. 'lightgreen',
  324. 'orangered',
  325. 'pink',
  326. 'gold',
  327. 'whitesmoke',
  328. 'lightgray',
  329. 'dimgray'
  330. ],
  331. default: 'unset',
  332. },
  333. endbackground: {
  334. label: 'transitionend background',
  335. labelPos: 'left',
  336. type: 'select',
  337. options: [
  338. 'unset',
  339. 'black',
  340. 'blue',
  341. 'green',
  342. 'aqua',
  343. 'red',
  344. 'purple',
  345. 'yellow',
  346. 'white',
  347. 'gray',
  348. 'lightskyblue',
  349. 'lightgreen',
  350. 'orangered',
  351. 'pink',
  352. 'gold',
  353. 'whitesmoke',
  354. 'lightgray',
  355. 'dimgray'
  356. ],
  357. default: 'unset',
  358. },
  359. url: {
  360. section: ['', 'Support'],
  361. label: 'almaceleste.github.io',
  362. type: 'button',
  363. click: () => {
  364. GM_openInTab('https://almaceleste.github.io', {
  365. active: true,
  366. insert: true,
  367. setParent: true
  368. });
  369. }
  370. },
  371. },
  372. css: windowcss,
  373. events: {
  374. save: function() {
  375. GM_config.close();
  376. }
  377. },
  378. });
  379. function log(type, event){
  380. const color = GM_config.get(`${type}color`);
  381. const background = GM_config.get(`${type}background`);
  382. const style = `
  383. color: ${color};
  384. background-color: ${background};
  385. font-style: ${GM_config.get('italic') ? 'italic' : 'unset'};
  386. font-weight: ${GM_config.get('bold') ? 'bold' : 'unset'};
  387. `;
  388. let property = GM_config.get('property');
  389. if (property != 'none') {
  390. property = event.originalEvent[property];
  391. }
  392. else {
  393. property = '';
  394. }
  395. switch (GM_config.get('method')) {
  396. case 'debug':
  397. console.debug(`%ctransition${type}:`, style, property, event.originalEvent);
  398. break;
  399. case 'dir':
  400. console.log(`%ctransition${type}:`, style, property);
  401. console.dir(event.originalEvent);
  402. break;
  403. case 'dirxml':
  404. console.log(`%ctransition${type}:`, style, property);
  405. console.dirxml(event.originalEvent);
  406. break;
  407. case 'error':
  408. console.error(`%ctransition${type}:`, style, property, event.originalEvent);
  409. break;
  410. case 'info':
  411. console.info(`%ctransition${type}:`, style, property, event.originalEvent);
  412. break;
  413. case 'log':
  414. console.log(`%ctransition${type}:`, style, property, event.originalEvent);
  415. break;
  416. case 'warn':
  417. console.warn(`%ctransition${type}:`, style, property, event.originalEvent);
  418. break;
  419. default:
  420. console.log(`%ctransition${type}:`, style, property, event.originalEvent);
  421. break;
  422. }
  423. }
  424. (function() {
  425. 'use strict';
  426. $(document).ready(() => {
  427. $(window).on({
  428. transitionrun: (e) => {
  429. if (GM_config.get('run')) {
  430. log('run', e);
  431. }
  432. },
  433. transitionstart: (e) => {
  434. if (GM_config.get('start')) {
  435. log('start', e);
  436. }
  437. },
  438. transitioncancel: (e) => {
  439. if (GM_config.get('cancel')) {
  440. log('cancel', e);
  441. }
  442. },
  443. transitionend: (e) => {
  444. if (GM_config.get('end')) {
  445. log('end', e);
  446. }
  447. },
  448. });
  449. });
  450. })();