Skip to content

Instantly share code, notes, and snippets.

@biuuu
Last active October 10, 2018 09:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save biuuu/dcfdb0d561ea12f12d0912cada5ce121 to your computer and use it in GitHub Desktop.
Save biuuu/dcfdb0d561ea12f12d0912cada5ce121 to your computer and use it in GitHub Desktop.
anime1.me的窗口全屏用户脚本
// ==UserScript==
// @name anime1.me网页全屏
// @namespace https://gist.github.com/biuuu/dcfdb0d561ea12f12d0912cada5ce121
// @version 0.1.1
// @description 123
// @icon https://anime1.me/favicon.ico
// @author biuuu
// @match https://anime1.me/*
// @run-at document-end
// @grant none
// @updateURL https://gist.github.com/biuuu/dcfdb0d561ea12f12d0912cada5ce121/raw/6ccfe9325ecceecab10aa17e8a547da3906ceb89/pageFullscreen.user.js
// ==/UserScript==
(function () {
'use strict';
$('#main .entry-title').append('<button class="btn-page-fullscreen">窗口全屏</button><button class="btn-exit-fullscreen">退出全屏</button>')
$('#main').append(`<style>
.btn-page-fullscreen, .btn-exit-fullscreen {
margin-left: 20px;
padding: 4px 8px;
font-size: 12px;
display: none;
}
.btn-exit-fullscreen {
position: fixed;
top: 10px;
right: 10px;
z-index: 100000;
opacity: 0;
}
.post:hover .btn-page-fullscreen {
display: inline-block;
}
.post:hover .btn-exit-fullscreen {
opacity: 1;
}
</style>`)
var player = null
$('#main').on('click', '.btn-page-fullscreen', function () {
player = $(this).closest('.post').find('.entry-content iframe')
if (player) {
player.css({
position: 'fixed',
top: 0,
left: 0,
width: '100vw',
height: '100vh',
zIndex: 99999
})
$(this).closest('.post').find('.btn-exit-fullscreen').css({
display: 'block'
})
}
})
var exit = function (e) {
if (player) {
player.css({
position: '',
top: '',
left: '',
width: '',
height: '',
zIndex: ''
})
$(this).css({ display: 'none' })
player = null
}
}
$('#main').on('click', '.btn-exit-fullscreen', exit)
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment