User:-flowsINtomAyHeM/common.js
Jump to navigation
Jump to search
In other languages: 日本語 • Български • Deutsch • Ελληνικά • English • Español • Français • Magyar • Italiano • 한국어 • Nederlands • Polski • Português • Português do Brasil • Русский • Türkçe • 中文
CSS and Javascript changes must not modify the wiki.gg branding or advertisements.
Note: After saving, you may have to bypass your browser's cache to see the changes.
Firefox / Safari | Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
|
---|---|
Google Chrome | Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
|
Internet Explorer | Hold Ctrl while clicking Refresh, or press Ctrl-F5
|
Opera | Clear the cache in Tools → Preferences |
// Add play-on-hover behaviour to all video files with the .hoverPlay class
mw.hook('wikipage.content').add(function($content) {
$content.find('.hoverPlay video').each(function(i, video) {
video.setAttribute('loop', '');
video.setAttribute('muted', '');
video.removeAttribute('controls');
function onMouseOver(e) { e.target.play(); }
function onMouseOut(e) { e.target.pause(); e.target.currentTime = 0; }
video.addEventListener('mouseover', onMouseOver, false);
video.addEventListener('mouseout', onMouseOut, false);
video.addEventListener('click', function(e) {
e.target.removeEventListener('mouseover', onMouseOver, false);
e.target.removeEventListener('mouseout', onMouseOut, false);
e.target.setAttribute('controls', '');
}, { once: true }, false);
});
});