Reddit Sidebar Offscreen

Moves Reddit right sidebar offscreen, uses "q" to toggle

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Reddit Sidebar Offscreen
// @namespace    https://jyoko.github.io/
// @version      1.4
// @description  Moves Reddit right sidebar offscreen, uses "q" to toggle
// @author       jyoko
// @include      http*://*.reddit.com*
// @grant        none
// ==/UserScript==
/* jshint -W097 */
'use strict';

if (window.hasOwnProperty('$')) {
  window.addEventListener('keyup', function(e) {
    if (e.target.tagName === 'INPUT' || e.target.tagName === 'TEXTAREA') return;
    if (e.keyCode === 81) { // q
      toggler($('.side'));
    }
  });
  toggler($('.side'));
}
// Full credit to /u/GameFreak4321 here, excellent idea
// https://www.reddit.com/r/Enhancement/comments/swp8s/feature_request_a_button_to_hide_the_sidebar
function toggler(side) {
  if (side.hasClass('RESSidebarHide')){
    side.css('margin-right', '0px').removeClass('RESSidebarHide');
  } else {
    side.css('margin-right','-'+side.width()+'px').addClass('RESSidebarHide');
  }            
}