Guest User

Dissenter on YT

a guest
Feb 28th, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.72 KB | None | 0 0
  1. ========= youtube-layout.js =========
  2.  
  3. let url = "";
  4. window.addEventListener("scroll", function(e) {
  5. if(window.location.href !== url) {
  6. url = window.location.href;
  7. // Test the root element of the extension, #reddit_comments, to see if extension has already been appended
  8. if (document.getElementById("comments") != null){
  9. document.getElementById("comments").remove();
  10. }
  11. if (document.getElementById("dissenter-parent-outer") != null){
  12. document.getElementById("dissenter-parent-outer").remove();
  13. }
  14.  
  15. var parent = document.createElement("div");
  16. parent.id = "dissenter-parent-outer"
  17.  
  18. var parentIn = document.createElement("div");
  19. parentIn.id = "dissenter-parent-inner"
  20.  
  21.  
  22. var iframe = document.createElement("iframe");
  23. iframe.src = "https://dissenter.com/discussion/begin-extension?url=" + url;
  24. iframe.id = "dissenter"
  25. iframe.class = "style-scope ytd-watch-flexy"
  26. parentIn.appendChild(iframe)
  27. parent.appendChild(parentIn)
  28. document.getElementById("primary-inner").appendChild(parent);
  29. }
  30. });
  31.  
  32. ========= youtube-layout.css =========
  33.  
  34. #dissenter {
  35. display: block;
  36. width: 100%;
  37. height: 100%;
  38. border: none;
  39. margin-top: -150px;
  40. }
  41. #dissenter-parent-inner {
  42. clip: rect(10px, 3000px, 3000px, 0px);
  43. position: absolute;
  44. width: 100%;
  45. height: 100%;
  46. }
  47. #dissenter-parent-outer {
  48. position: relative;
  49. width: 100%;
  50. height: 50%;
  51. }
  52. #primary-inner {
  53. height: 100%;
  54. }
  55.  
  56. ========= manifest.json =========
  57.  
  58. {
  59. "background.persistent": false,
  60. "incognito": "not_allowed",
  61. "offline_enabled": false,
  62. "version_name": "0.1.0",
  63. "manifest_version": 2,
  64. "name": "Dissenter Extension",
  65. "short_name": "Dissenter",
  66. "description": "Dissenter is the comment section of the Internet.",
  67. "homepage_url": "https://dissenter.com",
  68. "version": "0.1.0",
  69. "icons": {
  70. "16": "assets/images/logo/icon-16.png",
  71. "48": "assets/images/logo/icon-48.png",
  72. "128": "assets/images/logo/icon-128.png"
  73. },
  74. "permissions": [
  75. "activeTab",
  76. "https://*.dissenter.com/*"
  77. ],
  78. "browser_action": {
  79. "default_icon": "assets/images/logo/icon-128.png",
  80. "default_popup": "popup/popup.html"
  81. },
  82. "commands": {
  83. "_execute_browser_action": {
  84. "suggested_key": {
  85. "default": "Alt+Shift+D",
  86. "mac": "Alt+Shift+D"
  87. }
  88. }
  89. },
  90. "content_scripts": [{
  91. "matches": ["https://www.youtube.com/watch?v=*"],
  92. "js": ["content/youtube-layout.js"],
  93. "css": ["content/youtube-layout.css"],
  94. "run_at": "document_end"
  95. }],
  96. "background": {
  97. "scripts": [
  98. "background/background.js"
  99. ]
  100. },
  101. "content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self' https://*.dissenter.com/*"
  102. }
Advertisement
Add Comment
Please, Sign In to add comment