Creating a SafeLink Generator on Blogger Page in Few Minutes

0

Safelinks are a common practice in the download-oriented blogging world, acting as a buffer between direct file links and your readers. They help monetize your content, protect against direct link theft, and often provide a layer of security. However, manually editing your Blogger template for every safelink can be tedious and prone to errors. Thankfully, there are ways to add safelinks to your Blogger download posts without directly modifying your template's HTML.

This blog post will guide you through adding a fully functional SafeLink generator to your Blogger page, allowing you to monetize your download links.

1. Create a New Blogger Page

  • Log in to your Blogger account.
  • In the left-hand menu, click "Pages."
  • Click "New Page."
  • Change the compose view to HTML view.
  • LIVE DEMO

2. Paste the HTML Code

Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>SafeLink Generator</title>

    <style>

        .hidden { display: none; }

        .center { text-align: center; margin-top: 20px; }

        .ads, .ad-slot { 

            margin: 20px auto; 

            width: 100%; 

            max-width: 300px; 

            height: 250px; 

            background-color: #f0f0f0; 

            border: 1px solid #ccc; 

            cursor: pointer;

            border: 2px solid #000; /* Added outer border */

        }

        .ad-slot { 

            width: 100%; 

            max-width: 230px; 

            height: 50px; 

            border: 2px solid #000; /* Added outer border */

        }

        .hidden-title { display: none; }

        .button {

            display: inline-block;

            padding: 10px 20px;

            font-size: 16px;

            cursor: pointer;

            text-align: center;

            color: #fff;

            background-color: #007bff;

            border: none;

            border-radius: 5px;

            text-decoration: none;

            transition: background-color 0.3s;

            width: 80%;

            max-width: 200px;

            margin: 10px;

            white-space: nowrap; /* Ensure button text is in a single line */

            min-width: 150px; /* Set minimum width to prevent wrapping */

        }

        .button:hover {

            background-color: #0056b3;

        }

        .button:active {

            background-color: #004494;

        }

        .fa-cloud-download, .fa-shield, .fa-info-circle {

            margin-right: 5px;

        }

        #generator {

            display: none;

        }

        .timer-box {

            display: inline-block;

            padding: 10px;

            border: 1px solid #007bff;

            border-radius: 5px;

            color: #007bff;

            text-align: center;

            font-size: 18px;

            margin-top: 10px;

            width: 150px; /* Set width to match button */

            cursor: pointer;

        }

        .password-container {

            padding: 20px;

            border: 2px solid #007bff;

            border-radius: 10px;

            max-width: 300px;

            margin: 20px auto;

            background-color: #f9f9f9;

        }

        .step-label-container {

            display: inline-flex;

            align-items: center;

            margin-bottom: 10px;

        }

        .step-label {

            color: red;

            font-size: 18px;

            font-weight: bold; /* Make text bold */

            display: inline-block;

        }

        .icon-info {

            display: inline-flex;

            align-items: center;

            margin-left: 5px; /* Reduced margin for tight button */

            margin-top: 0; /* Adjusted margin to fit up and down */

            margin-bottom: 0; /* Adjusted margin to fit up and down */

            cursor: pointer;

            color: #fff;

            background-color: #ff0000;

            vertical-align: middle;

            font-size: 8px; /* Reduced font size for very small button */

            border: 1px solid #ff0000;

            padding: 1px 2px; /* Reduced padding for very small button */

            border-radius: 3px;

        }

        .icon-info i {

            margin-right: 2px; /* Reduced margin for very small button */

        }

        .icon-info:hover {

            background-color: #cc0000;

            border-color: #cc0000;

        }

        .icon-info:active {

            background-color: #990000;

            border-color: #990000;

        }

        .congratulations {

            color: green;

            font-size: 18px;

            margin-top: 10px;

        }

        .popup-box {

            position: relative;

            margin: 20px auto;

            max-width: 800px;

            padding: 20px;

            background-color: #fff;

            border: 2px solid #007bff;

            border-radius: 10px;

            text-align: center;

        }

        .popup-box h2 {

            color: green;

        }

        .popup-box p {

            margin: 10px 0;

        }

        .close-btn {

            position: absolute;

            top: 10px;

            right: 10px;

            background-color: #007bff;

            color: #fff;

            border: none;

            border-radius: 50%;

            cursor: pointer;

            padding: 5px 10px;

            font-size: 14px;

        }

        .close-btn:hover {

            background-color: #0056b3;

        }

        /* Custom CSS to hide the Blogger page or post title on SafeLink page */

        .safelink-page .post-title, .safelink-page .entry-title, .safelink-page .post h3 {

            display: none;

        }

        .safelink-page .hidden-title { /* Hide title on safelink page */

            display: none;

        }



        /* Align ad slots properly */

        .ad-container {

            display: flex;

            flex-direction: column;

            align-items: center;

        }



        /* Responsive styles for the primary ad button */

        @media (max-width: 768px) {

            .ads {

                max-width: 100%;

                height: auto; /* Make primary ad space auto responsive */

            }

            .button {

                padding: 8px 16px;

                font-size: 14px;

                width: auto; /* Ensure button fits text */

                max-width: none; /* Ensure button fits text */

                min-width: 150px; /* Set minimum width to prevent wrapping */

            }

            .timer-box {

                width: 150px; /* Set width to match button */

                font-size: 16px;

            }

        }



        @media (max-width: 480px) {

            .ads {

                max-width: 100%;

                height: auto; /* Make primary ad space auto responsive */

            }

            .button {

                padding: 6px 12px;

                font-size: 12px;

                width: auto; /* Ensure button fits text */

                max-width: none; /* Ensure button fits text */

                min-width: 150px; /* Set minimum width to prevent wrapping */

            }

            .timer-box {

                width: 150px; /* Set width to match button */

                font-size: 14px;

            }

        }

        .responsive-ad {

            width: 100%;

            max-width: 728px; /* Maximum width for larger screens */

            height: auto;

            margin: 20px auto;

            background-color: #f0f0f0;

            border: 1px solid #ccc;

        }

    </style>

    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">

    <script>

        let reduceStepClickCount = 0;



        async function generateLink() {

            let url = document.getElementById('url').value.trim();

            if (!url.startsWith('http://') && !url.startsWith('https://')) {

                url = 'http://' + url;

            }

            const password = document.getElementById('password').value || '';

            const counter = document.getElementById('counter').value || 0;

            const steps = parseInt(document.getElementById('steps').value) || 1;

            const safelink = btoa(url + '|' + password + '|' + counter + '|' + steps + '|1'); // Encoding the link with step 1

            const baseUrl = window.location.origin + window.location.pathname;

            const generatedLink = baseUrl + '?link=' + safelink;

            document.getElementById('generatedLink').value = generatedLink;

            document.getElementById('generatedLinkContainer').classList.remove('hidden');

        }



        function startCounter(count) {

            if (count > 0) {

                document.getElementById('timerBox').innerText = 'Please wait';

                let counter = parseInt(count);

                const interval = setInterval(() => {

                    if (counter > 0) {

                        document.getElementById('timerBox').innerText = counter + ' sec.';

                        counter--;

                    } else {

                        clearInterval(interval);

                        showGetLinkButton();

                    }

                }, 1000);

            } else {

                showGetLinkButton();

            }

        }



        function showGetLinkButton() {

            const step = parseInt(document.getElementById('finalLink').dataset.step);

            const totalSteps = parseInt(document.getElementById('finalLink').dataset.totalSteps);

            let stepText;

            if (step < totalSteps) {

                stepText = `Step ${step} (${totalSteps - step} remaining)`;

            } else {

                stepText = 'Final Step';

            }

            document.getElementById('stepLabel').innerText = stepText;

            document.getElementById('reduceStepIcon').classList.remove('hidden');

            document.getElementById('timerBox').innerHTML = '<i class="fa fa-shield"></i> Get Link';

            document.getElementById('timerBox').onclick = () => {

                const password = document.getElementById('finalLink').dataset.password;

                if (password) {

                    document.getElementById('passwordPrompt').classList.remove('hidden');

                    document.getElementById('passwordPrompt').scrollIntoView({ behavior: 'smooth' });

                } else {

                    proceedToNextStep();

                }

                document.getElementById('timerBox').classList.add('hidden');

            };

        }



        function verifyPassword() {

            const enteredPassword = document.getElementById('enteredPassword').value;

            const correctPassword = document.getElementById('finalLink').dataset.password;

            if (enteredPassword === correctPassword) {

                document.getElementById('passwordPrompt').classList.add('hidden');

                proceedToNextStep();

            } else {

                alert('Incorrect password. Please try again.');

            }

        }



        function proceedToNextStep() {

            const url = document.getElementById('finalLink').dataset.url;

            const password = document.getElementById('finalLink').dataset.password;

            const counter = document.getElementById('finalLink').dataset.counter;

            const totalSteps = parseInt(document.getElementById('finalLink').dataset.totalSteps);

            const step = parseInt(document.getElementById('finalLink').dataset.step) + 1;



            if (step <= totalSteps) {

                const safelink = btoa(url + '|' + password + '|' + counter + '|' + totalSteps + '|' + step); // Encoding the link with the next step

                const baseUrl = window.location.origin + window.location.pathname;

                const generatedLink = baseUrl + '?link=' + safelink;

                window.location.href = generatedLink;

            } else {

                document.getElementById('getLinkContainer').classList.remove('hidden');

                document.getElementById('getLinkContainer').scrollIntoView({ behavior: 'smooth' });

            }

        }



        function onPageLoad() {

            const urlParams = new URLSearchParams(window.location.search);

            const link = urlParams.get('link');

            if (link) {

                const [url, password, counter, totalSteps, step] = atob(link).split('|'); // Decoding the link

                document.getElementById('finalLink').dataset.url = url;

                document.getElementById('finalLink').dataset.password = password;

                document.getElementById('finalLink').dataset.counter = counter;

                document.getElementById('finalLink').dataset.totalSteps = totalSteps;

                document.getElementById('finalLink').dataset.step = step;

                document.getElementById('ads').classList.remove('hidden');

                startCounter(counter);

                document.body.classList.add('safelink-page'); // Add class to body for SafeLink page styles

            } else {

                document.getElementById('generator').style.display = 'block';

            }

        }



        function adClicked() {

            const totalSteps = parseInt(document.getElementById('finalLink').dataset.totalSteps);

            const reducedSteps = Math.ceil(totalSteps / 2);

            document.getElementById('finalLink').dataset.totalSteps = reducedSteps;

            document.getElementById('popupBox').innerHTML = `

                <h2>Congratulations!</h2>

                <p>You have clicked on an ad. The number of steps has been reduced by 50%.</p>

                <p>This SafeLink page uses a step mechanism to ensure safe and secure redirection to your desired link. The total number of steps is determined by the user during link generation. Clicking on ads will reduce the number of steps by 50%, allowing you to reach your destination faster. Thank you for your support!</p>

                <button class="close-btn" onclick="closePopup()">X</button>

            `;

            document.getElementById('popupBox').classList.remove('hidden');

        }



        function showReduceStepInfo() {

            reduceStepClickCount++;

            if (reduceStepClickCount % 2 === 1) {

                document.getElementById('popupBox').innerHTML = `

                    <h2>Reduce Step Information</h2>

                    <p>If you click on ads, the number of steps to reach your final destination will be reduced by 50%. This helps support our service while providing you a faster route to your link.</p>

                    <button class="close-btn" onclick="closePopup()">X</button>

                `;

                document.getElementById('popupBox').classList.remove('hidden');

            } else {

                document.getElementById('popupBox').classList.add('hidden');

            }

        }



        function closePopup() {

            document.getElementById('popupBox').classList.add('hidden');

        }



        function copyLink() {

            const link = document.getElementById('generatedLink');

            link.select();

            link.setSelectionRange(0, 99999); // For mobile devices

            document.execCommand('copy');

            alert('Link copied to clipboard: ' + link.value);

        }



        function getLink() {

            const url = document.getElementById('finalLink').dataset.url;

            window.open(url, '_blank');

        }

    </script>

</head>

<body onload="onPageLoad()">

    <div id="safelinkGenerator" class="center">

        <h1 class="hidden-title">SafeLink Generator</h1>

        <div id="generator">

            <input type="text" id="url" placeholder="Enter URL" required><br><br>

            <input type="password" id="password" placeholder="Enter Password (Optional)"><br><br>

            <input type="number" id="counter" placeholder="Enter Counter in Seconds (Optional)"><br><br>

            <input type="number" id="steps" placeholder="Enter Number of Steps" min="1" max="10" value="1" required><br><br>

            <button class="button" onclick="generateLink()">Generate Link</button><br><br>

            <div id="generatedLinkContainer" class="hidden">

                <input type="text" id="generatedLink" readonly><br><br>

                <button class="button" onclick="copyLink()">Copy Link</button>

            </div>

        </div>

        <div id="ads" class="hidden">

            <div class="ads" onclick="adClicked()">Ad Space 1</div>

            <div class="ad-container">

                <div class="ad-slot" onclick="adClicked()">Ad Space 2 (230x50)</div>

            </div>

            <div class="step-label-container">

                <div id="stepLabel" class="step-label"></div>

                <div class="icon-info hidden" id="reduceStepIcon" onclick="showReduceStepInfo()">

                    <i class="fa fa-info-circle"></i> Reduce Step

                </div>

            </div>

            <div id="popupBox" class="popup-box hidden"></div>

            <br>

            <div id="timerBox" class="timer-box"></div>

            <br>

            <div class="ad-slot" onclick="adClicked()">Ad Space 3 (230x50)</div>

            <div class="ads" onclick="adClicked()">Ad Space 4</div>

        </div>

        <div id="passwordPrompt" class="hidden password-container">

            <input type="password" id="enteredPassword" placeholder="Enter Password"><br><br>

            <button class="button" onclick="verifyPassword()">Submit</button>

        </div>

        <div id="getLinkContainer" class="hidden">

            <button class="button" onclick="getLink()"><i class="fa fa-cloud-download"></i> Get Link</button>

        </div>

        <div id="finalLink" class="hidden" data-url="" data-password="" data-counter="" data-totalSteps="" data-step="">

            <a href="#" target="_blank">Go to Link</a>

        </div>

        <div class="responsive-ad">

            <!-- Your responsive ad code here -->

        </div>

    </div>

</body>

</html>
</div>

Key Featuress

  1. URL Input Field: Allows users to input the URL they want to generate a safe link for.
  2. Password Protection: Optional field for users to add a password to the generated safe link.
  3. Counter/Timer: Optional field to set a countdown timer before the link becomes accessible.
  4. Step Mechanism: Allows users to generate a link that requires multiple steps to access, enhancing security.
  5. Ads and Ad Spaces:
    • Primary Ad Space: Display ads to generate revenue, with responsiveness for different devices.
    • Additional Ad Slots: Smaller ad slots within the page.
  6. Generated Link Display: Shows the generated safe link to the user with a copy button.
  7. Get Link Button: Button to proceed to the final destination link, with responsive design to fit in a single line.
  8. Click Tracking and Rewards: Tracks ad clicks and reduces the number of steps required to access the final link.
  9. Popup Messages: Displays messages when ads are clicked, with a close button to hide the popup.
  10. Password Prompt: If a password is set, prompts the user to enter it before proceeding.
  11. SEO Tips Section: Provides SEO strategies and tips to boost website ranking.
  12. Responsive Design: Ensures the page is usable on both desktop and mobile devices.
  13. Responsive Ad Unit: Additional responsive ad unit after the main content.
Please note that this functionality extends beyond blogger to encompass all HTML and static web pages.

In essence, this code provides a comprehensive solution for creating and managing SafeLinks on your Blogger page, combining security, monetization, and user-friendliness.


Tags

Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.
Post a Comment (0)

buttons=(Accept !) days=(30)

Our website uses cookies to enhance your experience. Learn More about our cookie policy.
Accept !
To Top